diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2021-01-19 20:37:26 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2021-01-19 20:40:04 -0500 |
commit | 183a306ef87fd15df27dc4327182a944033ea3a0 (patch) | |
tree | 5774e85956c06f7d82860483ae8de0a17d28e4a5 | |
parent | 8222d6f7b992d3b184434acb31cd66b0f2e41401 (diff) | |
download | python-setuptools-git-183a306ef87fd15df27dc4327182a944033ea3a0.tar.gz |
Remove bootstrap and tox-pip and instead rely on pep517.
-rw-r--r-- | bootstrap.py | 57 | ||||
-rw-r--r-- | pyproject.toml | 1 | ||||
-rwxr-xr-x | setup.py | 12 | ||||
-rw-r--r-- | tools/tox_pip.py | 70 | ||||
-rw-r--r-- | tox.ini | 6 |
5 files changed, 0 insertions, 146 deletions
diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index 118671f6..00000000 --- a/bootstrap.py +++ /dev/null @@ -1,57 +0,0 @@ -""" -If setuptools is not already installed in the environment, it's not possible -to invoke setuptools' own commands. This routine will bootstrap this local -environment by creating a minimal egg-info directory and then invoking the -egg-info command to flesh out the egg-info directory. -""" - -import os -import sys -import textwrap -import subprocess -import io - - -minimal_egg_info = textwrap.dedent(""" - [distutils.commands] - egg_info = setuptools.command.egg_info:egg_info - - [distutils.setup_keywords] - include_package_data = setuptools.dist:assert_bool - install_requires = setuptools.dist:check_requirements - extras_require = setuptools.dist:check_extras - entry_points = setuptools.dist:check_entry_points - - [egg_info.writers] - PKG-INFO = setuptools.command.egg_info:write_pkg_info - dependency_links.txt = setuptools.command.egg_info:overwrite_arg - entry_points.txt = setuptools.command.egg_info:write_entries - requires.txt = setuptools.command.egg_info:write_requirements - """) - - -def ensure_egg_info(): - if os.path.exists('setuptools.egg-info'): - return - print("adding minimal entry_points") - add_minimal_info() - run_egg_info() - - -def add_minimal_info(): - """ - Build a minimal egg-info, enough to invoke egg_info - """ - - os.mkdir('setuptools.egg-info') - with io.open('setuptools.egg-info/entry_points.txt', 'w') as ep: - ep.write(minimal_egg_info) - - -def run_egg_info(): - cmd = [sys.executable, 'setup.py', 'egg_info'] - print("Regenerating egg_info") - subprocess.check_call(cmd) - - -__name__ == '__main__' and ensure_egg_info() diff --git a/pyproject.toml b/pyproject.toml index 4e80bdc1..414ffed5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [build-system] requires = [ - # avoid self install on Python 2; ref #1996 "setuptools >= 40.8; python_version > '3'", "wheel", ] @@ -10,17 +10,6 @@ from setuptools.command.install import install here = os.path.dirname(__file__) -def require_metadata(): - "Prevent improper installs without necessary metadata. See #659" - egg_info_dir = os.path.join(here, 'setuptools.egg-info') - if not os.path.exists(egg_info_dir): - msg = ( - "Cannot build setuptools without metadata. " - "Run `bootstrap.py`." - ) - raise RuntimeError(msg) - - def read_commands(): command_ns = {} cmd_module_path = 'setuptools/command/__init__.py' @@ -189,5 +178,4 @@ setup_params = dict( if __name__ == '__main__': # allow setup.py to run from another directory here and os.chdir(here) - require_metadata() dist = setuptools.setup(**setup_params) diff --git a/tools/tox_pip.py b/tools/tox_pip.py deleted file mode 100644 index be2ff1d0..00000000 --- a/tools/tox_pip.py +++ /dev/null @@ -1,70 +0,0 @@ -import os -import subprocess -import sys -import re - - -def remove_setuptools(): - """ - Remove setuptools from the current environment. - """ - print("Removing setuptools") - cmd = [sys.executable, '-m', 'pip', 'uninstall', '-y', 'setuptools'] - # set cwd to something other than '.' to avoid detecting - # '.' as the installed package. - subprocess.check_call(cmd, cwd=os.environ['TOX_WORK_DIR']) - - -def bootstrap(): - print("Running bootstrap") - cmd = [sys.executable, '-m', 'bootstrap'] - subprocess.check_call(cmd) - - -def is_install_self(args): - """ - Do the args represent an install of .? - """ - def strip_extras(arg): - match = re.match(r'(.*)?\[.*\]$', arg) - return match.group(1) if match else arg - - return ( - 'install' in args - and any( - arg in ['.', os.getcwd()] - for arg in map(strip_extras, args) - ) - ) - - -def pip(*args): - cmd = [sys.executable, '-m', 'pip'] + list(args) - return subprocess.check_call(cmd) - - -def test_dependencies(): - from ConfigParser import ConfigParser - - def clean(dep): - spec, _, _ = dep.partition('#') - return spec.strip() - - parser = ConfigParser() - parser.read('setup.cfg') - raw = parser.get('options.extras_require', 'tests').split('\n') - return filter(None, map(clean, raw)) - - -def run(args): - os.environ['PIP_USE_PEP517'] = 'true' - - if is_install_self(args): - remove_setuptools() - bootstrap() - - pip(*args) - - -if __name__ == '__main__': - run(sys.argv[1:]) @@ -11,8 +11,6 @@ commands = pytest {posargs} usedevelop = True extras = testing -install_command = {[helpers]pip} install {opts} {packages} -list_dependencies_command = {[helpers]pip} freeze --all setenv = COVERAGE_FILE={toxworkdir}/.coverage.{envname} passenv = @@ -74,7 +72,3 @@ commands = python -m twine upload dist/* python -m jaraco.develop.create-github-release python -m jaraco.tidelift.publish-release-notes - -[helpers] -# Custom pip behavior -pip = python {toxinidir}/tools/tox_pip.py |