From: DongHun Kwak Date: Tue, 29 Dec 2020 22:07:04 +0000 (+0900) Subject: Imported Upstream version 49.1.1 X-Git-Tag: upstream/49.1.1^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c6d2ee74e364f8fdf91d1a74215552b8aa0372c;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 49.1.1 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f2f2b27..55f806f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 49.1.0 +current_version = 49.1.1 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index 26586fb..d5a2a70 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,15 @@ +v49.1.1 +------- + +* #2094: Removed pkg_resources.py2_warn module, which is no longer reachable. + + +v49.0.1 +------- + +* #2228: Applied fix for pypa/distutils#3, restoring expectation that spawn will raise a DistutilsExecError when attempting to execute a missing file. + + v49.1.0 ------- @@ -16,7 +28,8 @@ v49.0.0 v48.0.0 ------- -* #2143: Setuptools adopts distutils from the Python 3.9 standard library and no longer depends on distutils in the standard library. When importing ``setuptools`` or ``setuptools.distutils_patch``, Setuptools will expose its bundled version as a top-level ``distutils`` package (and unload any previously-imported top-level distutils package), retaining the expectation that ``distutils``' objects are actually Setuptools objects. Although this change is not expected to break any use cases, it will likely affect tool chains that are monkey-patching distutils or relying on Setuptools' own monkey-patching of distutils. +* #2143: Setuptools adopts distutils from the Python 3.9 standard library and no longer depends on distutils in the standard library. When importing ``setuptools`` or ``setuptools.distutils_patch``, Setuptools will expose its bundled version as a top-level ``distutils`` package (and unload any previously-imported top-level distutils package), retaining the expectation that ``distutils``' objects are actually Setuptools objects. + To avoid getting any legacy behavior from the standard library, projects are advised to always "import setuptools" prior to importing anything from distutils. This behavior happens by default when using ``pip install`` or ``pep517.build``. Workflows that rely on ``setup.py (anything)`` will need to first ensure setuptools is imported. One way to achieve this behavior without modifying code is to invoke Python thus: ``python -c "import setuptools; exec(open('setup.py').read())" (anything)``. v47.3.2 diff --git a/README.rst b/README.rst index 9cbf7b8..dc2bf98 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,6 @@ +.. image:: https://raw.githubusercontent.com/pypa/setuptools/master/docs/logo/banner%201%20line%20color.svg + + .. image:: https://img.shields.io/pypi/v/setuptools.svg :target: `PyPI link`_ @@ -24,6 +27,7 @@ .. 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 + See the `Installation Instructions `_ in the Python Packaging User's Guide for instructions on installing, upgrading, and uninstalling diff --git a/docs/index.txt b/docs/index.txt index 13a46e7..228f97c 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -1,15 +1,11 @@ -Welcome to Setuptools' documentation! -===================================== +.. image:: https://raw.githubusercontent.com/pypa/setuptools/master/docs/logo/banner%201%20line%20color.svg -Setuptools is a fully-featured, actively-maintained, and stable library -designed to facilitate packaging Python projects, where packaging includes: - - Python package and module definitions - - Distribution package metadata - - Test hooks - - Project installation - - Platform-specific details - - Python 3 support +Documentation +============= + +Setuptools is a fully-featured, actively-maintained, and stable library +designed to facilitate packaging Python projects. Documentation content: diff --git a/docs/logo/README.md b/docs/logo/README.md new file mode 100644 index 0000000..74fadbf --- /dev/null +++ b/docs/logo/README.md @@ -0,0 +1,10 @@ +![](setup_tools_logo_colour.svg) +### Design: + +Setuptools logo designed in 2020 by [C.Rogers](crogersmedia.com) for the Setuptools project using the Free Open Source graphics editor [Inkscape](inkscape.org). + +### Copyright: +Logo is (c) the Setuptools developers. + +### Font: +The font used is the Open Font "Josefin Sans", which is available for free under the Open Font License (OFL). diff --git a/docs/logo/banner 1 line color.png b/docs/logo/banner 1 line color.png new file mode 100644 index 0000000..d160428 Binary files /dev/null and b/docs/logo/banner 1 line color.png differ diff --git a/docs/logo/banner 1 line color.svg b/docs/logo/banner 1 line color.svg new file mode 100644 index 0000000..d6dc9aa --- /dev/null +++ b/docs/logo/banner 1 line color.svg @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/docs/logo/banner 2 lines color.png b/docs/logo/banner 2 lines color.png new file mode 100644 index 0000000..89370a9 Binary files /dev/null and b/docs/logo/banner 2 lines color.png differ diff --git a/docs/logo/banner 2 lines color.svg b/docs/logo/banner 2 lines color.svg new file mode 100644 index 0000000..991577f --- /dev/null +++ b/docs/logo/banner 2 lines color.svg @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/docs/logo/full color 1000px.png b/docs/logo/full color 1000px.png new file mode 100644 index 0000000..c25a23b Binary files /dev/null and b/docs/logo/full color 1000px.png differ diff --git a/docs/logo/full color.svg b/docs/logo/full color.svg new file mode 100644 index 0000000..7eae8fc --- /dev/null +++ b/docs/logo/full color.svg @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/docs/logo/josefinsans/.uuid b/docs/logo/josefinsans/.uuid new file mode 100644 index 0000000..d7e92c7 --- /dev/null +++ b/docs/logo/josefinsans/.uuid @@ -0,0 +1 @@ +922c129c-9f4c-4831-b632-c7f43be6feb0 \ No newline at end of file diff --git a/docs/logo/josefinsans/DESCRIPTION.en_us.html b/docs/logo/josefinsans/DESCRIPTION.en_us.html new file mode 100644 index 0000000..9364b24 --- /dev/null +++ b/docs/logo/josefinsans/DESCRIPTION.en_us.html @@ -0,0 +1,9 @@ +

+The idea of this typeface is to be geometric, elegant, with a vintage feeling, for use at larger sizes. +It is inspired by geometric sans serif designs from the 1920s. +The x-height is half way from baseline to cap height, an unusual proportion. +

+

+There is a sister family, Josefin Slab +

+ diff --git a/docs/logo/josefinsans/JosefinSans-Bold.ttf b/docs/logo/josefinsans/JosefinSans-Bold.ttf new file mode 100644 index 0000000..12a7ad0 Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-Bold.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-BoldItalic.ttf b/docs/logo/josefinsans/JosefinSans-BoldItalic.ttf new file mode 100644 index 0000000..4a0fc91 Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-BoldItalic.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-Italic.ttf b/docs/logo/josefinsans/JosefinSans-Italic.ttf new file mode 100644 index 0000000..1cbe036 Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-Italic.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-Light.ttf b/docs/logo/josefinsans/JosefinSans-Light.ttf new file mode 100644 index 0000000..7fe3f7b Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-Light.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-LightItalic.ttf b/docs/logo/josefinsans/JosefinSans-LightItalic.ttf new file mode 100644 index 0000000..8dc3538 Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-LightItalic.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-Regular.ttf b/docs/logo/josefinsans/JosefinSans-Regular.ttf new file mode 100644 index 0000000..ed11900 Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-Regular.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-SemiBold.ttf b/docs/logo/josefinsans/JosefinSans-SemiBold.ttf new file mode 100644 index 0000000..b67504a Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-SemiBold.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-SemiBoldItalic.ttf b/docs/logo/josefinsans/JosefinSans-SemiBoldItalic.ttf new file mode 100644 index 0000000..24a27d1 Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-SemiBoldItalic.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-Thin.ttf b/docs/logo/josefinsans/JosefinSans-Thin.ttf new file mode 100644 index 0000000..c54ca7f Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-Thin.ttf differ diff --git a/docs/logo/josefinsans/JosefinSans-ThinItalic.ttf b/docs/logo/josefinsans/JosefinSans-ThinItalic.ttf new file mode 100644 index 0000000..6840b7c Binary files /dev/null and b/docs/logo/josefinsans/JosefinSans-ThinItalic.ttf differ diff --git a/docs/logo/josefinsans/METADATA.pb b/docs/logo/josefinsans/METADATA.pb new file mode 100644 index 0000000..8b67716 --- /dev/null +++ b/docs/logo/josefinsans/METADATA.pb @@ -0,0 +1,99 @@ +name: "Josefin Sans" +designer: "Santiago Orozco" +license: "OFL" +category: "SANS_SERIF" +date_added: "2010-11-17" +fonts { + name: "Josefin Sans" + style: "normal" + weight: 100 + filename: "JosefinSans-Thin.ttf" + post_script_name: "JosefinSans-Thin" + full_name: "Josefin Sans Thin" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "italic" + weight: 100 + filename: "JosefinSans-ThinItalic.ttf" + post_script_name: "JosefinSans-ThinItalic" + full_name: "Josefin Sans Thin Italic" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "normal" + weight: 300 + filename: "JosefinSans-Light.ttf" + post_script_name: "JosefinSans-Light" + full_name: "Josefin Sans Light" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "italic" + weight: 300 + filename: "JosefinSans-LightItalic.ttf" + post_script_name: "JosefinSans-LightItalic" + full_name: "Josefin Sans Light Italic" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "normal" + weight: 400 + filename: "JosefinSans-Regular.ttf" + post_script_name: "JosefinSans-Regular" + full_name: "Josefin Sans Regular" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "italic" + weight: 400 + filename: "JosefinSans-Italic.ttf" + post_script_name: "JosefinSans-Italic" + full_name: "Josefin Sans Italic" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "normal" + weight: 600 + filename: "JosefinSans-SemiBold.ttf" + post_script_name: "JosefinSans-SemiBold" + full_name: "Josefin Sans SemiBold" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "italic" + weight: 600 + filename: "JosefinSans-SemiBoldItalic.ttf" + post_script_name: "JosefinSans-SemiBoldItalic" + full_name: "Josefin Sans SemiBold Italic" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "normal" + weight: 700 + filename: "JosefinSans-Bold.ttf" + post_script_name: "JosefinSans-Bold" + full_name: "Josefin Sans Bold" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +fonts { + name: "Josefin Sans" + style: "italic" + weight: 700 + filename: "JosefinSans-BoldItalic.ttf" + post_script_name: "JosefinSans-BoldItalic" + full_name: "Josefin Sans Bold Italic" + copyright: "Copyright 2010 The Josefin Sans Project Authors (https://github.com/ThomasJockin/JosefinSansFont-master), with Reserved Font Name \"Josefin Sans\"." +} +subsets: "latin" +subsets: "latin-ext" +subsets: "menu" +subsets: "vietnamese" diff --git a/docs/logo/josefinsans/OFL.txt b/docs/logo/josefinsans/OFL.txt new file mode 100644 index 0000000..6586a7e --- /dev/null +++ b/docs/logo/josefinsans/OFL.txt @@ -0,0 +1,93 @@ +Copyright (c) 2010, Santiago Orozco (hi@typemade.mx) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/logo/symbol color 1000px.png b/docs/logo/symbol color 1000px.png new file mode 100644 index 0000000..e0c36fc Binary files /dev/null and b/docs/logo/symbol color 1000px.png differ diff --git a/docs/logo/symbol color.svg b/docs/logo/symbol color.svg new file mode 100644 index 0000000..2936cbb --- /dev/null +++ b/docs/logo/symbol color.svg @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/docs/logo/type.svg b/docs/logo/type.svg new file mode 100644 index 0000000..dbb9c1d --- /dev/null +++ b/docs/logo/type.svg @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index b953490..5927ef0 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -82,7 +82,6 @@ __import__('pkg_resources.extern.packaging.version') __import__('pkg_resources.extern.packaging.specifiers') __import__('pkg_resources.extern.packaging.requirements') __import__('pkg_resources.extern.packaging.markers') -__import__('pkg_resources.py2_warn') __metaclass__ = type diff --git a/pkg_resources/py2_warn.py b/pkg_resources/py2_warn.py deleted file mode 100644 index 6855aa2..0000000 --- a/pkg_resources/py2_warn.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -import warnings -import textwrap - - -msg = textwrap.dedent(""" - Encountered a version of Setuptools that no longer supports - this version of Python. Please head to - https://bit.ly/setuptools-py2-sunset for support. - """) - -pre = "Setuptools no longer works on Python 2\n" - -if sys.version_info < (3,): - warnings.warn(pre + "*" * 60 + msg + "*" * 60) - raise SystemExit(32) diff --git a/setup.cfg b/setup.cfg index 1f347c3..3151fa4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ formats = zip [metadata] name = setuptools -version = 49.1.0 +version = 49.1.1 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/command/build_py.py b/setuptools/_distutils/command/build_py.py index cf0ca57..edc2171 100644 --- a/setuptools/_distutils/command/build_py.py +++ b/setuptools/_distutils/command/build_py.py @@ -5,7 +5,7 @@ Implements the Distutils 'build_py' command.""" import os import importlib.util import sys -from glob import glob +import glob from distutils.core import Command from distutils.errors import * @@ -125,7 +125,7 @@ class build_py (Command): files = [] for pattern in globs: # Each pattern has to be converted to a platform-specific path - filelist = glob(os.path.join(src_dir, convert_path(pattern))) + filelist = glob.glob(os.path.join(glob.escape(src_dir), convert_path(pattern))) # Files that match more than one pattern are only added once files.extend([fn for fn in filelist if fn not in files and os.path.isfile(fn)]) @@ -216,7 +216,7 @@ class build_py (Command): def find_package_modules(self, package, package_dir): self.check_package(package, package_dir) - module_files = glob(os.path.join(package_dir, "*.py")) + module_files = glob.glob(os.path.join(glob.escape(package_dir), "*.py")) modules = [] setup_script = os.path.abspath(self.distribution.script_name) diff --git a/setuptools/_distutils/spawn.py b/setuptools/_distutils/spawn.py index aad277b..0d1bd03 100644 --- a/setuptools/_distutils/spawn.py +++ b/setuptools/_distutils/spawn.py @@ -71,9 +71,15 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0): env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) - proc = subprocess.Popen(cmd, env=env) - proc.wait() - exitcode = proc.returncode + try: + proc = subprocess.Popen(cmd, env=env) + proc.wait() + exitcode = proc.returncode + except OSError as exc: + if not DEBUG: + cmd = cmd[0] + raise DistutilsExecError( + "command %r failed: %s" % (cmd, exc.args[-1])) from exc if exitcode: if not DEBUG: diff --git a/setuptools/_distutils/tests/__init__.py b/setuptools/_distutils/tests/__init__.py index 5d2e69e..c7dcc7e 100644 --- a/setuptools/_distutils/tests/__init__.py +++ b/setuptools/_distutils/tests/__init__.py @@ -15,26 +15,26 @@ by import rather than matching pre-defined names. import os import sys import unittest -import warnings from test.support import run_unittest +from .py38compat import save_restore_warnings_filters + here = os.path.dirname(__file__) or os.curdir def test_suite(): - old_filters = warnings.filters[:] suite = unittest.TestSuite() for fn in os.listdir(here): if fn.startswith("test") and fn.endswith(".py"): modname = "distutils.tests." + fn[:-3] - __import__(modname) + # bpo-40055: Save/restore warnings filters to leave them unchanged. + # Importing tests imports docutils which imports pkg_resources + # which adds a warnings filter. + with save_restore_warnings_filters(): + __import__(modname) module = sys.modules[modname] suite.addTest(module.test_suite()) - # bpo-40055: Save/restore warnings filters to leave them unchanged. - # Importing tests imports docutils which imports pkg_resources which adds a - # warnings filter. - warnings.filters[:] = old_filters return suite diff --git a/setuptools/_distutils/tests/py38compat.py b/setuptools/_distutils/tests/py38compat.py new file mode 100644 index 0000000..46ff575 --- /dev/null +++ b/setuptools/_distutils/tests/py38compat.py @@ -0,0 +1,50 @@ +# flake8: noqa + +import contextlib + +try: + from test.support.warnings_helper import check_warnings +except (ModuleNotFoundError, ImportError): + from test.support import check_warnings + + +try: + from test.support.os_helper import ( + change_cwd, + rmtree, + EnvironmentVarGuard, + TESTFN, + unlink, + skip_unless_symlink, + temp_dir, + create_empty_file, + temp_cwd, + ) +except (ModuleNotFoundError, ImportError): + from test.support import ( + change_cwd, + rmtree, + EnvironmentVarGuard, + TESTFN, + unlink, + skip_unless_symlink, + temp_dir, + create_empty_file, + temp_cwd, + ) + + +# From Python 3.9 +@contextlib.contextmanager +def _save_restore_warnings_filters(): + old_filters = warnings.filters[:] + try: + yield + finally: + warnings.filters[:] = old_filters + + +try: + from test.support.warnings_helper import save_restore_warnings_filters +except (ModuleNotFoundError, ImportError): + save_restore_warnings_filters = _save_restore_warnings_filters diff --git a/setuptools/_distutils/tests/support.py b/setuptools/_distutils/tests/support.py index 259af88..b4410fc 100644 --- a/setuptools/_distutils/tests/support.py +++ b/setuptools/_distutils/tests/support.py @@ -6,7 +6,8 @@ import tempfile import unittest import sysconfig from copy import deepcopy -import test.support + +from . import py38compat as os_helper from distutils import log from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL @@ -64,7 +65,7 @@ class TempdirManager(object): super().tearDown() while self.tempdirs: tmpdir = self.tempdirs.pop() - test.support.rmtree(tmpdir) + os_helper.rmtree(tmpdir) def mkdtemp(self): """Create a temporary directory that will be cleaned up. diff --git a/setuptools/_distutils/tests/test_archive_util.py b/setuptools/_distutils/tests/test_archive_util.py index e9aad0e..ce6456d 100644 --- a/setuptools/_distutils/tests/test_archive_util.py +++ b/setuptools/_distutils/tests/test_archive_util.py @@ -13,7 +13,10 @@ from distutils.archive_util import (check_archive_formats, make_tarball, ARCHIVE_FORMATS) from distutils.spawn import find_executable, spawn from distutils.tests import support -from test.support import check_warnings, run_unittest, patch, change_cwd +from test.support import run_unittest, patch + +from .py38compat import change_cwd +from .py38compat import check_warnings try: import grp diff --git a/setuptools/_distutils/tests/test_bdist_msi.py b/setuptools/_distutils/tests/test_bdist_msi.py index 418e60e..937266f 100644 --- a/setuptools/_distutils/tests/test_bdist_msi.py +++ b/setuptools/_distutils/tests/test_bdist_msi.py @@ -1,9 +1,11 @@ """Tests for distutils.command.bdist_msi.""" import sys import unittest -from test.support import run_unittest, check_warnings +from test.support import run_unittest from distutils.tests import support +from .py38compat import check_warnings + @unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows') class BDistMSITestCase(support.TempdirManager, diff --git a/setuptools/_distutils/tests/test_bdist_wininst.py b/setuptools/_distutils/tests/test_bdist_wininst.py index 5c3d025..31cf262 100644 --- a/setuptools/_distutils/tests/test_bdist_wininst.py +++ b/setuptools/_distutils/tests/test_bdist_wininst.py @@ -2,7 +2,9 @@ import sys import platform import unittest -from test.support import run_unittest, check_warnings +from test.support import run_unittest + +from .py38compat import check_warnings from distutils.command.bdist_wininst import bdist_wininst from distutils.tests import support diff --git a/setuptools/_distutils/tests/test_build_ext.py b/setuptools/_distutils/tests/test_build_ext.py index 1aec153..5a72458 100644 --- a/setuptools/_distutils/tests/test_build_ext.py +++ b/setuptools/_distutils/tests/test_build_ext.py @@ -15,6 +15,7 @@ from distutils.errors import ( import unittest from test import support +from . import py38compat as os_helper from test.support.script_helper import assert_python_ok # http://bugs.python.org/issue4373 @@ -38,7 +39,7 @@ class BuildExtTestCase(TempdirManager, # bpo-30132: On Windows, a .pdb file may be created in the current # working directory. Create a temporary working directory to cleanup # everything at the end of the test. - change_cwd = support.change_cwd(self.tmp_dir) + change_cwd = os_helper.change_cwd(self.tmp_dir) change_cwd.__enter__() self.addCleanup(change_cwd.__exit__, None, None, None) diff --git a/setuptools/_distutils/tests/test_core.py b/setuptools/_distutils/tests/test_core.py index 27ce732..666ff4a 100644 --- a/setuptools/_distutils/tests/test_core.py +++ b/setuptools/_distutils/tests/test_core.py @@ -5,8 +5,8 @@ import distutils.core import os import shutil import sys -import test.support from test.support import captured_stdout, run_unittest +from . import py38compat as os_helper import unittest from distutils.tests import support from distutils import log @@ -62,13 +62,13 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase): super(CoreTestCase, self).tearDown() def cleanup_testfn(self): - path = test.support.TESTFN + path = os_helper.TESTFN if os.path.isfile(path): os.remove(path) elif os.path.isdir(path): shutil.rmtree(path) - def write_setup(self, text, path=test.support.TESTFN): + def write_setup(self, text, path=os_helper.TESTFN): f = open(path, "w") try: f.write(text) @@ -105,8 +105,8 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase): cwd = os.getcwd() # Create a directory and write the setup.py file there: - os.mkdir(test.support.TESTFN) - setup_py = os.path.join(test.support.TESTFN, "setup.py") + os.mkdir(os_helper.TESTFN) + setup_py = os.path.join(os_helper.TESTFN, "setup.py") distutils.core.run_setup( self.write_setup(setup_prints_cwd, path=setup_py)) diff --git a/setuptools/_distutils/tests/test_dist.py b/setuptools/_distutils/tests/test_dist.py index d431085..45eadee 100644 --- a/setuptools/_distutils/tests/test_dist.py +++ b/setuptools/_distutils/tests/test_dist.py @@ -12,8 +12,9 @@ from distutils.dist import Distribution, fix_help_options from distutils.cmd import Command from test.support import ( - TESTFN, captured_stdout, captured_stderr, run_unittest + captured_stdout, captured_stderr, run_unittest ) +from .py38compat import TESTFN from distutils.tests import support from distutils import log diff --git a/setuptools/_distutils/tests/test_extension.py b/setuptools/_distutils/tests/test_extension.py index e35f273..2eb5b42 100644 --- a/setuptools/_distutils/tests/test_extension.py +++ b/setuptools/_distutils/tests/test_extension.py @@ -3,9 +3,11 @@ import unittest import os import warnings -from test.support import check_warnings, run_unittest +from test.support import run_unittest from distutils.extension import read_setup_file, Extension +from .py38compat import check_warnings + class ExtensionTestCase(unittest.TestCase): def test_read_setup_file(self): diff --git a/setuptools/_distutils/tests/test_file_util.py b/setuptools/_distutils/tests/test_file_util.py index a4e2d02..d253607 100644 --- a/setuptools/_distutils/tests/test_file_util.py +++ b/setuptools/_distutils/tests/test_file_util.py @@ -8,7 +8,9 @@ from distutils.file_util import move_file, copy_file from distutils import log from distutils.tests import support from distutils.errors import DistutilsFileError -from test.support import run_unittest, unlink +from test.support import run_unittest +from .py38compat import unlink + class FileUtilTestCase(support.TempdirManager, unittest.TestCase): diff --git a/setuptools/_distutils/tests/test_filelist.py b/setuptools/_distutils/tests/test_filelist.py index 71fde2b..d8e4b39 100644 --- a/setuptools/_distutils/tests/test_filelist.py +++ b/setuptools/_distutils/tests/test_filelist.py @@ -8,11 +8,11 @@ from distutils.errors import DistutilsTemplateError from distutils.filelist import glob_to_re, translate_pattern, FileList from distutils import filelist -import test.support from test.support import captured_stdout, run_unittest from distutils.tests import support from .py35compat import adapt_glob +from . import py38compat as os_helper MANIFEST_IN = """\ @@ -298,9 +298,9 @@ class FileListTestCase(support.LoggingSilencer, class FindAllTestCase(unittest.TestCase): - @test.support.skip_unless_symlink + @os_helper.skip_unless_symlink def test_missing_symlink(self): - with test.support.temp_cwd(): + with os_helper.temp_cwd(): os.symlink('foo', 'bar') self.assertEqual(filelist.findall(), []) @@ -310,13 +310,13 @@ class FindAllTestCase(unittest.TestCase): '.' as the parameter, the dot should be omitted from the results. """ - with test.support.temp_cwd(): + with os_helper.temp_cwd(): os.mkdir('foo') file1 = os.path.join('foo', 'file1.txt') - test.support.create_empty_file(file1) + os_helper.create_empty_file(file1) os.mkdir('bar') file2 = os.path.join('bar', 'file2.txt') - test.support.create_empty_file(file2) + os_helper.create_empty_file(file2) expected = [file2, file1] self.assertEqual(sorted(filelist.findall()), expected) @@ -325,9 +325,9 @@ class FindAllTestCase(unittest.TestCase): When findall is called with another path, the full path name should be returned. """ - with test.support.temp_dir() as temp_dir: + with os_helper.temp_dir() as temp_dir: file1 = os.path.join(temp_dir, 'file1.txt') - test.support.create_empty_file(file1) + os_helper.create_empty_file(file1) expected = [file1] self.assertEqual(filelist.findall(temp_dir), expected) diff --git a/setuptools/_distutils/tests/test_register.py b/setuptools/_distutils/tests/test_register.py index e68b0af..84607f9 100644 --- a/setuptools/_distutils/tests/test_register.py +++ b/setuptools/_distutils/tests/test_register.py @@ -5,7 +5,9 @@ import getpass import urllib import warnings -from test.support import check_warnings, run_unittest +from test.support import run_unittest + +from .py38compat import check_warnings from distutils.command import register as register_module from distutils.command.register import register diff --git a/setuptools/_distutils/tests/test_sdist.py b/setuptools/_distutils/tests/test_sdist.py index 23db126..b087a81 100644 --- a/setuptools/_distutils/tests/test_sdist.py +++ b/setuptools/_distutils/tests/test_sdist.py @@ -6,7 +6,9 @@ import warnings import zipfile from os.path import join from textwrap import dedent -from test.support import captured_stdout, check_warnings, run_unittest +from test.support import captured_stdout, run_unittest + +from .py38compat import check_warnings try: import zlib diff --git a/setuptools/_distutils/tests/test_spawn.py b/setuptools/_distutils/tests/test_spawn.py index 919d0ad..f620da7 100644 --- a/setuptools/_distutils/tests/test_spawn.py +++ b/setuptools/_distutils/tests/test_spawn.py @@ -4,9 +4,9 @@ import stat import sys import unittest.mock from test.support import run_unittest -from test import support as test_support from .py35compat import unix_shell +from . import py38compat as os_helper from distutils.spawn import find_executable from distutils.spawn import spawn @@ -46,9 +46,9 @@ class SpawnTestCase(support.TempdirManager, spawn([exe]) # should work without any error def test_find_executable(self): - with test_support.temp_dir() as tmp_dir: + with os_helper.temp_dir() as tmp_dir: # use TESTFN to get a pseudo-unique filename - program_noeext = test_support.TESTFN + program_noeext = os_helper.TESTFN # Give the temporary program an ".exe" suffix for all. # It's needed on Windows and not harmful on other platforms. program = program_noeext + ".exe" @@ -68,7 +68,7 @@ class SpawnTestCase(support.TempdirManager, self.assertEqual(rv, filename) # test find in the current directory - with test_support.change_cwd(tmp_dir): + with os_helper.change_cwd(tmp_dir): rv = find_executable(program) self.assertEqual(rv, program) @@ -78,7 +78,7 @@ class SpawnTestCase(support.TempdirManager, self.assertIsNone(rv) # PATH='': no match, except in the current directory - with test_support.EnvironmentVarGuard() as env: + with os_helper.EnvironmentVarGuard() as env: env['PATH'] = '' with unittest.mock.patch('distutils.spawn.os.confstr', return_value=tmp_dir, create=True), \ @@ -88,12 +88,12 @@ class SpawnTestCase(support.TempdirManager, self.assertIsNone(rv) # look in current directory - with test_support.change_cwd(tmp_dir): + with os_helper.change_cwd(tmp_dir): rv = find_executable(program) self.assertEqual(rv, program) # PATH=':': explicitly looks in the current directory - with test_support.EnvironmentVarGuard() as env: + with os_helper.EnvironmentVarGuard() as env: env['PATH'] = os.pathsep with unittest.mock.patch('distutils.spawn.os.confstr', return_value='', create=True), \ @@ -102,12 +102,12 @@ class SpawnTestCase(support.TempdirManager, self.assertIsNone(rv) # look in current directory - with test_support.change_cwd(tmp_dir): + with os_helper.change_cwd(tmp_dir): rv = find_executable(program) self.assertEqual(rv, program) # missing PATH: test os.confstr("CS_PATH") and os.defpath - with test_support.EnvironmentVarGuard() as env: + with os_helper.EnvironmentVarGuard() as env: env.pop('PATH', None) # without confstr @@ -126,6 +126,11 @@ class SpawnTestCase(support.TempdirManager, rv = find_executable(program) self.assertEqual(rv, filename) + def test_spawn_missing_exe(self): + with self.assertRaises(DistutilsExecError) as ctx: + spawn(['does-not-exist']) + self.assertIn("command 'does-not-exist' failed", str(ctx.exception)) + def test_suite(): return unittest.makeSuite(SpawnTestCase) diff --git a/setuptools/_distutils/tests/test_sysconfig.py b/setuptools/_distutils/tests/test_sysconfig.py index d507639..c757194 100644 --- a/setuptools/_distutils/tests/test_sysconfig.py +++ b/setuptools/_distutils/tests/test_sysconfig.py @@ -10,7 +10,11 @@ import unittest from distutils import sysconfig from distutils.ccompiler import get_default_compiler from distutils.tests import support -from test.support import TESTFN, run_unittest, check_warnings, swap_item +from test.support import run_unittest, swap_item + +from .py38compat import TESTFN +from .py38compat import check_warnings + class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): diff --git a/setuptools/_distutils/tests/test_unixccompiler.py b/setuptools/_distutils/tests/test_unixccompiler.py index f215966..1828ba1 100644 --- a/setuptools/_distutils/tests/test_unixccompiler.py +++ b/setuptools/_distutils/tests/test_unixccompiler.py @@ -1,7 +1,9 @@ """Tests for distutils.unixccompiler.""" import sys import unittest -from test.support import EnvironmentVarGuard, run_unittest +from test.support import run_unittest + +from .py38compat import EnvironmentVarGuard from distutils import sysconfig from distutils.unixccompiler import UnixCCompiler