Merge pull request #276 from axnsan12/pyproject-pep518

Add pyproject.toml (implement PEP517 and PEP518)
master
Cristi Vîjdea 2018-12-19 23:49:55 +02:00 committed by GitHub
commit 8974aa5734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 39 additions and 31 deletions

View File

@ -15,18 +15,20 @@ jobs:
python: '3.7' python: '3.7'
dist: xenial dist: xenial
sudo: required sudo: required
- - python: '3.6'
python: '3.6'
env: TOXENV=djmaster env: TOXENV=djmaster
- # readthedocs uses python 3.5 for building - # readthedocs uses python 3.5 for building
python: '3.5' python: '3.5'
env: TOXENV=docs env: TOXENV=docs
- - python: '3.6'
python: '3.6'
env: TOXENV=lint env: TOXENV=lint
- stage: publish - stage: publish
python: '3.6' python: '3.6'
before_script:
# workaround for Travis' inability to build PEP517 projects; anything added to build-system.requires
# will also have to be added here until Travis implements this
- pip install setuptools-scm
script: skip script: skip
env: PYPI_DEPLOY=true env: PYPI_DEPLOY=true
deploy: &pypi deploy: &pypi
@ -45,6 +47,7 @@ jobs:
fast_finish: true fast_finish: true
install: install:
- python -m pip install -U pip setuptools
- pip install -r requirements/ci.txt - pip install -r requirements/ci.txt
before_script: before_script:

View File

@ -35,6 +35,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
$ virtualenv venv $ virtualenv venv
$ source venv/bin/activate $ source venv/bin/activate
(venv) $ python -m pip install -U pip setuptools
(venv) $ pip install -U -e .[validation] (venv) $ pip install -U -e .[validation]
(venv) $ pip install -U -r requirements/dev.txt (venv) $ pip install -U -r requirements/dev.txt
@ -57,8 +58,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
.. code:: console .. code:: console
(venv) $ cd testproj (venv) $ python testproj/manage.py generate_swagger ../tests/reference.yaml --overwrite --user admin --url http://test.local:8002/
(venv) $ python manage.py generate_swagger ../tests/reference.yaml --overwrite --user admin --url http://test.local:8002/
After checking the git diff to verify that no unexpected changes appeared, you should commit the new After checking the git diff to verify that no unexpected changes appeared, you should commit the new
``reference.yaml`` together with your changes. ``reference.yaml`` together with your changes.
@ -67,13 +67,13 @@ You want to contribute some code? Great! Here are a few steps to get you started
.. code:: console .. code:: console
# (optional) sort imports with isort and check flake8 linting
(venv) $ isort --apply
(venv) $ flake8 src/drf_yasg testproj tests setup.py
# install test dependencies # install test dependencies
(venv) $ pip install -U -r requirements/test.txt (venv) $ pip install -U -r requirements/test.txt
# run tests in the current environment, faster than tox # run tests in the current environment, faster than tox
(venv) $ pytest -n auto --cov (venv) $ pytest -n auto --cov
# (optional) sort imports with isort and check flake8 linting
(venv) $ isort --apply
(venv) $ flake8 src/drf_yasg testproj tests setup.py
# (optional) run tests for other python versions in separate environments # (optional) run tests for other python versions in separate environments
(venv) $ tox (venv) $ tox

View File

@ -1,5 +1,6 @@
include README.rst include README.rst
include LICENSE.rst include LICENSE.rst
include pyproject.toml
recursive-include requirements * recursive-include requirements *
recursive-include src/drf_yasg/static * recursive-include src/drf_yasg/static *
recursive-include src/drf_yasg/templates * recursive-include src/drf_yasg/templates *

View File

@ -140,7 +140,7 @@ In ``urls.py``:
... ...
] ]
This exposes 4 cached, validated and publicly available endpoints: This exposes 4 endpoints:
* A JSON view of your API specification at ``/swagger.json`` * A JSON view of your API specification at ``/swagger.json``
* A YAML view of your API specification at ``/swagger.yaml`` * A YAML view of your API specification at ``/swagger.yaml``
@ -294,6 +294,7 @@ For additional usage examples, you can take a look at the test project in the ``
$ virtualenv venv $ virtualenv venv
$ source venv/bin/activate $ source venv/bin/activate
(venv) $ cd testproj (venv) $ cd testproj
(venv) $ python -m pip install -U pip setuptools
(venv) $ pip install -U -r requirements.txt (venv) $ pip install -U -r requirements.txt
(venv) $ python manage.py migrate (venv) $ python manage.py migrate
(venv) $ python manage.py shell -c "import createsuperuser" (venv) $ python manage.py shell -c "import createsuperuser"

3
pyproject.toml 100644
View File

@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-scm"]
build-backend = "setuptools.build_meta"

View File

@ -1,3 +1,4 @@
-r requirements/setup.txt # this file is only used when deploying to heroku, because heroku insists on having a root-level requirements.txt
# for normal usage see the requirements/ directory
.[validation] .[validation]
-r requirements/heroku.txt -r requirements/heroku.txt

View File

@ -2,7 +2,8 @@
Sphinx>=1.7.0 Sphinx>=1.7.0
sphinx_rtd_theme>=0.2.4 sphinx_rtd_theme>=0.2.4
Pillow>=4.3.0 Pillow>=4.3.0
readme_renderer>=17.2 readme_renderer[md]>=24.0
twine>=1.12.1
Django>=2.0 Django>=2.0
djangorestframework_camel_case>=0.2.0 djangorestframework_camel_case>=0.2.0

View File

@ -1,3 +0,0 @@
# needed to build the package setup_requires in setup.py
setuptools-scm>=3.0.6

View File

@ -1,4 +1,2 @@
# requirements for building and running tox # requirements for building and running tox
tox>=3.1.2 tox>=3.3.0
-r setup.txt

View File

@ -1 +1 @@
python-3.6.7 python-3.7.1

View File

@ -17,7 +17,6 @@ with io.open('README.rst', encoding='utf-8') as readme:
description = readme.read() description = readme.read()
requirements = read_req('base.txt') requirements = read_req('base.txt')
requirements_setup = read_req('setup.txt')
requirements_validation = read_req('validation.txt') requirements_validation = read_req('validation.txt')
@ -28,7 +27,6 @@ def drf_yasg_setup(**kwargs):
package_dir={'': 'src'}, package_dir={'': 'src'},
include_package_data=True, include_package_data=True,
install_requires=requirements, install_requires=requirements,
setup_requires=requirements_setup,
extras_require={ extras_require={
'validation': requirements_validation, 'validation': requirements_validation,
}, },

19
tox.ini
View File

@ -1,11 +1,18 @@
[tox] [tox]
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django # https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
minversion = 3.3.0
isolated_build = true
isolated_build_env=.package
envlist = envlist =
py{27,34,35,36}-django111-drf{37,38,39}, py{27,34,35,36}-django111-drf{37,38,39},
py{34,35,36,37}-django20-drf{37,38,39}, py{34,35,36,37}-django20-drf{37,38,39},
py{35,36,37}-django21-drf{37,38,39}, py{35,36,37}-django21-drf{37,38,39},
djmaster, lint, docs djmaster, lint, docs
[testenv:.package]
# no additional dependencies besides PEP 517
deps =
[testenv] [testenv]
deps = deps =
django111: Django>=1.11,<2.0 django111: Django>=1.11,<2.0
@ -21,9 +28,8 @@ deps =
djmaster: https://github.com/django/django/archive/master.tar.gz djmaster: https://github.com/django/django/archive/master.tar.gz
# other dependencies # other dependencies
-rrequirements/setup.txt -r requirements/validation.txt
-rrequirements/validation.txt -r requirements/test.txt
-rrequirements/test.txt
commands = commands =
pytest -n 2 --cov --cov-config .coveragerc --cov-append --cov-report="" {posargs} pytest -n 2 --cov --cov-config .coveragerc --cov-append --cov-report="" {posargs}
@ -31,16 +37,15 @@ commands =
[testenv:lint] [testenv:lint]
skip_install = true skip_install = true
deps = deps =
-rrequirements/lint.txt -r requirements/lint.txt
commands = commands =
flake8 src/drf_yasg testproj tests setup.py flake8 src/drf_yasg testproj tests setup.py
[testenv:docs] [testenv:docs]
deps = deps =
-rrequirements/setup.txt -r requirements/docs.txt
-rrequirements/docs.txt
commands = commands =
python setup.py check --restructuredtext --metadata --strict twine check .tox/dist/*
sphinx-build -WnEa -b html docs docs/_build/html sphinx-build -WnEa -b html docs docs/_build/html
[pytest] [pytest]