Skip to content

Commit

Permalink
Add 'dist' build (encode#5656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby authored and carltongibson committed Dec 14, 2017
1 parent 2359d39 commit d12005c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
16 changes: 14 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

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:
Expand Down Expand Up @@ -84,6 +82,20 @@ def is_class(string):
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]
Expand Down
10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -18,6 +18,7 @@ DJANGO =

[testenv]
commands = ./runtests.py --fast {posargs} --coverage -rw
envdir = {toxworkdir}/venvs/{envname}
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
Expand All @@ -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
Expand Down

0 comments on commit d12005c

Please sign in to comment.