From: JinWang An Date: Mon, 27 Mar 2023 08:02:38 +0000 (+0900) Subject: Imported Upstream version 59.0.0 X-Git-Tag: upstream/59.0.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37a699110e7f42c526d4a9b62188f04d09588071;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 59.0.0 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fe2b8e3..2bcedf6 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 58.5.3 +current_version = 59.0.0 commit = True tag = True diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a82b6fd..265be84 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,9 @@ jobs: test: strategy: matrix: + distutils: + - stdlib + - local python: - pypy3 - 3.6 @@ -16,6 +19,8 @@ jobs: - macos-latest - windows-latest runs-on: ${{ matrix.platform }} + env: + SETUPTOOLS_USE_DISTUTILS: ${{ matrix.distutils }} steps: - uses: actions/checkout@v2 - name: Setup Python diff --git a/CHANGES.rst b/CHANGES.rst index 7285616..0caed66 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,37 @@ +v59.0.0 +------- + + +Deprecations +^^^^^^^^^^^^ +* #2856: Support for custom commands that inherit directly from ``distutils`` is + **deprecated**. Users should extend classes provided by setuptools instead. + +Breaking Changes +^^^^^^^^^^^^^^^^ +* #2870: Started failing on invalid inline description with line breaks :class:`ValueError` -- by :user:`webknjaz` + +Changes +^^^^^^^ +* #2698: Exposed exception classes from ``distutils.errors`` via ``setuptools.errors``. +* #2866: Incorporate changes from pypa/distutils@f1b0a2b. + +Documentation changes +^^^^^^^^^^^^^^^^^^^^^ +* #2227: Added sphinx theme customisations to display the new logo in the sidebar and + use its colours as "accent" in the documentation -- by :user:`abravalheri` +* #2227: Added new setuptools logo, including editable files and artwork documentation + -- by :user:`abravalheri` +* #2698: Added mentions to ``setuptools.errors`` as a way of handling custom command + errors. +* #2698: Added instructions to migrate from ``distutils.commands`` and + ``distutils.errors`` in the porting guide. +* #2871: Added a note to the docs that it is possible to install + ``setup.py``-less projects in editable mode with :doc:`pip v21.1+ + `, only having ``setup.cfg`` and ``pyproject.toml`` in + project root -- by :user:`webknjaz` + + v58.5.3 ------- @@ -204,7 +238,7 @@ Documentation changes some confusion. Add some examples and the version since when ``entry_points`` are supported in declarative configuration. - Tried to make the reading flow a bit leaner, gather some informations + Tried to make the reading flow a bit leaner, gather some information that were a bit dispersed. @@ -4291,7 +4325,7 @@ how it parses version numbers. * Fix test suite with Python 2.6. * Fix some DeprecationWarnings and ResourceWarnings. -* Distribute #335: Backed out ``setup_requires`` superceding installed requirements +* Distribute #335: Backed out ``setup_requires`` superseding installed requirements until regression can be addressed. 0.6.31 @@ -4310,7 +4344,7 @@ how it parses version numbers. PYTHONIOENCODING=utf8 pip install numpy * Fix for encoding issue when installing from Windows executable on Python 3. -* Distribute #323: Allow ``setup_requires`` requirements to supercede installed +* Distribute #323: Allow ``setup_requires`` requirements to supersede installed requirements. Added some new keyword arguments to existing pkg_resources methods. Also had to updated how __path__ is handled for namespace packages to ensure that when a new egg distribution containing a namespace package is @@ -4333,13 +4367,13 @@ how it parses version numbers. * If Sphinx is installed, the ``upload_docs`` command now runs ``build_sphinx`` to produce uploadable documentation. * Distribute #326: ``upload_docs`` provided mangled auth credentials under Python 3. -* Distribute #320: Fix check for "createable" in distribute_setup.py. +* Distribute #320: Fix check for "creatable" in distribute_setup.py. * Distribute #305: Remove a warning that was triggered during normal operations. * Distribute #311: Print metadata in UTF-8 independent of platform. * Distribute #303: Read manifest file with UTF-8 encoding under Python 3. * Distribute #301: Allow to run tests of namespace packages when using 2to3. * Distribute #304: Prevent import loop in site.py under Python 3.3. -* Distribute #283: Reenable scanning of ``*.pyc`` / ``*.pyo`` files on Python 3.3. +* Distribute #283: Re-enable scanning of ``*.pyc`` / ``*.pyo`` files on Python 3.3. * Distribute #299: The develop command didn't work on Python 3, when using 2to3, as the egg link would go to the Python 2 source. Linking to the 2to3'd code in build/lib makes it work, although you will have to rebuild the module diff --git a/README.rst b/README.rst index 6913517..6e7b95c 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,8 @@ +.. image:: https://raw.githubusercontent.com/pypa/setuptools/main/docs/images/banner-640x320.svg + :align: center + +| + .. image:: https://img.shields.io/pypi/v/setuptools.svg :target: `PyPI link`_ diff --git a/docs/conf.py b/docs/conf.py index ba54142..d352a48 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -101,6 +101,20 @@ default_role = 'any' # HTML theme html_theme = 'furo' +html_logo = "images/logo.png" +html_favicon = "images/favicon.ico" + +html_theme_options = { + "sidebar_hide_name": True, + "light_css_variables": { + "color-brand-primary": "#336790", # "blue" + "color-brand-content": "#336790", + }, + "dark_css_variables": { + "color-brand-primary": "#E5B62F", # "yellow" + "color-brand-content": "#E5B62F", + }, +} # Add support for inline tabs extensions += ['sphinx_inline_tabs'] @@ -157,3 +171,5 @@ towncrier_draft_working_directory = '..' towncrier_draft_include_empty = False extensions += ['jaraco.tidelift'] + +intersphinx_mapping['pip'] = 'https://pip.pypa.io/en/latest', None diff --git a/docs/deprecated/distutils-legacy.rst b/docs/deprecated/distutils-legacy.rst index a5d9626..94104fe 100644 --- a/docs/deprecated/distutils-legacy.rst +++ b/docs/deprecated/distutils-legacy.rst @@ -18,8 +18,17 @@ As Distutils is deprecated, any usage of functions or objects from distutils is ``distutils.cmd.Command`` → ``setuptools.Command`` +``distutils.command.{build_clib,build_ext,build_py,sdist}`` → ``setuptools.command.*`` + ``distutils.log`` → (no replacement yet) ``distutils.version.*`` → ``packaging.version.*`` +``distutils.errors.*`` → ``setuptools.errors.*`` [#errors]_ + If a project relies on uses of ``distutils`` that do not have a suitable replacement above, please search the `Setuptools issue tracker `_ and file a request, describing the use-case so that Setuptools' maintainers can investigate. Please provide enough detail to help the maintainers understand how distutils is used, what value it provides, and why that behavior should be supported. + + +.. [#errors] Please notice errors related to the command line usage of + ``setup.py``, such as ``DistutilsArgError``, are intentionally not exposed + by setuptools, since this is considered a deprecated practice. diff --git a/docs/images/README.rst b/docs/images/README.rst new file mode 100644 index 0000000..d80dc96 --- /dev/null +++ b/docs/images/README.rst @@ -0,0 +1,119 @@ +======= +Artwork +======= + +.. figure:: logo-over-white.svg + :align: center + + Setuptools logo, designed in 2021 by `Anderson Bravalheri`_ + +Elements of Design +================== + +The main colours of the design are a dark pastel azure (``#336790``) and a pale +orange (``#E5B62F``), referred in this document simply as "blue" and "yellow" +respectively. The text uses the *Monoid* typeface, an open source webfont that +was developed by Andreas Larsen and contributors in 2015 and is distributed +under the MIT or SIL licenses (more information at +https://github.com/larsenwork/monoid) + + +Usage +===== + +The preferred way of using the setuptools logo is over a white (or light) +background. Alternatively, the following options can be considered, depending +on the circumstances: + +- *"negative"* design - for dark backgrounds (e.g. website displayed in "dark + mode"): the white colour (``#FFFFFF``) of the background and the "blue" + (``#336790``) colour of the design can be swapped. +- *"monochrome"* - when colours are not available (e.g. black and white printed + media): a completely black or white version of the logo can also be used. +- *"banner"* mode: the symbol and text can be used alongside depending on the + available space. + +The following image illustrate these alternatives: + +.. image:: logo-demo-editable-inkscape.png + :align: center + +Please refer to the SVG files in the `setuptools repository`_ for the specific +shapes and proportions between the elements of the design. + + +Working with the Design +======================= + +The `setuptools repository`_ contains a series of vector representations of the +design under the ``docs/images`` directory. These representations can be +manipulated via any graphic editor that support SVG files, +however the free and open-source software Inkscape_ is recommended for maximum +compatibility. + +When selecting the right file to work with, file names including +``editable-inkscape`` indicate "more editable" elements (e.g. editable text), +while the others prioritise SVG paths for maximum reproducibility. + +Also notice that you might have to `install the correct fonts`_ to be able to +visualise or edit some of the designs. + + +Inspiration +=========== + +This design was inspired by :user:`cajhne`'s `original proposal`_ and the +ancient symbol of the ouroboros_. +It features a snake moving in a circular trajectory not only as a reference to +the Python programming language but also to the `wheel package format`_ as one +of the distribution formats supported by setuptools. +The shape of the snake also resembles a cog, which together with the hammer is +a nod to the two words that compose the name of the project. + + +License +======= + + +This logo, design variations or a modified version may be used by anyone to +refer to setuptools, but does not indicate endorsement by the project. + +Redistribution, usage and derivative works are permitted under the same license +used by the setuptools software (MIT): + +.. code-block:: text + + Copyright (c) Anderson Bravalheri + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + IN THE SOFTWARE. + + THE USAGE OF THIS LOGO AND ARTWORK DOES NOT INDICATE ENDORSEMENT BY THE + SETUPTOOLS PROJECT. + +Whenever possible, please make the image a link to +https://github.com/pypa/setuptools. + + +.. _Anderson Bravalheri: https://github.com/abravalheri +.. _Inkscape: https://inkscape.org +.. _setuptools repository: https://github.com/pypa/setuptools +.. _install the correct fonts: https://wiki.inkscape.org/wiki/Installing_fonts +.. _original proposal: https://github.com/pypa/setuptools/issues/2227#issuecomment-653628344 +.. _wheel package format: https://www.python.org/dev/peps/pep-0427/ +.. _ouroboros: https://en.wikipedia.org/wiki/Ouroboros diff --git a/docs/images/banner-640x320.png b/docs/images/banner-640x320.png new file mode 100644 index 0000000..ce7f99f Binary files /dev/null and b/docs/images/banner-640x320.png differ diff --git a/docs/images/banner-640x320.svg b/docs/images/banner-640x320.svg new file mode 100644 index 0000000..8222f64 --- /dev/null +++ b/docs/images/banner-640x320.svg @@ -0,0 +1,101 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/banner-negative-640x320.png b/docs/images/banner-negative-640x320.png new file mode 100644 index 0000000..c0126f8 Binary files /dev/null and b/docs/images/banner-negative-640x320.png differ diff --git a/docs/images/banner-negative-640x320.svg b/docs/images/banner-negative-640x320.svg new file mode 100644 index 0000000..fd5535f --- /dev/null +++ b/docs/images/banner-negative-640x320.svg @@ -0,0 +1,109 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/favicon.ico b/docs/images/favicon.ico new file mode 100644 index 0000000..152f063 Binary files /dev/null and b/docs/images/favicon.ico differ diff --git a/docs/images/favicon.svg b/docs/images/favicon.svg new file mode 100644 index 0000000..6f640f9 --- /dev/null +++ b/docs/images/favicon.svg @@ -0,0 +1,43 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/docs/images/favicon.xcf b/docs/images/favicon.xcf new file mode 100644 index 0000000..2cf5ff2 Binary files /dev/null and b/docs/images/favicon.xcf differ diff --git a/docs/images/logo-demo-editable-inkscape.png b/docs/images/logo-demo-editable-inkscape.png new file mode 100644 index 0000000..70ca467 Binary files /dev/null and b/docs/images/logo-demo-editable-inkscape.png differ diff --git a/docs/images/logo-demo-editable-inkscape.svg b/docs/images/logo-demo-editable-inkscape.svg new file mode 100644 index 0000000..45969b1 --- /dev/null +++ b/docs/images/logo-demo-editable-inkscape.svg @@ -0,0 +1,888 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + + + diff --git a/docs/images/logo-editable-inkscape.png b/docs/images/logo-editable-inkscape.png new file mode 100644 index 0000000..09036fc Binary files /dev/null and b/docs/images/logo-editable-inkscape.png differ diff --git a/docs/images/logo-editable-inkscape.svg b/docs/images/logo-editable-inkscape.svg new file mode 100644 index 0000000..1b323a5 --- /dev/null +++ b/docs/images/logo-editable-inkscape.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + SETUP + TOOLS + + + + diff --git a/docs/images/logo-inline-negative.png b/docs/images/logo-inline-negative.png new file mode 100644 index 0000000..6718373 Binary files /dev/null and b/docs/images/logo-inline-negative.png differ diff --git a/docs/images/logo-inline-negative.svg b/docs/images/logo-inline-negative.svg new file mode 100644 index 0000000..deed96e --- /dev/null +++ b/docs/images/logo-inline-negative.svg @@ -0,0 +1,105 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/logo-inline.png b/docs/images/logo-inline.png new file mode 100644 index 0000000..33e0e48 Binary files /dev/null and b/docs/images/logo-inline.png differ diff --git a/docs/images/logo-inline.svg b/docs/images/logo-inline.svg new file mode 100644 index 0000000..11ab7df --- /dev/null +++ b/docs/images/logo-inline.svg @@ -0,0 +1,97 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/logo-negative.png b/docs/images/logo-negative.png new file mode 100644 index 0000000..c025f4f Binary files /dev/null and b/docs/images/logo-negative.png differ diff --git a/docs/images/logo-negative.svg b/docs/images/logo-negative.svg new file mode 100644 index 0000000..23a553d --- /dev/null +++ b/docs/images/logo-negative.svg @@ -0,0 +1,106 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/logo-over-white.png b/docs/images/logo-over-white.png new file mode 100644 index 0000000..60bbff3 Binary files /dev/null and b/docs/images/logo-over-white.png differ diff --git a/docs/images/logo-over-white.svg b/docs/images/logo-over-white.svg new file mode 100644 index 0000000..3ae3968 --- /dev/null +++ b/docs/images/logo-over-white.svg @@ -0,0 +1,106 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/logo-symbol-only.png b/docs/images/logo-symbol-only.png new file mode 100644 index 0000000..9cf13f8 Binary files /dev/null and b/docs/images/logo-symbol-only.png differ diff --git a/docs/images/logo-symbol-only.svg b/docs/images/logo-symbol-only.svg new file mode 100644 index 0000000..febdb3e --- /dev/null +++ b/docs/images/logo-symbol-only.svg @@ -0,0 +1,46 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/docs/images/logo-text-only.png b/docs/images/logo-text-only.png new file mode 100644 index 0000000..0c5500b Binary files /dev/null and b/docs/images/logo-text-only.png differ diff --git a/docs/images/logo-text-only.svg b/docs/images/logo-text-only.svg new file mode 100644 index 0000000..a59731d --- /dev/null +++ b/docs/images/logo-text-only.svg @@ -0,0 +1,85 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/logo.png b/docs/images/logo.png new file mode 100644 index 0000000..3f82125 Binary files /dev/null and b/docs/images/logo.png differ diff --git a/docs/images/logo.svg b/docs/images/logo.svg new file mode 100644 index 0000000..103d294 --- /dev/null +++ b/docs/images/logo.svg @@ -0,0 +1,98 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/index.rst b/docs/index.rst index 2833ab9..b886c8f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,8 @@ -setuptools -========== +.. image:: images/banner-640x320.svg + :align: center + +Documentation +============= Setuptools is a fully-featured, actively-maintained, and stable library designed to facilitate packaging Python projects. @@ -12,10 +15,17 @@ designed to facilitate packaging Python projects. build_meta pkg_resources references/keywords - roadmap setuptools + +.. toctree:: + :caption: Project + :maxdepth: 1 + :hidden: + + roadmap Development guide Backward compatibility & deprecated practice Changelog + Artwork .. tidelift-referral-banner:: diff --git a/docs/userguide/extension.rst b/docs/userguide/extension.rst index 93b5950..d74ca3f 100644 --- a/docs/userguide/extension.rst +++ b/docs/userguide/extension.rst @@ -45,6 +45,14 @@ entry points in the active distributions on ``sys.path``. In fact, this is how setuptools' own commands are installed: the setuptools project's setup script defines entry points for them! +.. note:: + When creating commands, and specially when defining custom ways of building + compiled extensions (for example via ``build_ext``), consider + handling exceptions such as ``CompileError``, ``LinkError``, ``LibError``, + among others. These exceptions are available in the ``setuptools.errors`` + module. + + Adding ``setup()`` Arguments ---------------------------- diff --git a/docs/userguide/quickstart.rst b/docs/userguide/quickstart.rst index bcb282e..6bf353a 100644 --- a/docs/userguide/quickstart.rst +++ b/docs/userguide/quickstart.rst @@ -186,17 +186,18 @@ For more details, see :doc:`datafiles` Development mode ================ -``setuptools`` allows you to install a package without copying any files -to your interpreter directory (e.g. the ``site-packages`` directory). This -allows you to modify your source code and have the changes take effect without -you having to rebuild and reinstall. This is currently incompatible with -PEP 517 and therefore it requires a ``setup.py`` script with the following -content:: - import setuptools - setuptools.setup() +.. tip:: + + Prior to :ref:`pip v21.1 `, a ``setup.py`` script was + required to be compatible with development mode. With late + versions of pip, any project may be installed in this mode. -Then:: +``setuptools`` allows you to install a package without copying any files +to your interpreter directory (e.g. the ``site-packages`` directory). +This allows you to modify your source code and have the changes take +effect without you having to rebuild and reinstall. +Here's how to do it:: pip install --editable . diff --git a/pytest.ini b/pytest.ini index 2678afd..df1c2af 100644 --- a/pytest.ini +++ b/pytest.ini @@ -34,3 +34,15 @@ filterwarnings= # https://github.com/pypa/setuptools/issues/2497 ignore:.* is an invalid version and will not be supported::pkg_resources + + # https://github.com/pypa/setuptools/pull/2865#issuecomment-965700112 + # ideally would apply to Python 3.10+ when + # SETUPTOOLS_USE_DISTUTILS=stdlib but for + # https://github.com/pytest-dev/pytest/discussions/9296 + ignore:The distutils.sysconfig module is deprecated, use sysconfig instead + + # Workaround for pypa/setuptools#2868 + # ideally would apply to PyPy only but for + # https://github.com/pytest-dev/pytest/discussions/9296 + ignore:Distutils was imported before setuptools + ignore:Setuptools is replacing distutils diff --git a/setup.cfg b/setup.cfg index fdaf6c0..6bcc369 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = setuptools -version = 58.5.3 +version = 59.0.0 author = Python Packaging Authority author_email = distutils-sig@python.org description = Easily download, build, install, upgrade, and uninstall Python packages @@ -55,11 +55,11 @@ testing = mock flake8-2020 virtualenv>=13.0.0 - pytest-virtualenv>=1.2.7 + pytest-virtualenv @ git+https://github.com/jaraco/pytest-plugins@distutils-deprecated#subdirectory=pytest-virtualenv wheel paver pip>=19.1 # For proper file:// URLs support. - jaraco.envs + jaraco.envs>=2.2 pytest-xdist sphinx jaraco.path>=3.2.0 diff --git a/setuptools/_distutils/ccompiler.py b/setuptools/_distutils/ccompiler.py index 48d160d..777fc66 100644 --- a/setuptools/_distutils/ccompiler.py +++ b/setuptools/_distutils/ccompiler.py @@ -802,7 +802,7 @@ int main (int argc, char **argv) { except (LinkError, TypeError): return False else: - os.remove("a.out") + os.remove(os.path.join(self.output_dir or '', "a.out")) finally: for fn in objects: os.remove(fn) diff --git a/setuptools/_distutils/command/install.py b/setuptools/_distutils/command/install.py index 866e2d5..e98f049 100644 --- a/setuptools/_distutils/command/install.py +++ b/setuptools/_distutils/command/install.py @@ -29,16 +29,16 @@ WINDOWS_SCHEME = { INSTALL_SCHEMES = { 'unix_prefix': { - 'purelib': '$base/lib/python$py_version_short/site-packages', - 'platlib': '$platbase/$platlibdir/python$py_version_short/site-packages', - 'headers': '$base/include/python$py_version_short$abiflags/$dist_name', + 'purelib': '$base/lib/$implementation_lower$py_version_short/site-packages', + 'platlib': '$platbase/$platlibdir/$implementation_lower$py_version_short/site-packages', + 'headers': '$base/include/$implementation_lower$py_version_short$abiflags/$dist_name', 'scripts': '$base/bin', 'data' : '$base', }, 'unix_home': { - 'purelib': '$base/lib/python', - 'platlib': '$base/$platlibdir/python', - 'headers': '$base/include/python/$dist_name', + 'purelib': '$base/lib/$implementation_lower', + 'platlib': '$base/$platlibdir/$implementation_lower', + 'headers': '$base/include/$implementation_lower/$dist_name', 'scripts': '$base/bin', 'data' : '$base', }, @@ -64,8 +64,8 @@ if HAS_USER_SITE: INSTALL_SCHEMES['nt_user'] = { 'purelib': '$usersite', 'platlib': '$usersite', - 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name', - 'scripts': '$userbase/Python$py_version_nodot/Scripts', + 'headers': '$userbase/$implementation$py_version_nodot/Include/$dist_name', + 'scripts': '$userbase/$implementation$py_version_nodot/Scripts', 'data' : '$userbase', } @@ -73,7 +73,7 @@ if HAS_USER_SITE: 'purelib': '$usersite', 'platlib': '$usersite', 'headers': - '$userbase/include/python$py_version_short$abiflags/$dist_name', + '$userbase/include/$implementation_lower$py_version_short$abiflags/$dist_name', 'scripts': '$userbase/bin', 'data' : '$userbase', } @@ -83,6 +83,12 @@ if HAS_USER_SITE: # and to SCHEME_KEYS here. SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') +def _get_implementation(): + if hasattr(sys, 'pypy_version_info'): + return 'PyPy' + else: + return 'Python' + class install(Command): @@ -313,6 +319,8 @@ class install(Command): 'exec_prefix': exec_prefix, 'abiflags': abiflags, 'platlibdir': getattr(sys, 'platlibdir', 'lib'), + 'implementation_lower': _get_implementation().lower(), + 'implementation': _get_implementation(), } if HAS_USER_SITE: diff --git a/setuptools/_distutils/tests/test_unixccompiler.py b/setuptools/_distutils/tests/test_unixccompiler.py index ee2fe99..63c7dd3 100644 --- a/setuptools/_distutils/tests/test_unixccompiler.py +++ b/setuptools/_distutils/tests/test_unixccompiler.py @@ -232,6 +232,13 @@ class UnixCCompilerTestCase(unittest.TestCase): sysconfig.customize_compiler(self.cc) self.assertEqual(self.cc.linker_so[0], 'my_ld') + def test_has_function(self): + # Issue https://github.com/pypa/distutils/issues/64: + # ensure that setting output_dir does not raise + # FileNotFoundError: [Errno 2] No such file or directory: 'a.out' + self.cc.output_dir = 'scratch' + self.cc.has_function('abort', includes=['stdlib.h']) + def test_suite(): return unittest.makeSuite(UnixCCompilerTestCase) diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8ae27d8..f221029 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -621,10 +621,11 @@ class manifest_maker(sdist): if hasattr(build_py, 'get_data_files_without_manifest'): return build_py.get_data_files_without_manifest() - log.warn( + warnings.warn( "Custom 'build_py' does not implement " "'get_data_files_without_manifest'.\nPlease extend command classes" - " from setuptools instead of distutils." + " from setuptools instead of distutils.", + SetuptoolsDeprecationWarning ) return build_py.get_data_files() diff --git a/setuptools/dist.py b/setuptools/dist.py index 8e2111a..848d6b0 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -145,11 +145,11 @@ def read_pkg_file(self, file): def single_line(val): - # quick and dirty validation for description pypa/setuptools#1390 + """Validate that the value does not have line breaks.""" + # Ref: https://github.com/pypa/setuptools/issues/1390 if '\n' in val: - # TODO after 2021-07-31: Replace with `raise ValueError("newlines not allowed")` - warnings.warn("newlines not allowed and will break in the future") - val = val.replace('\n', ' ') + raise ValueError('Newlines are not allowed') + return val diff --git a/setuptools/errors.py b/setuptools/errors.py index 2701747..f4d35a6 100644 --- a/setuptools/errors.py +++ b/setuptools/errors.py @@ -3,6 +3,7 @@ Provides exceptions used by setuptools modules. """ +from distutils import errors as _distutils_errors from distutils.errors import DistutilsError @@ -14,3 +15,26 @@ class RemovedCommandError(DistutilsError, RuntimeError): error is raised if a command exists in ``distutils`` but has been actively removed in ``setuptools``. """ + + +# Re-export errors from distutils to facilitate the migration to PEP632 + +ByteCompileError = _distutils_errors.DistutilsByteCompileError +CCompilerError = _distutils_errors.CCompilerError +ClassError = _distutils_errors.DistutilsClassError +CompileError = _distutils_errors.CompileError +ExecError = _distutils_errors.DistutilsExecError +FileError = _distutils_errors.DistutilsFileError +InternalError = _distutils_errors.DistutilsInternalError +LibError = _distutils_errors.LibError +LinkError = _distutils_errors.LinkError +ModuleError = _distutils_errors.DistutilsModuleError +OptionError = _distutils_errors.DistutilsOptionError +PlatformError = _distutils_errors.DistutilsPlatformError +PreprocessError = _distutils_errors.PreprocessError +SetupError = _distutils_errors.DistutilsSetupError +TemplateError = _distutils_errors.DistutilsTemplateError +UnknownFileError = _distutils_errors.UnknownFileError + +# The root error class in the hierarchy +BaseError = _distutils_errors.DistutilsError diff --git a/setuptools/tests/test_distutils_adoption.py b/setuptools/tests/test_distutils_adoption.py index 0e89921..b6b9c00 100644 --- a/setuptools/tests/test_distutils_adoption.py +++ b/setuptools/tests/test_distutils_adoption.py @@ -14,6 +14,11 @@ IS_PYPY = '__pypy__' in sys.builtin_module_names class VirtualEnv(jaraco.envs.VirtualEnv): name = '.env' + # Some version of PyPy will import distutils on startup, implicitly + # importing setuptools, and thus leading to BackendInvalid errors + # when upgrading Setuptools. Bypass this behavior by avoiding the + # early availability and need to upgrade. + create_opts = ['--no-setuptools'] def run(self, cmd, *args, **kwargs): cmd = [self.exe(cmd[0])] + cmd[1:] diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index e6d8e90..66f46ad 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -11,6 +11,7 @@ from unittest import mock import pytest import pkg_resources +from setuptools import SetuptoolsDeprecationWarning from setuptools.command.sdist import sdist from setuptools.command.egg_info import manifest_maker from setuptools.dist import Distribution @@ -148,8 +149,7 @@ class TestSdistTest: self.assert_package_data_in_manifest(cmd) - @mock.patch('setuptools.command.egg_info.log') - def test_custom_build_py(self, log_stub): + def test_custom_build_py(self): """ Ensure projects defining custom build_py don't break when creating sdists (issue #2849) @@ -180,25 +180,13 @@ class TestSdistTest: cmd.distribution.cmdclass = {'build_py': CustomBuildPy} assert cmd.distribution.get_command_class('build_py') == CustomBuildPy - with quiet(): + msg = "setuptools instead of distutils" + with quiet(), pytest.warns(SetuptoolsDeprecationWarning, match=msg): cmd.run() using_custom_command_guard.assert_called() self.assert_package_data_in_manifest(cmd) - warn_stub = log_stub.warn - warn_stub.assert_called() - for call in warn_stub.call_args_list: - args, _kw = call - if "setuptools instead of distutils" in args[0]: - return - else: - raise AssertionError( - "The user should have been warned to extend setuptools command" - " classes instead of distutils", - warn_stub.call_args_list - ) - def test_setup_py_exists(self): dist = Distribution(SETUP_ATTRS) dist.script_name = 'foo.py' diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py index 2abedfc..00f5f18 100644 --- a/setuptools/tests/test_virtualenv.py +++ b/setuptools/tests/test_virtualenv.py @@ -76,9 +76,14 @@ def _get_pip_versions(): return param if network else mark(param, pytest.mark.skip(reason="no network")) network_versions = [ - mark('pip==19.3.1', pytest.mark.xfail(reason='pypa/pip#6599')), - 'pip==20.0.2', - 'https://github.com/pypa/pip/archive/main.zip', + mark('pip<20', pytest.mark.xfail(reason='pypa/pip#6599')), + 'pip<20.1', + 'pip<21', + 'pip<22', + mark( + 'https://github.com/pypa/pip/archive/main.zip', + pytest.mark.skipif('sys.version_info < (3, 7)'), + ), ] versions = itertools.chain( @@ -89,6 +94,10 @@ def _get_pip_versions(): return list(versions) +@pytest.mark.skipif( + 'platform.python_implementation() == "PyPy"', + reason="https://github.com/pypa/setuptools/pull/2865#issuecomment-965834995", +) @pytest.mark.parametrize('pip_version', _get_pip_versions()) def test_pip_upgrade_from_source(pip_version, tmp_src, virtualenv): """ @@ -99,7 +108,7 @@ def test_pip_upgrade_from_source(pip_version, tmp_src, virtualenv): if pip_version is None: upgrade_pip = () else: - upgrade_pip = ('python -m pip install -U {pip_version} --retries=1',) + upgrade_pip = ('python -m pip install -U "{pip_version}" --retries=1',) virtualenv.run(' && '.join(( 'pip uninstall -y setuptools', 'pip install -U wheel', diff --git a/tox.ini b/tox.ini index 8a48a1c..ab99360 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ commands = usedevelop = True extras = testing passenv = + SETUPTOOLS_USE_DISTUTILS windir # required for test_pkg_resources [testenv:docs]