summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/python-tests.yml2
-rw-r--r--setup.cfg13
-rw-r--r--setuptools/tests/test_virtualenv.py11
-rw-r--r--tools/tox_pip.py61
-rw-r--r--tox.ini4
5 files changed, 80 insertions, 11 deletions
diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml
index 9d24a54a..60765b52 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('docs/requirements.txt') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
diff --git a/setup.cfg b/setup.cfg
index bef019ee..87c25a62 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -57,3 +57,16 @@ 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.
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..a5ce930f 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]