Skip to content

Commit 6c8600a

Browse files
author
Ryan P Kilby
committed
Add 'dist' build
1 parent 7855d3b commit 6c8600a

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@ matrix:
2020
- { python: "3.6", env: DJANGO=master }
2121
- { python: "3.6", env: DJANGO=1.11 }
2222
- { python: "3.6", env: DJANGO=2.0 }
23-
- { python: "2.7", env: TOXENV=lint }
24-
- { python: "2.7", env: TOXENV=docs }
25-
- python: "2.7"
23+
- { python: "3.6", env: TOXENV=lint }
24+
- { python: "3.6", env: TOXENV=docs }
25+
26+
- python: "3.6"
27+
env: TOXENV=dist
28+
script:
29+
- python setup.py bdist_wheel
30+
- tox --installpkg ./dist/djangorestframework-*.whl
31+
- tox # test sdist
32+
33+
- python: "3.6"
2634
env: TOXENV=readme
2735
addons:
2836
apt_packages: pandoc
37+
2938
exclude:
3039
- { python: "2.7", env: DJANGO=master }
3140
- { python: "2.7", env: DJANGO=2.0 }

runtests.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
ISORT_ARGS = ['--recursive', '--check-only', '-o' 'uritemplate', '-p', 'tests', 'rest_framework', 'tests']
1818

19-
sys.path.append(os.path.dirname(__file__))
20-
2119

2220
def exit_on_failure(ret, message=None):
2321
if ret:
@@ -84,6 +82,20 @@ def is_class(string):
8482
run_flake8 = False
8583
run_isort = False
8684

85+
try:
86+
# Remove the package root directory from `sys.path`, ensuring that rest_framework
87+
# is imported from the installed site packages. Used for testing the distribution
88+
sys.argv.remove('--no-pkgroot')
89+
except ValueError:
90+
pass
91+
else:
92+
sys.path.pop(0)
93+
94+
# import rest_framework before pytest re-adds the package root directory.
95+
import rest_framework
96+
package_dir = os.path.join(os.getcwd(), 'rest_framework')
97+
assert not rest_framework.__file__.startswith(package_dir)
98+
8799
if len(sys.argv) > 1:
88100
pytest_args = sys.argv[1:]
89101
first_arg = pytest_args[0]

tox.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ envlist =
77
{py27,py34,py35,py36}-django111,
88
{py34,py35,py36}-django20,
99
{py35,py36}-djangomaster,
10-
lint,docs,readme,
10+
dist,lint,docs,readme,
1111

1212
[travis:env]
1313
DJANGO =
@@ -18,6 +18,7 @@ DJANGO =
1818

1919
[testenv]
2020
commands = ./runtests.py --fast {posargs} --coverage -rw
21+
envdir = {toxworkdir}/venvs/{envname}
2122
setenv =
2223
PYTHONDONTWRITEBYTECODE=1
2324
PYTHONWARNINGS=once
@@ -29,6 +30,13 @@ deps =
2930
-rrequirements/requirements-testing.txt
3031
-rrequirements/requirements-optionals.txt
3132

33+
[testenv:dist]
34+
commands = ./runtests.py --fast {posargs} --no-pkgroot -rw
35+
deps =
36+
django
37+
-rrequirements/requirements-testing.txt
38+
-rrequirements/requirements-optionals.txt
39+
3240
[testenv:lint]
3341
basepython = python2.7
3442
commands = ./runtests.py --lintonly

0 commit comments

Comments
 (0)