From 9d280ae2d3e8368006c31070b82c76444bb0554b Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 30 Dec 2020 07:06:03 +0900 Subject: [PATCH] Imported Upstream version 46.2.0 --- .bumpversion.cfg | 2 +- .github/FUNDING.yml | 1 + ...ls-warns-about-python-2-incompatibility.md | 53 +++++++++++ .gitignore | 1 + .travis.yml | 5 -- CHANGES.rst | 24 +++++ README.rst | 16 ++-- azure-pipelines.yml | 1 + changelog.d/1424.bugfix.rst | 1 - changelog.d/2041.bugfix.rst | 1 + docs/build_meta.txt | 89 +++++++++++++++++++ docs/history.txt | 2 +- docs/pkg_resources.txt | 6 +- docs/setuptools.txt | 5 +- pkg_resources/__init__.py | 37 ++++---- pkg_resources/api_tests.txt | 4 +- pkg_resources/py2_warn.py | 5 +- pkg_resources/tests/test_pkg_resources.py | 8 ++ pytest.ini | 3 + setup.cfg | 2 +- setuptools/command/bdist_wininst.py | 9 ++ setuptools/command/build_py.py | 9 +- setuptools/command/easy_install.py | 1 - setuptools/lib2to3_ex.py | 9 ++ setuptools/package_index.py | 2 +- setuptools/tests/test_bdist_deprecations.py | 23 +++++ setuptools/tests/test_build_py.py | 41 ++++++++- setuptools/tests/test_test.py | 6 ++ tools/finalize.py | 8 ++ tox.ini | 1 + 30 files changed, 327 insertions(+), 48 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/setuptools-warns-about-python-2-incompatibility.md delete mode 100644 changelog.d/1424.bugfix.rst create mode 100644 changelog.d/2041.bugfix.rst create mode 100644 docs/build_meta.txt create mode 100644 setuptools/tests/test_bdist_deprecations.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 03fe7b4..c1b062e 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 46.1.1 +current_version = 46.2.0 commit = True tag = True diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..27de01d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +tidelift: pypi/setuptools diff --git a/.github/ISSUE_TEMPLATE/setuptools-warns-about-python-2-incompatibility.md b/.github/ISSUE_TEMPLATE/setuptools-warns-about-python-2-incompatibility.md new file mode 100644 index 0000000..2f5fe53 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/setuptools-warns-about-python-2-incompatibility.md @@ -0,0 +1,53 @@ +--- +name: Setuptools warns about Python 2 incompatibility +about: Report the issue where setuptools 45 or later stops working on Python 2 +title: Incompatible install in (summarize your environment) +labels: Python 2 +assignees: '' + +--- + + + +## Prerequisites + + + +- [ ] Python 2 is required for this application. +- [ ] I maintain the software that installs Setuptools (if not, please contact that project). +- [ ] Setuptools installed with pip 9 or later. +- [ ] Pinning Setuptools to `setuptools<45` in the environment was unsuccessful. + +## Environment Details + +- Operating System and version: +- Python version: +- Python installed how: +- Virtualenv version (if using virtualenv): n/a + +Command(s) used to install setuptools (and output): + +``` +``` + +Output of `pip --version` when installing setuptools: + +``` +``` + +## Other notes diff --git a/.gitignore b/.gitignore index 0c272d1..90ae805 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ setuptools.egg-info .cache .idea/ .pytest_cache/ +.mypy_cache/ diff --git a/.travis.yml b/.travis.yml index 38a66f3..3e97f35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,11 +21,6 @@ jobs: - python: 3.8-dev - <<: *latest_py3 env: TOXENV=docs DISABLE_COVERAGE=1 - - <<: *latest_py3 - stage: deploy - if: tag IS present - script: tox -e release - after_success: skip allow_failures: # suppress failures due to pypa/setuptools#2000 - python: pypy3 diff --git a/CHANGES.rst b/CHANGES.rst index 1edbd12..03c89be 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,27 @@ +v46.2.0 +------- + +* #2040: Deprecated the ``bdist_wininst`` command. Binary packages should be built as wheels instead. +* #2062: Change 'Mac OS X' to 'macOS' in code. +* #2075: Stop recognizing files ending with ``.dist-info`` as distribution metadata. +* #2086: Deprecate 'use_2to3' functionality. Packagers are encouraged to use single-source solutions or build tool chains to manage conversions outside of setuptools. +* #1698: Added documentation for ``build_meta`` (a bare minimum, not completed). +* #2082: Filter ``lib2to3`` ``PendingDeprecationWarning`` and ``DeprecationWarning`` in testes, + because ``lib2to3`` is `deprecated in Python 3.9 `_. + + +v46.1.3 +------- + +No significant changes. + + +v46.1.2 +------- + +* #1458: Added template for reporting Python 2 incompatibilities. + + v46.1.1 ------- diff --git a/README.rst b/README.rst index da0549a..6caaa75 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,13 @@ .. image:: https://img.shields.io/pypi/v/setuptools.svg - :target: https://pypi.org/project/setuptools + :target: `PyPI link`_ -.. image:: https://img.shields.io/readthedocs/setuptools/latest.svg - :target: https://setuptools.readthedocs.io +.. image:: https://img.shields.io/pypi/pyversions/setuptools.svg + :target: `PyPI link`_ + +.. _PyPI link: https://pypi.org/project/setuptools + +.. image:: https://dev.azure.com/jaraco/setuptools/_apis/build/status/jaraco.setuptools?branchName=master + :target: https://dev.azure.com/jaraco/setuptools/_build/latest?definitionId=1&branchName=master .. image:: https://img.shields.io/travis/pypa/setuptools/master.svg?label=Linux%20CI&logo=travis&logoColor=white :target: https://travis-ci.org/pypa/setuptools @@ -10,14 +15,15 @@ .. image:: https://img.shields.io/appveyor/ci/pypa/setuptools/master.svg?label=Windows%20CI&logo=appveyor&logoColor=white :target: https://ci.appveyor.com/project/pypa/setuptools/branch/master +.. image:: https://img.shields.io/readthedocs/setuptools/latest.svg + :target: https://setuptools.readthedocs.io + .. image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white :target: https://codecov.io/gh/pypa/setuptools .. image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat :target: https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=readme -.. image:: https://img.shields.io/pypi/pyversions/setuptools.svg - See the `Installation Instructions `_ in the Python Packaging User's Guide for instructions on installing, upgrading, and uninstalling diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3e80bf4..0253a77 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -66,6 +66,7 @@ stages: tox -e release env: TWINE_PASSWORD: $(PyPI-token) + TIDELIFT_TOKEN: $(Tidelift-token) displayName: 'publish to PyPI' condition: contains(variables['Build.SourceBranch'], 'tags') diff --git a/changelog.d/1424.bugfix.rst b/changelog.d/1424.bugfix.rst deleted file mode 100644 index 2c7209f..0000000 --- a/changelog.d/1424.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed lint error (long line) in #1424. diff --git a/changelog.d/2041.bugfix.rst b/changelog.d/2041.bugfix.rst new file mode 100644 index 0000000..8db757d --- /dev/null +++ b/changelog.d/2041.bugfix.rst @@ -0,0 +1 @@ +Preserve file modes during pkg files copying, but clear read only flag for target afterwards. diff --git a/docs/build_meta.txt b/docs/build_meta.txt new file mode 100644 index 0000000..ef9fb2a --- /dev/null +++ b/docs/build_meta.txt @@ -0,0 +1,89 @@ +======================================= +Build System Support +======================================= + +What is it? +------------- + +Python packaging has come `a long way `_. + +The traditional ``setuptools`` way of packgaging Python modules +uses a ``setup()`` function within the ``setup.py`` script. Commands such as +``python setup.py bdist`` or ``python setup.py bdist_wheel`` generate a +distribution bundle and ``python setup.py install`` installs the distribution. +This interface makes it difficult to choose other packaging tools without an +overhaul. Because ``setup.py`` scripts allowed for arbitrary execution, it +proved difficult to provide a reliable user experience across environments +and history. + +`PEP 517 `_ therefore came to +rescue and specified a new standard to +package and distribute Python modules. Under PEP 517: + + a ``pyproject.toml`` file is used to specify what program to use + for generating distribution. + + Then, two functions provided by the program, ``build_wheel(directory: str)`` + and ``build_sdist(directory: str)`` create the distribution bundle at the + specified ``directory``. The program is free to use its own configuration + script or extend the ``.toml`` file. + + Lastly, ``pip install *.whl`` or ``pip install *.tar.gz`` does the actual + installation. If ``*.whl`` is available, ``pip`` will go ahead and copy + the files into ``site-packages`` directory. If not, ``pip`` will look at + ``pyproject.toml`` and decide what program to use to 'build from source' + (the default is ``setuptools``) + +With this standard, switching between packaging tools becomes a lot easier. ``build_meta`` +implements ``setuptools``' build system support. + +How to use it? +-------------- + +Starting with a package that you want to distribute. You will need your source +scripts, a ``pyproject.toml`` file and a ``setup.cfg`` file:: + + ~/meowpkg/ + pyproject.toml + setup.cfg + meowpkg/__init__.py + +The pyproject.toml file is required to specify the build system (i.e. what is +being used to package your scripts and install from source). To use it with +setuptools, the content would be:: + + [build-system] + requires = ["setuptools", "wheel"] + build-backend = "setuptools.build_meta" + +Use ``setuptools``' `declarative config`_ to specify the package information:: + + [metadata] + name = meowpkg + version = 0.0.1 + description = a package that meows + + [options] + packages = find: + +Now generate the distribution. Although the PyPA is still working to +`provide a recommended tool `_ +to build packages, the `pep517 package = "10.3" or \ dversion == 8 and macosversion >= "10.4": return True - # egg isn't macosx or legacy darwin + # egg isn't macOS or legacy darwin return False # are they the same major version and machine type? @@ -2069,11 +2069,14 @@ def find_on_path(importer, path_item, only=False): def dist_factory(path_item, entry, only): - """ - Return a dist_factory for a path_item and entry - """ + """Return a dist_factory for the given entry.""" lower = entry.lower() - is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info'))) + is_egg_info = lower.endswith('.egg-info') + is_dist_info = ( + lower.endswith('.dist-info') and + os.path.isdir(os.path.join(path_item, entry)) + ) + is_meta = is_egg_info or is_dist_info return ( distributions_from_metadata if is_meta else diff --git a/pkg_resources/api_tests.txt b/pkg_resources/api_tests.txt index 7ae5a03..ded1880 100644 --- a/pkg_resources/api_tests.txt +++ b/pkg_resources/api_tests.txt @@ -290,8 +290,8 @@ Platform Compatibility Rules ---------------------------- On the Mac, there are potential compatibility issues for modules compiled -on newer versions of Mac OS X than what the user is running. Additionally, -Mac OS X will soon have two platforms to contend with: Intel and PowerPC. +on newer versions of macOS than what the user is running. Additionally, +macOS will soon have two platforms to contend with: Intel and PowerPC. Basic equality works as on other platforms:: diff --git a/pkg_resources/py2_warn.py b/pkg_resources/py2_warn.py index 1b15195..bfc3523 100644 --- a/pkg_resources/py2_warn.py +++ b/pkg_resources/py2_warn.py @@ -12,9 +12,8 @@ msg = textwrap.dedent(""" Setuptools using pip 9.x or later or pin to `setuptools<45` in your environment. If you have done those things and are still encountering - this message, please comment in - https://github.com/pypa/setuptools/issues/1458 - about the steps that led to this unsupported combination. + this message, please follow up at + https://bit.ly/setuptools-py2-warning. """) pre = "Setuptools will stop working on Python 2\n" diff --git a/pkg_resources/tests/test_pkg_resources.py b/pkg_resources/tests/test_pkg_resources.py index 7828186..189a866 100644 --- a/pkg_resources/tests/test_pkg_resources.py +++ b/pkg_resources/tests/test_pkg_resources.py @@ -330,6 +330,14 @@ def test_distribution_version_missing_undetected_path(): assert msg == expected +@pytest.mark.parametrize('only', [False, True]) +def test_dist_info_is_not_dir(tmp_path, only): + """Test path containing a file with dist-info extension.""" + dist_info = tmp_path / 'foobar.dist-info' + dist_info.touch() + assert not pkg_resources.dist_factory(str(tmp_path), str(dist_info), only) + + class TestDeepVersionLookupDistutils: @pytest.fixture def env(self, tmpdir): diff --git a/pytest.ini b/pytest.ini index b13b7f3..479a296 100644 --- a/pytest.ini +++ b/pytest.ini @@ -20,3 +20,6 @@ filterwarnings = ignore:Unicode unequal comparison failed to convert:UnicodeWarning # https://github.com/pypa/setuptools/issues/2025 ignore:direct construction of .*Item has been deprecated:DeprecationWarning + # https://github.com/pypa/setuptools/issues/2081 + ignore:lib2to3 package is deprecated:PendingDeprecationWarning + ignore:lib2to3 package is deprecated:DeprecationWarning diff --git a/setup.cfg b/setup.cfg index 1442618..2f5525f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ formats = zip [metadata] name = setuptools -version = 46.1.1 +version = 46.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/command/bdist_wininst.py b/setuptools/command/bdist_wininst.py index 073de97..ff4b634 100644 --- a/setuptools/command/bdist_wininst.py +++ b/setuptools/command/bdist_wininst.py @@ -1,4 +1,7 @@ import distutils.command.bdist_wininst as orig +import warnings + +from setuptools import SetuptoolsDeprecationWarning class bdist_wininst(orig.bdist_wininst): @@ -14,6 +17,12 @@ class bdist_wininst(orig.bdist_wininst): return cmd def run(self): + warnings.warn( + "bdist_wininst is deprecated and will be removed in a future " + "version. Use bdist_wheel (wheel packages) instead.", + SetuptoolsDeprecationWarning + ) + self._is_running = True try: orig.bdist_wininst.run(self) diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index bac4fb1..9d0288a 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -7,6 +7,7 @@ import textwrap import io import distutils.errors import itertools +import stat from setuptools.extern import six from setuptools.extern.six.moves import map, filter, filterfalse @@ -20,6 +21,10 @@ except ImportError: "do nothing" +def make_writable(target): + os.chmod(target, os.stat(target).st_mode | stat.S_IWRITE) + + class build_py(orig.build_py, Mixin2to3): """Enhanced 'build_py' command that includes data files with packages @@ -120,8 +125,8 @@ class build_py(orig.build_py, Mixin2to3): target = os.path.join(build_dir, filename) self.mkpath(os.path.dirname(target)) srcfile = os.path.join(src_dir, filename) - outf, copied = self.copy_file( - srcfile, target, preserve_mode=False) + outf, copied = self.copy_file(srcfile, target) + make_writable(target) srcfile = os.path.abspath(srcfile) if (copied and srcfile in self.distribution.convert_2to3_doctests): diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 64ff045..5a9576f 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ Easy Install ------------ diff --git a/setuptools/lib2to3_ex.py b/setuptools/lib2to3_ex.py index 4b1a73f..017f728 100644 --- a/setuptools/lib2to3_ex.py +++ b/setuptools/lib2to3_ex.py @@ -7,11 +7,13 @@ Customized Mixin2to3 support: This module raises an ImportError on Python 2. """ +import warnings from distutils.util import Mixin2to3 as _Mixin2to3 from distutils import log from lib2to3.refactor import RefactoringTool, get_fixers_from_package import setuptools +from ._deprecation_warning import SetuptoolsDeprecationWarning class DistutilsRefactoringTool(RefactoringTool): @@ -33,6 +35,13 @@ class Mixin2to3(_Mixin2to3): return if not files: return + + warnings.warn( + "2to3 support is deprecated. If the project still " + "requires Python 2 support, please migrate to " + "a single-codebase solution or employ an " + "independent conversion process.", + SetuptoolsDeprecationWarning) log.info("Fixing " + " ".join(files)) self.__build_fixer_names() self.__exclude_fixers() diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 7a80241..0744ea2 100644 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -1053,7 +1053,7 @@ def open_with_auth(url, opener=urllib.request.urlopen): parsed = urllib.parse.urlparse(url) scheme, netloc, path, params, query, frag = parsed - # Double scheme does not raise on Mac OS X as revealed by a + # Double scheme does not raise on macOS as revealed by a # failing test. We would expect "nonnumeric port". Refs #20. if netloc.endswith(':'): raise http_client.InvalidURL("nonnumeric port: ''") diff --git a/setuptools/tests/test_bdist_deprecations.py b/setuptools/tests/test_bdist_deprecations.py new file mode 100644 index 0000000..704164a --- /dev/null +++ b/setuptools/tests/test_bdist_deprecations.py @@ -0,0 +1,23 @@ +"""develop tests +""" +import mock + +import pytest + +from setuptools.dist import Distribution +from setuptools import SetuptoolsDeprecationWarning + + +@mock.patch("distutils.command.bdist_wininst.bdist_wininst") +def test_bdist_wininst_warning(distutils_cmd): + dist = Distribution(dict( + script_name='setup.py', + script_args=['bdist_wininst'], + name='foo', + py_modules=['hi'], + )) + dist.parse_command_line() + with pytest.warns(SetuptoolsDeprecationWarning): + dist.run_commands() + + distutils_cmd.run.assert_called_once() diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index 92b455d..78a31ac 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -2,6 +2,8 @@ import os import stat import shutil +import pytest + from setuptools.dist import Distribution @@ -26,9 +28,10 @@ def test_directories_in_package_data_glob(tmpdir_cwd): def test_read_only(tmpdir_cwd): """ - Ensure mode is not preserved in copy for package modules - and package data, as that causes problems - with deleting read-only files on Windows. + Ensure read-only flag is not preserved in copy + for package modules and package data, as that + causes problems with deleting read-only files on + Windows. #1451 """ @@ -47,3 +50,35 @@ def test_read_only(tmpdir_cwd): dist.parse_command_line() dist.run_commands() shutil.rmtree('build') + + +@pytest.mark.xfail( + 'platform.system() == "Windows"', + reason="On Windows, files do not have executable bits", + raises=AssertionError, + strict=True, +) +def test_executable_data(tmpdir_cwd): + """ + Ensure executable bit is preserved in copy for + package data, as users rely on it for scripts. + + #2041 + """ + dist = Distribution(dict( + script_name='setup.py', + script_args=['build_py'], + packages=['pkg'], + package_data={'pkg': ['run-me']}, + name='pkg', + )) + os.makedirs('pkg') + open('pkg/__init__.py', 'w').close() + open('pkg/run-me', 'w').close() + os.chmod('pkg/run-me', 0o700) + + dist.parse_command_line() + dist.run_commands() + + assert os.stat('build/lib/pkg/run-me').st_mode & stat.S_IEXEC, \ + "Script is not executable" diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 8ee70a7..0f77d8f 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -73,7 +73,11 @@ def quiet_log(): log.set_verbosity(0) +ack_2to3 = pytest.mark.filterwarnings('ignore:2to3 support is deprecated') + + @pytest.mark.usefixtures('sample_test', 'quiet_log') +@ack_2to3 def test_test(capfd): params = dict( name='foo', @@ -124,6 +128,7 @@ def test_tests_are_run_once(capfd): @pytest.mark.usefixtures('sample_test') +@ack_2to3 def test_warns_deprecation(capfd): params = dict( name='foo', @@ -149,6 +154,7 @@ def test_warns_deprecation(capfd): @pytest.mark.usefixtures('sample_test') +@ack_2to3 def test_deprecation_stderr(capfd): params = dict( name='foo', diff --git a/tools/finalize.py b/tools/finalize.py index 3b66341..5f28456 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -53,7 +53,15 @@ def bump_version(): subprocess.check_call(cmd) +def ensure_config(): + """ + Double-check that Git has an e-mail configured. + """ + subprocess.check_output(['git', 'config', 'user.email']) + + if __name__ == '__main__': print("Cutting release at", get_version()) + ensure_config() update_changelog() bump_version() diff --git a/tox.ini b/tox.ini index 347106e..aa99e28 100644 --- a/tox.ini +++ b/tox.ini @@ -65,6 +65,7 @@ skip_install = True deps = towncrier bump2version +passenv = * commands = python tools/finalize.py -- 2.34.1