From 497e40f4128950376ca3ff09f96092a0f5c6c98f Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 30 Dec 2020 07:07:27 +0900 Subject: [PATCH] Imported Upstream version 49.2.0 --- .bumpversion.cfg | 2 +- .github/workflows/python-tests.yml | 9 +++++++++ CHANGES.rst | 6 ++++++ conftest.py | 18 ++++++++++++++++++ setup.cfg | 2 +- setuptools/distutils_patch.py | 19 ++++++++++++++++++- tox.ini | 4 ---- 7 files changed, 53 insertions(+), 7 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5e4d74b..9b3e408 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 49.1.3 +current_version = 49.2.0 commit = True tag = True diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 5a59808..f2188d3 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -30,6 +30,9 @@ jobs: - macOS-latest # - windows-2019 # - windows-2016 + include: + # Dev versions + - { python-version: 3.9-dev, os: ubuntu-20.04 } env: NETWORK_REQUIRED: 1 @@ -38,8 +41,14 @@ jobs: steps: - uses: actions/checkout@master + - name: Set up Python ${{ matrix.python-version }} (deadsnakes) + uses: deadsnakes/action@v1.0.0 + if: endsWith(matrix.python-version, '-dev') + with: + python-version: ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1.1.1 + if: "!endsWith(matrix.python-version, '-dev')" with: python-version: ${{ matrix.python-version }} - name: Log Python version diff --git a/CHANGES.rst b/CHANGES.rst index b23bc39..82e6ef6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,9 @@ +v49.2.0 +------- + +* #2230: Now warn the user when setuptools is imported after distutils modules have been loaded (exempting PyPy for 3.6), directing the users of packages to import setuptools first. + + v49.1.3 ------- diff --git a/conftest.py b/conftest.py index 50cc650..6013e18 100644 --- a/conftest.py +++ b/conftest.py @@ -19,6 +19,24 @@ collect_ignore = [ ] +def pytest_configure(config): + disable_coverage_on_pypy(config) + + +def disable_coverage_on_pypy(config): + """ + Coverage makes tests on PyPy unbearably slow, so disable it. + """ + if '__pypy__' not in sys.builtin_module_names: + return + + # Recommended at pytest-dev/pytest-cov#418 + cov = config.pluginmanager.get_plugin('_cov') + cov.options.no_cov = True + if cov.cov_controller: + cov.cov_controller.pause() + + if sys.version_info < (3,): collect_ignore.append('setuptools/lib2to3_ex.py') collect_ignore.append('setuptools/_imp.py') diff --git a/setup.cfg b/setup.cfg index bad15f9..fa0e565 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ formats = zip [metadata] name = setuptools -version = 49.1.3 +version = 49.2.0 description = Easily download, build, install, upgrade, and uninstall Python packages author = Python Packaging Authority author_email = distutils-sig@python.org diff --git a/setuptools/distutils_patch.py b/setuptools/distutils_patch.py index c5f273d..33f1e7f 100644 --- a/setuptools/distutils_patch.py +++ b/setuptools/distutils_patch.py @@ -12,10 +12,26 @@ import importlib import warnings +is_pypy = '__pypy__' in sys.builtin_module_names + + +def warn_distutils_present(): + if 'distutils' not in sys.modules: + return + if is_pypy and sys.version_info < (3, 7): + # PyPy for 3.6 unconditionally imports distutils, so bypass the warning + # https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250 + return + warnings.warn( + "Distutils was imported before Setuptools. This usage is discouraged " + "and may exhibit undesirable behaviors or errors. Please use " + "Setuptools' objects directly or at least import Setuptools first.") + + def clear_distutils(): if 'distutils' not in sys.modules: return - warnings.warn("Setuptools is replacing distutils") + warnings.warn("Setuptools is replacing distutils.") mods = [name for name in sys.modules if re.match(r'distutils\b', name)] for name in mods: del sys.modules[name] @@ -40,5 +56,6 @@ def ensure_local_distutils(): assert '_distutils' in core.__file__, core.__file__ +warn_distutils_present() if enabled(): ensure_local_distutils() diff --git a/tox.ini b/tox.ini index 5ae7b66..557c8d5 100644 --- a/tox.ini +++ b/tox.ini @@ -27,10 +27,6 @@ extras = tests -[testenv:pypy{,3}] -commands = pytest --no-cov {posargs} - - [testenv:coverage] description=Combine coverage data and create report deps=coverage -- 2.34.1