Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use gcc compiler on Github windows runners with microsoft visual studio installed #822

Open
jiawlu opened this issue Jul 23, 2024 · 1 comment

Comments

@jiawlu
Copy link

jiawlu commented Jul 23, 2024

I'm using scikit-build-core to build my c++ program on github windows runners. I would like to use gcc instead of microsoft visual studio as the compiler. Below is how I configure compiler settings in my program, but it does not work (see the log, MSVS was used)

Github workflow file

name: build-wheels

on:
  push:
    branches: [main]
  pull_request:
    branches: [main, release]
  workflow_dispatch:

jobs:
  build_wheels:
    name: Build wheel for ${{ matrix.buildplat[1] }}
    runs-on: ${{ matrix.buildplat[0] }}
    strategy:
      fail-fast: false
      matrix:
        buildplat:
          - [windows-2022, win_amd64]
        python: ["cp38"]
    steps:
      - uses: actions/checkout@v3

      - name: Build wheels for win
        if: ${{ contains(matrix.buildplat[1], 'win') }}
        uses: pypa/[email protected]
        env:
          CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
          CIBW_ENVIRONMENT_WINDOWS: >
            CC=gcc
            CXX=g++
            SKBUILD_CMAKE_ARGS="-DCMAKE_C_COMPILER=gcc;-DCMAKE_CXX_COMPILER=g++"

      - uses: actions/upload-artifact@v3
        with:
          path: ./wheelhouse/*.whl

pyproject.toml file

[project.urls]
"Source Code" = "https://github.com/jiawlu/OSM2GMNS"
"Bug Tracker" = "https://github.com/jiawlu/OSM2GMNS/issues"

[build-system]
requires = ["scikit-build-core>=0.9.0", "ninja>=1.0"]
build-backend = "scikit_build_core.build"

[project]
name = "osm2gmns"
version = "1.0.0dev1"

requires-python = ">=3.8"
dependencies = []

classifiers = [
  "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.8",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
]


[tool.scikit-build]
wheel.packages = ["osm2gmns"]
wheel.install-dir = "osm2gmns"
wheel.expand-macos-universal-tags = true

cmake.version = ">=3.25"
cmake.args = ["-DBUILD_OSM2GMNS_EXE=OFF","-DCMAKE_C_COMPILER=gcc","-DCMAKE_CXX_COMPILER=g++","-GNinja"]
cmake.build-type = "Release"
cmake.verbose = true

sdist.include = [
    "docs",
    "python",
    "src"
]

sdist.exclude = [
  ".github",
  ".gitattributes",
  ".gitignore",
  "build"
]

[tool.cibuildwheel]
build = "*"
skip = "cp3{6,7}-*"
@henryiii
Copy link
Collaborator

Hmm, I would have thought that would work. You don't need CIBW_ENVIRONMENT_WINDOWS, you can just set the env vars directly. I'm not sure how well gcc works instead of MSVC when you are targeting the normal Windows CPython, it's not been officially supported since something like Python 3.3 from what I remember.

Do you have MinGW installed, though? In our tests (which build with the mingw, etc versions of Python), we have to install it:

cygwin:
name: Tests on 🐍 3.9 • cygwin
runs-on: windows-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: cygwin/cygwin-install-action@v4
with:
platform: x86_64
packages:
cmake ninja git make gcc-g++ python39 python39-devel python39-pip
- name: Install
run: python3.9 -m pip install .[test]
- name: Test package
run:
python3.9 -m pytest -ra --showlocals -m "not virtualenv"
--durations=20
msys:
name: Tests on 🐍 3 • msys UCRT
runs-on: windows-latest
timeout-minutes: 30
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
path-type: minimal
update: true
install: >-
base-devel git
pacboy: >-
python:p python-pip:p gcc:p cmake:p
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install
run: python -m pip install .[test]
- name: Test package
run: >-
python -m pytest -ra --showlocals -m "not broken_on_urct"
--durations=20
mingw64:
name: Tests on 🐍 3 • mingw64
runs-on: windows-latest
timeout-minutes: 30
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: mingw64
path-type: minimal
update: true
install: >-
base-devel git
pacboy: >-
python:p python-pip:p gcc:p cmake:p
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install
run: python -m pip install .[test]
- name: Test package
run: >-
python -m pytest -ra --showlocals -m "not setuptools" --durations=20
env:
SETUPTOOLS_USE_DISTUTILS: "local"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants