Commit 54b76e63 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #1981 from pypa/feature/deps-in-metadata

Move test dependencies to package metadata.
parents 73376585 91ede46d
......@@ -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 }}-
......
python:
version: 3
requirements_file: docs/requirements.txt
pip_install: false
extra_requirements:
- docs
pip_install: true
Setuptools now declares its ``tests`` and ``docs`` dependencies in metadata (extras).
sphinx!=1.8.0
rst.linker>=1.9
jaraco.packaging>=6.1
setuptools>=34
......@@ -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
......@@ -12,6 +12,17 @@ from .textwrap import DALS
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):
"""
......
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:])
......@@ -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=
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment