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: ...@@ -55,7 +55,7 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ~/.cache/pip 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: | restore-keys: |
${{ runner.os }}-pip- ${{ runner.os }}-pip-
${{ runner.os }}- ${{ runner.os }}-
......
python: python:
version: 3 version: 3
requirements_file: docs/requirements.txt extra_requirements:
pip_install: false - 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 ...@@ -55,5 +55,25 @@ exclude = *.tests
[options.extras_require] [options.extras_require]
ssl = ssl =
wincertstore==0.2; sys_platform=='win32' wincertstore==0.2; sys_platform=='win32'
certs = certs =
certifi==2016.9.26 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 ...@@ -12,6 +12,17 @@ from .textwrap import DALS
from .test_easy_install import make_nspkg_sdist 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) @pytest.fixture(autouse=True)
def pytest_virtualenv_works(virtualenv): def pytest_virtualenv_works(virtualenv):
""" """
......
import os import os
import subprocess import subprocess
import sys import sys
import re
def remove_setuptools(): def remove_setuptools():
...@@ -20,18 +21,62 @@ def bootstrap(): ...@@ -20,18 +21,62 @@ def bootstrap():
subprocess.check_call(cmd) subprocess.check_call(cmd)
def pip(args): def is_install_self(args):
# Honor requires-python when installing test suite dependencies """
if any('-r' in arg for arg in args): Do the args represent an install of .?
os.environ['PIP_IGNORE_REQUIRES_PYTHON'] = '0' """
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() remove_setuptools()
bootstrap() bootstrap()
sys.version_info > (3,) or disable_python_requires()
cmd = [sys.executable, '-m', 'pip'] + args pip(*args)
subprocess.check_call(cmd)
if __name__ == '__main__': if __name__ == '__main__':
pip(sys.argv[1:]) run(sys.argv[1:])
...@@ -13,18 +13,18 @@ requires = ...@@ -13,18 +13,18 @@ requires =
pip = python {toxinidir}/tools/tox_pip.py pip = python {toxinidir}/tools/tox_pip.py
[testenv] [testenv]
deps=-r{toxinidir}/setuptools/tests/requirements.txt
pip_version = pip pip_version = pip
install_command = {[helpers]pip} install {opts} {packages} install_command = {[helpers]pip} install {opts} {packages}
list_dependencies_command = {[helpers]pip} freeze --all list_dependencies_command = {[helpers]pip} freeze --all
setenv = setenv =
COVERAGE_FILE={toxworkdir}/.coverage.{envname} 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 # TODO: The passed environment variables came from copying other tox.ini files
# These should probably be individually annotated to explain what needs them. # These should probably be individually annotated to explain what needs them.
passenv=APPDATA HOMEDRIVE HOMEPATH windir APPVEYOR APPVEYOR_* CI CODECOV_* TRAVIS TRAVIS_* NETWORK_REQUIRED passenv=APPDATA HOMEDRIVE HOMEPATH windir APPVEYOR APPVEYOR_* CI CODECOV_* TRAVIS TRAVIS_* NETWORK_REQUIRED
commands=pytest --cov-config={toxinidir}/tox.ini --cov-report= {posargs} commands=pytest --cov-config={toxinidir}/tox.ini --cov-report= {posargs}
usedevelop=True usedevelop=True
extras =
tests
[testenv:coverage] [testenv:coverage]
...@@ -44,12 +44,12 @@ skip_install=True ...@@ -44,12 +44,12 @@ skip_install=True
commands=codecov -X gcov --file {toxworkdir}/coverage.xml commands=codecov -X gcov --file {toxworkdir}/coverage.xml
[testenv:docs] [testenv:docs]
deps = -r{toxinidir}/docs/requirements.txt extras =
skip_install=True docs
testing
changedir = docs
commands = commands =
python -m bootstrap python -m sphinx . {toxinidir}/build/html
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/build/html
sphinx-build -W -b man -d {envtmpdir}/doctrees docs docs/build/man
[coverage:run] [coverage:run]
source= 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