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

Merge with distutils@d7ffdb9c7 #4538

Closed
wants to merge 62 commits into from
Closed

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Aug 2, 2024

  • Distutils C++ support
  • 👹 Feed the hobgoblins (delint).
  • Adjust tests further to accommodate C++ support.
  • 👹 Feed the hobgoblins (delint).
  • Ignore sysconfig variables for LDCXXSHARED as it appears not to exist on PyPy.
  • ENH: Extension should be able to accept PathLike sources objects
  • Adjust expectation to match behavior.
  • For consistency, ensure Extension.sources is always a pathlib.Path object and adjust expectations in tests.
  • When computing input_opt, ensure src is a string (when it could be a pathlib Path).
  • In filelist, allow for self.files to be pathlib objects.
  • Revert "Disable cygwin tests for now. Ref test_cygwin job failing after adding ruff #3921"
  • find_library_file: port from doctest to normal test and fix for cygwin
  • test_customize_compiler_with_msvc_python: skip for cygwin
  • Prefer f-strings
  • Remove r string now that docstring is gone.
  • 👹 Feed the hobgoblins (delint).
  • 👹 Feed the hobgoblins (delint).
  • Allow path objects
  • Need to include 'three' in the input.
  • Consolidate str and Path handling.
  • Expand convert_path to also accept pathlib.Path objects.
  • Prefer simply 'pathlib' for import.
  • Extract a singledispatchmethod _copy for handling the copy of each data file.
  • Use explicit registration for compatibility with older Pythons.
  • Prefer os.PathLike in convert_path
  • Simply accept pathlib objects and convert them early for compatibilty with upstream.
  • Convert needs to accept None for Setuptools' sake.
  • In test_convert_path, utilize posixpath.join and ntpath.join for maximum compatibility with other libraries.
  • Wrap paths in PurePosixPath to ensure that any WindowsPaths don't get backslashes.
  • convert_path no longer fails if passed a path with a trailing slash. Instead, trailing slashes are stripped just as they are with pathlib.Path.
  • convert_path now converts to a platform-native path.Path, but then calls .as_posix() on it.
  • Separate test_convert_path into two tests to avoid interactions in monkeypatching os.path.
  • Remove expectation that a ValueError is raised for data_files being drive-relative absolute on Windows.
  • Simplify convert_path by simply relying on the logic in PurePath.
  • Harmonize convert_path tests across Unix and Windows.
  • Consolidate convert_path tests and just generate the expected value in a platform-sensitive way. Should fix failures on mingw.
  • Use simple import
  • venv_install_options: add missing clear_argv fixture
  • CI: add a job for running tests under MSVC CPython with GCC as the default compiler
  • mingw: make get_msvcr() a noop
  • Remove unused RangeMap
  • Harmonize '-shared' parameter for C and C++ in Mingw32CCompiler
  • In sysconfig.customize_compiler, initialize ldcxxshared from config vars.
  • Refactored customize_compiler to reduce logical branches and extract _add_flags logic.
  • Don't add flags when the value is None, such as when on PyPy, LDCXXSHARED is unset.
  • Rely on monkeysession to monkeypatch.
  • Apply isort. Ref Apply Scientific Python repo-review suggestions distutils#240

Summary of changes

Closes

Pull Request Checklist

sciyoshi and others added 30 commits March 2, 2024 10:40
Starting with b42197c UnixCCompiler got some improved support
for cygwin which made the doctest fail.

The doctest is hard to read as is, and adding more platform specific exceptions
wouldn't help, so just convert to a normal test and special case cygwin to make
the test pass there again.
Mingw32CCompiler() checks that the default compiler isn't cygwin,
so it can't be used under cygwin, so skip it there.
Prior to 3.11, singledispatch[method] doesn't know about unions.
jaraco and others added 24 commits July 20, 2024 15:16
Test for convert_path no longer runs on all operating systems as it's too difficult (impossible) to monkeypatch PurePath reliably.
…n a platform-sensitive way. Should fix failures on mingw.
ENH: Extension should be able to accept PathLike sources objects
Otherwise the test fails if arguments are passed to pytest, for example --no-cov:

FAILED distutils/tests/test_dist.py::TestDistributionBehavior::test_venv_install_options -
      distutils.errors.DistutilsArgError: option --no-cov not recognized
…fault compiler

The tests currently assume everywhere that there is only one compiler per platform,
and while it would be possible to parametrize all the tests it would make things more
complex and we'd also have to decide which compiler is required for running the tests and
which one is optional etc.

To avoid all this introduce a DISTUTILS_TEST_DEFAULT_COMPILER env var which can be used
to override the default compiler type for the whole test run. This keeps the tests as is
and makes sure all tests run against the alternative compiler. Also add it to pass_env
for tox, so it gets passed to pytest, if set.

The added CI job installs an ucrt targeting GCC via MSYS2, and forces the MSVC CPython
to use it via DISTUTILS_TEST_DEFAULT_COMPILER=mingw32.
This was added back in the day to make mingw use the same CRT as CPython
(https://bugs.python.org/issue870382), but at least with newer mingw-w64 and
ucrt switching the CRT at "runtime" isn't supported anymore. To build a
compatible extension you have to use a ucrt mingw-w64 build, so things match
up and link against the same CRT.

CPython 3.5+ uses ucrt (see https://wiki.python.org/moin/WindowsCompilers), so
anything besides that is no longer relevant, which only leaves vcruntime140.

Since it's not clear what linking against vcruntime140 solves, and there have
been reports of it needing to be patched out:

* #4101
* pypa/distutils#204 (comment)

let's just make it return nothing. Keep get_msvcr() around for now to avoid breaking
code which patched it.

Fixes #204
Its last use in cygwinccompiler was just removed.
…_add_flags logic.

Reduces cyclomatic complexity so it passes QA checks.
…nv_install_options

venv_install_options: add missing clear_argv fixture
…on-mingw-variant2

mingw: make get_msvcr() a noop + add a CI job testing MSVC Python with GCC
@jaraco
Copy link
Member Author

jaraco commented Aug 2, 2024

After pypa/distutils#275, I'm going to open a new PR.

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

Successfully merging this pull request may close these issues.

5 participants