aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-02-04 05:34:30 -0500
committerGitHub <noreply@github.com>2020-02-04 05:34:30 -0500
commit54b76e63bb7ace4cd1be29d75f6dcfe3227444f9 (patch)
tree50fce6e6ca78d05287df8f8f600029d554eb0a26
parent73376585065bbf28395c71fe15137c19a712d4f3 (diff)
parent91ede46d247291a5e5449403880c15a2674ebcb5 (diff)
downloadexternal_python_setuptools-54b76e63bb7ace4cd1be29d75f6dcfe3227444f9.tar.gz
external_python_setuptools-54b76e63bb7ace4cd1be29d75f6dcfe3227444f9.tar.bz2
external_python_setuptools-54b76e63bb7ace4cd1be29d75f6dcfe3227444f9.zip
Merge pull request #1981 from pypa/feature/deps-in-metadata
Move test dependencies to package metadata.
-rw-r--r--.github/workflows/python-tests.yml2
-rw-r--r--.readthedocs.yml5
-rw-r--r--changelog.d/1981.change.rst1
-rw-r--r--docs/requirements.txt5
-rw-r--r--setup.cfg20
-rw-r--r--setuptools/tests/test_virtualenv.py11
-rw-r--r--tools/tox_pip.py61
-rw-r--r--tox.ini14
8 files changed, 96 insertions, 23 deletions
diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml
index 9d24a54a..e3663cf0 100644
--- a/.github/workflows/python-tests.yml
+++ b/.github/workflows/python-tests.yml
@@ -55,7 +55,7 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}-${{ hashFiles('tests/requirements.txt') }}-${{ hashFiles('tox.ini') }}
+ key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
diff --git a/.readthedocs.yml b/.readthedocs.yml
index 3aef6b6b..7b994a35 100644
--- a/.readthedocs.yml
+++ b/.readthedocs.yml
@@ -1,4 +1,5 @@
python:
version: 3
- requirements_file: docs/requirements.txt
- pip_install: false
+ extra_requirements:
+ - docs
+ pip_install: true
diff --git a/changelog.d/1981.change.rst b/changelog.d/1981.change.rst
new file mode 100644
index 00000000..c5713d9b
--- /dev/null
+++ b/changelog.d/1981.change.rst
@@ -0,0 +1 @@
+Setuptools now declares its ``tests`` and ``docs`` dependencies in metadata (extras).
diff --git a/docs/requirements.txt b/docs/requirements.txt
deleted file mode 100644
index bc27165b..00000000
--- a/docs/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-sphinx!=1.8.0
-rst.linker>=1.9
-jaraco.packaging>=6.1
-
-setuptools>=34
diff --git a/setup.cfg b/setup.cfg
index bef019ee..bc34b22c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -55,5 +55,25 @@ exclude = *.tests
[options.extras_require]
ssl =
wincertstore==0.2; sys_platform=='win32'
+
certs =
certifi==2016.9.26
+
+tests =
+ mock
+ pytest-flake8
+ flake8-2020; python_version>="3.6"
+ virtualenv>=13.0.0
+ pytest-virtualenv>=1.2.7
+ pytest>=3.7
+ wheel
+ coverage>=4.5.1
+ pytest-cov>=2.5.1
+ paver; python_version>="3.6"
+ futures; python_version=="2.7"
+ pip>=19.1 # For proper file:// URLs support.
+
+docs =
+ sphinx
+ jaraco.packaging>=6.1
+ rst.linker>=1.9
diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py
index b009fbd6..6549a6c0 100644
--- a/setuptools/tests/test_virtualenv.py
+++ b/setuptools/tests/test_virtualenv.py
@@ -13,6 +13,17 @@ from .test_easy_install import make_nspkg_sdist
@pytest.fixture(autouse=True)
+def disable_requires_python(monkeypatch):
+ """
+ Disable Requires-Python on Python 2.7
+ """
+ if sys.version_info > (3,):
+ return
+
+ monkeypatch.setenv('PIP_IGNORE_REQUIRES_PYTHON', 'true')
+
+
+@pytest.fixture(autouse=True)
def pytest_virtualenv_works(virtualenv):
"""
pytest_virtualenv may not work. if it doesn't, skip these
diff --git a/tools/tox_pip.py b/tools/tox_pip.py
index 2d33e9e5..9fe4f905 100644
--- a/tools/tox_pip.py
+++ b/tools/tox_pip.py
@@ -1,6 +1,7 @@
import os
import subprocess
import sys
+import re
def remove_setuptools():
@@ -20,18 +21,62 @@ def bootstrap():
subprocess.check_call(cmd)
-def pip(args):
- # Honor requires-python when installing test suite dependencies
- if any('-r' in arg for arg in args):
- os.environ['PIP_IGNORE_REQUIRES_PYTHON'] = '0'
+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()
- if '.' in args:
+ parser = ConfigParser()
+ parser.read('setup.cfg')
+ raw = parser.get('options.extras_require', 'tests').split('\n')
+ return filter(None, map(clean, raw))
+
+
+def disable_python_requires():
+ """
+ On Python 2, install the dependencies that are selective
+ on Python version while honoring REQUIRES_PYTHON, then
+ disable REQUIRES_PYTHON so that pip can install this
+ checkout of setuptools.
+ """
+ pip('install', *test_dependencies())
+ os.environ['PIP_IGNORE_REQUIRES_PYTHON'] = 'true'
+
+
+def run(args):
+ os.environ['PIP_USE_PEP517'] = 'true'
+
+ if is_install_self(args):
remove_setuptools()
bootstrap()
+ sys.version_info > (3,) or disable_python_requires()
- cmd = [sys.executable, '-m', 'pip'] + args
- subprocess.check_call(cmd)
+ pip(*args)
if __name__ == '__main__':
- pip(sys.argv[1:])
+ run(sys.argv[1:])
diff --git a/tox.ini b/tox.ini
index 6c73bd0c..2164599f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,18 +13,18 @@ requires =
pip = python {toxinidir}/tools/tox_pip.py
[testenv]
-deps=-r{toxinidir}/setuptools/tests/requirements.txt
pip_version = pip
install_command = {[helpers]pip} install {opts} {packages}
list_dependencies_command = {[helpers]pip} freeze --all
setenv =
COVERAGE_FILE={toxworkdir}/.coverage.{envname}
- py{27,py2}: PIP_IGNORE_REQUIRES_PYTHON=true
# TODO: The passed environment variables came from copying other tox.ini files
# These should probably be individually annotated to explain what needs them.
passenv=APPDATA HOMEDRIVE HOMEPATH windir APPVEYOR APPVEYOR_* CI CODECOV_* TRAVIS TRAVIS_* NETWORK_REQUIRED
commands=pytest --cov-config={toxinidir}/tox.ini --cov-report= {posargs}
usedevelop=True
+extras =
+ tests
[testenv:coverage]
@@ -44,12 +44,12 @@ skip_install=True
commands=codecov -X gcov --file {toxworkdir}/coverage.xml
[testenv:docs]
-deps = -r{toxinidir}/docs/requirements.txt
-skip_install=True
+extras =
+ docs
+ testing
+changedir = docs
commands =
- python -m bootstrap
- sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/build/html
- sphinx-build -W -b man -d {envtmpdir}/doctrees docs docs/build/man
+ python -m sphinx . {toxinidir}/build/html
[coverage:run]
source=