Add 'dist' build (#5656)

This commit is contained in:
Ryan P Kilby 2017-12-14 05:48:03 -05:00 committed by Carlton Gibson
parent 2359d3981b
commit d12005cf90
3 changed files with 33 additions and 4 deletions

View File

@ -22,10 +22,19 @@ matrix:
- { python: "3.6", env: DJANGO=2.0 }
- { python: "2.7", env: TOXENV=lint }
- { python: "2.7", env: TOXENV=docs }
- python: "2.7"
- python: "3.6"
env: TOXENV=dist
script:
- python setup.py bdist_wheel
- tox --installpkg ./dist/djangorestframework-*.whl
- tox # test sdist
- python: "3.6"
env: TOXENV=readme
addons:
apt_packages: pandoc
exclude:
- { python: "2.7", env: DJANGO=master }
- { python: "2.7", env: DJANGO=2.0 }

View File

@ -16,8 +16,6 @@ FLAKE8_ARGS = ['rest_framework', 'tests']
ISORT_ARGS = ['--recursive', '--check-only', '-o' 'uritemplate', '-p', 'tests', 'rest_framework', 'tests']
sys.path.append(os.path.dirname(__file__))
def exit_on_failure(ret, message=None):
if ret:
@ -84,6 +82,20 @@ if __name__ == "__main__":
run_flake8 = False
run_isort = False
try:
# Remove the package root directory from `sys.path`, ensuring that rest_framework
# is imported from the installed site packages. Used for testing the distribution
sys.argv.remove('--no-pkgroot')
except ValueError:
pass
else:
sys.path.pop(0)
# import rest_framework before pytest re-adds the package root directory.
import rest_framework
package_dir = os.path.join(os.getcwd(), 'rest_framework')
assert not rest_framework.__file__.startswith(package_dir)
if len(sys.argv) > 1:
pytest_args = sys.argv[1:]
first_arg = pytest_args[0]

10
tox.ini
View File

@ -7,7 +7,7 @@ envlist =
{py27,py34,py35,py36}-django111,
{py34,py35,py36}-django20,
{py35,py36}-djangomaster,
lint,docs,readme,
dist,lint,docs,readme,
[travis:env]
DJANGO =
@ -18,6 +18,7 @@ DJANGO =
[testenv]
commands = ./runtests.py --fast {posargs} --coverage -rw
envdir = {toxworkdir}/venvs/{envname}
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
@ -29,6 +30,13 @@ deps =
-rrequirements/requirements-testing.txt
-rrequirements/requirements-optionals.txt
[testenv:dist]
commands = ./runtests.py --fast {posargs} --no-pkgroot -rw
deps =
django
-rrequirements/requirements-testing.txt
-rrequirements/requirements-optionals.txt
[testenv:lint]
basepython = python2.7
commands = ./runtests.py --lintonly