diff --git a/.github/workflows/tests-cygwin.yml b/.github/workflows/tests-cygwin.yml index 17e33bcfa..a446b3864 100644 --- a/.github/workflows/tests-cygwin.yml +++ b/.github/workflows/tests-cygwin.yml @@ -17,38 +17,80 @@ jobs: runs-on: windows-latest env: FORCE_COLOR: true + SHELLOPTS: igncr + CHERE_INVOKING: true strategy: fail-fast: false matrix: - python: - - '3.10' + python-minor: + - '9' steps: + - name: Tell git to use proper newlines + run: git config --global core.autocrlf input + - name: Checkout uses: actions/checkout@v2 - - name: Set up target Python - uses: actions/setup-python@v2 + - uses: actions/cache@v3 with: - python-version: ${{ matrix.python }} + path: 'C:\cygwin' + key: ${{ runner.os }}-cygwin-python-3${{ matrix.python-minor }}-${{ hashfiles('pyproject.toml') }} - name: Setup Cygwin uses: cygwin/cygwin-install-action@v2 + with: + packages: >- + python3${{ matrix.python-minor }} + python3${{ matrix.python-minor }}-pip + cmake make ninja gcc-core gcc-g++ git + gnupg gnupg2 meson pkg-config + + - name: Tell Cygwin git about this repository + # This addresses the "fatal: detected dubious ownership in + # repository" and "fatal: not in a git directory" errors + # encountered when trying to run Cygwin git in a directory not + # owned by the current user. This happens when the tests run + # Cygwin git in a directory outside the Cygwin filesystem. + run: git config --global --add safe.directory '*' + shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} - name: Install nox + shell: bash.exe -eo pipefail -o igncr "{0}" + env: + PATH: "/bin:/usr/bin:/usr/local/bin:/usr/lib/lapack" + TMP: "/tmp" + TEMP: "/tmp" run: | - python -m pip install nox + /usr/bin/python -m pip install nox nox --version + - name: Download setuptools/pip wheels for ensurepip + shell: bash.exe -eo pipefail -o igncr "{0}" + env: + PATH: "/bin:/usr/bin:/usr/local/bin:/usr/lib/lapack" + TMP: "/tmp" + TEMP: "/tmp" + run: | + mkdir -p /usr/share/python-wheels + /usr/bin/python -m pip wheel --wheel-dir /usr/share/python-wheels setuptools pip wheel + - name: Run tests - run: nox -s test-${{ matrix.python }} + shell: bash.exe -eo pipefail -o igncr "{0}" + env: + PATH: "/bin:/usr/bin:/usr/local/bin:/usr/lib/lapack" + CHERE_INVOKING: 1 + TMP: "/tmp" + TEMP: "/tmp" + run: | + nox -s test-3.${{ matrix.python-minor }} - name: Send coverage report uses: codecov/codecov-action@v1 if: ${{ always() }} env: - PYTHON: cygwin-${{ matrix.python }} + PYTHON: cygwin-3.${{ matrix.python-minor }} with: flags: tests env_vars: PYTHON - name: cygwin-${{ matrix.python }} + name: cygwin-3.${{ matrix.python-minor }} diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index 6a271d781..2b0fa54cf 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -103,6 +103,7 @@ def _init_colors() -> Dict[str, str]: _LINUX_NATIVE_MODULE_REGEX = re.compile(r'^(?P.+)\.(?P.+)\.so$') +_CYGWIN_NATIVE_MODULE_REGEX = re.compile(r'^(?P.+)\.(?P.+)\.dll$') _WINDOWS_NATIVE_MODULE_REGEX = re.compile(r'^(?P.+)\.(?P.+)\.pyd$') _STABLE_ABI_TAG_REGEX = re.compile(r'^abi(?P[0-9]+)$') @@ -345,7 +346,7 @@ def _calculate_file_abi_tag_heuristic_posix(self, filename: str) -> Optional[mes # preventive and check its value to make sure it matches our expectations try: extension = sysconfig.get_config_vars().get('SHLIB_SUFFIX', '.so') - if extension != '.so': + if extension not in ('.so', '.dll'): raise NotImplementedError( f"We don't currently support the {extension} extension. " 'Please report this to https://github.com/mesonbuild/mesonpy/issues ' @@ -358,7 +359,10 @@ def _calculate_file_abi_tag_heuristic_posix(self, filename: str) -> Optional[mes 'Please report this to https://github.com/mesonbuild/mesonpy/issues ' 'and include the output of `python -m sysconfig`.' ) - match = _LINUX_NATIVE_MODULE_REGEX.match(filename) + if sys.platform == 'cygwin': + match = _CYGWIN_NATIVE_MODULE_REGEX.match(filename) + else: + match = _LINUX_NATIVE_MODULE_REGEX.match(filename) if not match: # this file does not appear to be a native module return None tag = match.group('tag') diff --git a/noxfile.py b/noxfile.py index 3a31522e9..0b5f0f297 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,7 @@ import os import os.path +import platform import nox @@ -46,6 +47,10 @@ def test(session): if os.environ.get('GITHUB_ACTIONS') == 'true': session.install('pytest-github-actions-annotate-failures') + # https://github.com/gitpython-developers/GitPython/pull/1455 + if platform.system().startswith('CYGWIN'): + session.install('git+https://github.com/gitpython-developers/GitPython.git') + session.run( 'pytest', '--showlocals', '-vv', diff --git a/pyproject.toml b/pyproject.toml index 8e2faa38b..5d40b2d33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ test = [ 'Cython', 'pyproject-metadata>=0.6.1', 'wheel', + 'importlib_metadata; python_version < "3.8"', ] docs = [ 'furo>=2021.08.31', diff --git a/tests/test_wheel.py b/tests/test_wheel.py index e0c7c667f..6f898fd7c 100644 --- a/tests/test_wheel.py +++ b/tests/test_wheel.py @@ -18,7 +18,8 @@ INTERPRETER_VERSION = f'{sys.version_info[0]}{sys.version_info[1]}' -if platform.python_implementation() == 'CPython': +python_implementation = platform.python_implementation() +if python_implementation == 'CPython' or python_implementation.startswith('CYGWIN'): INTERPRETER_TAG = f'cp{INTERPRETER_VERSION}' PYTHON_TAG = INTERPRETER_TAG # Py_UNICODE_SIZE has been a runtime option since Python 3.3, @@ -30,11 +31,11 @@ pymalloc = sysconfig.get_config_var('WITH_PYMALLOC') if pymalloc or pymalloc is None: # none is the default value, which is enable INTERPRETER_TAG += 'm' -elif platform.python_implementation() == 'PyPy': +elif python_implementation == 'PyPy': INTERPRETER_TAG = sysconfig.get_config_var('SOABI').replace('-', '_') PYTHON_TAG = f'pp{INTERPRETER_VERSION}' else: - raise NotImplementedError(f'Unknown implementation: {platform.python_implementation()}') + raise NotImplementedError(f'Unknown implementation: {python_implementation}') platform_ = sysconfig.get_platform() if platform.system() == 'Darwin': @@ -51,7 +52,7 @@ SHARED_LIB_EXT = 'so' elif platform.system() == 'Darwin': SHARED_LIB_EXT = 'dylib' -elif platform.system() == 'Windows': +elif platform.system() == 'Windows' or platform.system().startswith('CYGWIN'): SHARED_LIB_EXT = 'pyd' else: raise NotImplementedError(f'Unknown system: {platform.system()}') @@ -93,7 +94,7 @@ def test_scipy_like(wheel_scipy_like): 'mypkg/submod/__init__.py', 'mypkg/submod/unknown_filetype.npq', } - if os.name == 'nt': + if os.name == 'nt' or sys.platform == 'cygwin': # Currently Meson is installing `.dll.a` (import libraries) next to # `.pyd` extension modules. Those are very small, so it's not a major # issue - just sloppy. For now, ensure we don't fail on those @@ -143,6 +144,8 @@ def test_purelib_and_platlib(wheel_purelib_and_platlib): } if platform.system() == 'Windows': expecting.add('plat{}'.format(EXT_SUFFIX.replace('pyd', 'dll.a'))) + elif sys.platform == 'cygwin': + expecting.add('plat{}'.format(EXT_SUFFIX.replace('dll', 'dll.a'))) assert wheel_contents(artifact) == expecting @@ -193,6 +196,7 @@ def test_executable_bit(wheel_executable_bit): executable_files = { 'executable_bit-1.0.0.data/purelib/executable_module.py', 'executable_bit-1.0.0.data/scripts/example', + 'executable_bit-1.0.0.data/scripts/example.exe', 'executable_bit-1.0.0.data/scripts/example-script', 'executable_bit-1.0.0.data/data/bin/example-script', }