From a65c4326c788cd9f6a81eb1754029751500f7721 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 16 Nov 2021 13:05:23 +0200 Subject: Update setuptools.readthedocs.io to setuptools.pypa.io --- setuptools/command/easy_install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 1aed0e87..fc848d0d 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -6,7 +6,7 @@ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. -__ https://setuptools.readthedocs.io/en/latest/deprecated/easy_install.html +__ https://setuptools.pypa.io/en/latest/deprecated/easy_install.html """ @@ -519,7 +519,7 @@ class easy_install(Command): For information on other options, you may wish to consult the documentation at: - https://setuptools.readthedocs.io/en/latest/deprecated/easy_install.html + https://setuptools.pypa.io/en/latest/deprecated/easy_install.html Please make the appropriate changes for your system and try again. """).lstrip() # noqa @@ -1312,7 +1312,7 @@ class easy_install(Command): * You can set up the installation directory to support ".pth" files by using one of the approaches described here: - https://setuptools.readthedocs.io/en/latest/deprecated/easy_install.html#custom-installation-locations + https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again. -- cgit v1.2.1 From 76c9ab9efc3f13e5ef8681614bebbe437bf51012 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 20 Dec 2021 11:50:50 -0500 Subject: In easy_install, re-use scheme selection from distutils if available. --- setuptools/command/easy_install.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index fc848d0d..00b59904 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -17,10 +17,10 @@ from distutils.errors import ( DistutilsArgError, DistutilsOptionError, DistutilsError, DistutilsPlatformError, ) -from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS from distutils import log, dir_util from distutils.command.build_scripts import first_line_re from distutils.spawn import find_executable +from distutils.command import install import sys import os import zipimport @@ -251,6 +251,9 @@ class easy_install(Command): 'exec_prefix': exec_prefix, # Only python 3.2+ has abiflags 'abiflags': getattr(sys, 'abiflags', ''), + 'platlibdir': getattr(sys, 'platlibdir', 'lib'), + 'implementation_lower': install._get_implementation().lower(), + 'implementation': install._get_implementation(), } if site.ENABLE_USER_SITE: @@ -711,13 +714,7 @@ class easy_install(Command): return dist def select_scheme(self, name): - """Sets the install directories by applying the install schemes.""" - # it's the caller's problem if they supply a bad name! - scheme = INSTALL_SCHEMES[name] - for key in SCHEME_KEYS: - attrname = 'install_' + key - if getattr(self, attrname) is None: - setattr(self, attrname, scheme[key]) + install._select_scheme(self, name) # FIXME: 'easy_install.process_distribution' is too complex (12) def process_distribution( # noqa: C901 -- cgit v1.2.1 From 60b78468341d52bc033f0ad77e890a656ccb9a72 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 20 Dec 2021 12:01:37 -0500 Subject: Add fallback support for distutils in stdlib. --- setuptools/command/easy_install.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 00b59904..e8150057 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -252,9 +252,13 @@ class easy_install(Command): # Only python 3.2+ has abiflags 'abiflags': getattr(sys, 'abiflags', ''), 'platlibdir': getattr(sys, 'platlibdir', 'lib'), - 'implementation_lower': install._get_implementation().lower(), - 'implementation': install._get_implementation(), } + with contextlib.suppress(AttributeError): + # only for distutils outside stdlib + self.config_vars.update({ + 'implementation_lower': install._get_implementation().lower(), + 'implementation': install._get_implementation(), + }) if site.ENABLE_USER_SITE: self.config_vars['userbase'] = self.install_userbase @@ -714,7 +718,11 @@ class easy_install(Command): return dist def select_scheme(self, name): - install._select_scheme(self, name) + try: + install._select_scheme(self, name) + except AttributeError: + # stdlib distutils + install.install.select_scheme(self, name) # FIXME: 'easy_install.process_distribution' is too complex (12) def process_distribution( # noqa: C901 -- cgit v1.2.1 From edf116b1cc4a72075b9af06748df3b177d55d4dc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 20 Dec 2021 16:43:07 -0500 Subject: Select 'posix_user' for the scheme unless falling back to stdlib, then use 'unix_user'. Fixes #2938. --- setuptools/command/easy_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index e8150057..fb34d10e 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -378,7 +378,7 @@ class easy_install(Command): msg = "User base directory is not specified" raise DistutilsPlatformError(msg) self.install_base = self.install_platbase = self.install_userbase - scheme_name = os.name.replace('posix', 'unix') + '_user' + scheme_name = f'{os.name}_user' self.select_scheme(scheme_name) def _expand_attrs(self, attrs): @@ -722,7 +722,7 @@ class easy_install(Command): install._select_scheme(self, name) except AttributeError: # stdlib distutils - install.install.select_scheme(self, name) + install.install.select_scheme(self, name.replace('posix', 'unix')) # FIXME: 'easy_install.process_distribution' is too complex (12) def process_distribution( # noqa: C901 -- cgit v1.2.1 From b028d4636e6a9cb1737758f42f321340bf5abc25 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 3 Jan 2022 12:44:56 -0500 Subject: Use 'dict()' instead of '.copy()', for compatibility with DictStack. --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index fb34d10e..aad5794a 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1350,7 +1350,7 @@ class easy_install(Command): if self.prefix: # Set default install_dir/scripts from --prefix - config_vars = config_vars.copy() + config_vars = dict(config_vars) config_vars['base'] = self.prefix scheme = self.INSTALL_SCHEMES.get(os.name, self.DEFAULT_SCHEME) for attr, val in scheme.items(): -- cgit v1.2.1 From a257f0cb1f960e1d37933c5009da39a49a4622bc Mon Sep 17 00:00:00 2001 From: liuzhe Date: Wed, 22 Dec 2021 13:48:04 +0800 Subject: fix version parsing --- setuptools/command/easy_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index aad5794a..a2962a7d 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -243,8 +243,8 @@ class easy_install(Command): 'dist_version': self.distribution.get_version(), 'dist_fullname': self.distribution.get_fullname(), 'py_version': py_version, - 'py_version_short': py_version[0:3], - 'py_version_nodot': py_version[0] + py_version[2], + 'py_version_short': f'{sys.version_info.major}.{sys.version_info.minor}', + 'py_version_nodot': f'{sys.version_info.major}{sys.version_info.minor}', 'sys_prefix': prefix, 'prefix': prefix, 'sys_exec_prefix': exec_prefix, -- cgit v1.2.1 From b789d313eeb514e9ba469e10f81a333a8f7acc47 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 12 Jan 2022 09:51:18 -0500 Subject: Honor sysconfig variables in easy_install. Fixes #3026. --- setuptools/command/easy_install.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index a2962a7d..514719de 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -39,9 +39,10 @@ import subprocess import shlex import io import configparser +import sysconfig -from sysconfig import get_config_vars, get_path +from sysconfig import get_path from setuptools import SetuptoolsDeprecationWarning @@ -236,23 +237,22 @@ class easy_install(Command): self.version and self._render_version() py_version = sys.version.split()[0] - prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') - self.config_vars = { + self.config_vars = dict(sysconfig.get_config_vars()) + + self.config_vars.update({ 'dist_name': self.distribution.get_name(), 'dist_version': self.distribution.get_version(), 'dist_fullname': self.distribution.get_fullname(), 'py_version': py_version, 'py_version_short': f'{sys.version_info.major}.{sys.version_info.minor}', 'py_version_nodot': f'{sys.version_info.major}{sys.version_info.minor}', - 'sys_prefix': prefix, - 'prefix': prefix, - 'sys_exec_prefix': exec_prefix, - 'exec_prefix': exec_prefix, + 'sys_prefix': self.config_vars['prefix'], + 'sys_exec_prefix': self.config_vars['exec_prefix'], # Only python 3.2+ has abiflags 'abiflags': getattr(sys, 'abiflags', ''), 'platlibdir': getattr(sys, 'platlibdir', 'lib'), - } + }) with contextlib.suppress(AttributeError): # only for distutils outside stdlib self.config_vars.update({ -- cgit v1.2.1 From a7c6d64f76091d1cfd8297ba813fe4e901d00ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Wed, 26 Jan 2022 16:58:29 +0800 Subject: Use super() --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 514719de..5fab0fdb 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1577,7 +1577,7 @@ class PthDistributions(Environment): self.sitedirs = list(map(normalize_path, sitedirs)) self.basedir = normalize_path(os.path.dirname(self.filename)) self._load() - Environment.__init__(self, [], None, None) + super().__init__([], None, None) for path in yield_lines(self.paths): list(map(self.add, find_distributions(path, True))) -- cgit v1.2.1 From 44649c5a483a9c1cf2d80f6e9706d581cfc7437e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 30 Jan 2022 15:25:09 -0500 Subject: Add py_version_nodot_plat substitution support to easy_install. --- setuptools/command/easy_install.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 5fab0fdb..e25090b8 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -260,6 +260,12 @@ class easy_install(Command): 'implementation': install._get_implementation(), }) + # pypa/distutils#113 Python 3.9 compat + self.config_vars.setdefault( + 'py_version_nodot_plat', + getattr(sys, 'windir', '').replace('.', ''), + ) + if site.ENABLE_USER_SITE: self.config_vars['userbase'] = self.install_userbase self.config_vars['usersite'] = self.install_usersite -- cgit v1.2.1 From ee8ed624ac46a7769fa16179ecca9b6aca8c02a6 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 1 Feb 2022 17:30:53 +0000 Subject: Skip non-string values from sysconfig.get_config_vars() --- setuptools/command/easy_install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index e25090b8..bdacbbfc 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1334,7 +1334,9 @@ class easy_install(Command): if not self.user: return home = convert_path(os.path.expanduser("~")) - for name, path in self.config_vars.items(): + for path in self.config_vars.values(): + if not isinstance(path, str): + continue if path.startswith(home) and not os.path.isdir(path): self.debug_print("os.makedirs('%s', 0o700)" % path) os.makedirs(path, 0o700) -- cgit v1.2.1 From a3bc3d44fb0ad669d75e674218078752de7bb24d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 1 Feb 2022 20:13:22 -0500 Subject: Create a function for only_strs to help document its purpose. --- setuptools/command/easy_install.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index bdacbbfc..ef1a9b23 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1334,9 +1334,7 @@ class easy_install(Command): if not self.user: return home = convert_path(os.path.expanduser("~")) - for path in self.config_vars.values(): - if not isinstance(path, str): - continue + for path in only_strs(self.config_vars.values()): if path.startswith(home) and not os.path.isdir(path): self.debug_print("os.makedirs('%s', 0o700)" % path) os.makedirs(path, 0o700) @@ -2306,6 +2304,13 @@ def current_umask(): return tmp +def only_strs(values): + """ + Exclude non-str values. Ref #3063. + """ + return filter(lambda val: isinstance(val, str), values) + + class EasyInstallDeprecationWarning(SetuptoolsDeprecationWarning): """ Warning for EasyInstall deprecations, bypassing suppression. -- cgit v1.2.1 From 4cbbb99a953ac5b1fec3b1dfdd106a7781f4293d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 3 Dec 2021 22:17:12 -0500 Subject: Move ensure_directory into setuptools. --- setuptools/command/bdist_egg.py | 3 ++- setuptools/command/easy_install.py | 3 ++- setuptools/command/install_egg_info.py | 3 ++- setuptools/command/install_scripts.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index e6b1609f..11a1c6be 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -11,9 +11,10 @@ import re import textwrap import marshal -from pkg_resources import get_build_platform, Distribution, ensure_directory +from pkg_resources import get_build_platform, Distribution from setuptools.extension import Library from setuptools import Command +from .._path import ensure_directory from sysconfig import get_path, get_python_version diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index ef1a9b23..b1260dcd 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -56,12 +56,13 @@ from setuptools.package_index import ( from setuptools.command import bdist_egg, egg_info from setuptools.wheel import Wheel from pkg_resources import ( - yield_lines, normalize_path, resource_string, ensure_directory, + yield_lines, normalize_path, resource_string, get_distribution, find_distributions, Environment, Requirement, Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound, VersionConflict, DEVELOP_DIST, ) import pkg_resources +from .._path import ensure_directory # Turn on PEP440Warnings warnings.filterwarnings("default", category=pkg_resources.PEP440Warning) diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index edc4718b..65ede406 100644 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -4,6 +4,7 @@ import os from setuptools import Command from setuptools import namespaces from setuptools.archive_util import unpack_archive +from .._path import ensure_directory import pkg_resources @@ -37,7 +38,7 @@ class install_egg_info(namespaces.Installer, Command): elif os.path.exists(self.target): self.execute(os.unlink, (self.target,), "Removing " + self.target) if not self.dry_run: - pkg_resources.ensure_directory(self.target) + ensure_directory(self.target) self.execute( self.copytree, (), "Copying %s to %s" % (self.source, self.target) ) diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 9cd8eb06..aeb0e424 100644 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -4,7 +4,8 @@ from distutils.errors import DistutilsModuleError import os import sys -from pkg_resources import Distribution, PathMetadata, ensure_directory +from pkg_resources import Distribution, PathMetadata +from .._path import ensure_directory class install_scripts(orig.install_scripts): -- cgit v1.2.1 From 157e36ed63408713f56e16f25c5f813e82bb7442 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 5 Feb 2022 09:55:05 -0500 Subject: Replace use of parse_requirements with simple constructor. --- setuptools/command/egg_info.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index f2210292..379f9398 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -23,7 +23,7 @@ from setuptools.command.sdist import walk_revctrl from setuptools.command.setopt import edit_config from setuptools.command import bdist_egg from pkg_resources import ( - parse_requirements, safe_name, parse_version, + Requirement, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) import setuptools.unicode_utils as unicode_utils from setuptools.glob import glob @@ -205,12 +205,8 @@ class egg_info(InfoCommon, Command): try: is_version = isinstance(parsed_version, packaging.version.Version) - spec = ( - "%s==%s" if is_version else "%s===%s" - ) - list( - parse_requirements(spec % (self.egg_name, self.egg_version)) - ) + spec = "%s==%s" if is_version else "%s===%s" + Requirement(spec % (self.egg_name, self.egg_version)) except ValueError as e: raise distutils.errors.DistutilsOptionError( "Invalid distribution name or version syntax: %s-%s" % -- cgit v1.2.1