From 7548a42a9b7471d94fe775a705b1c32c66ee6023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 19:33:44 +0200 Subject: [PATCH 1/9] Add empty pyproject.toml Apparently this fixes `pip install -e .`?!? https://stackoverflow.com/a/53698424/3194671 --- pyproject.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 From dfd2bcabf2769727310514f965c3be75cb5f3834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 19:43:51 +0200 Subject: [PATCH 2/9] Add build-system requirements to pyproject.toml PEP518 added an alternative way to specify setup_requires before executing the setup.py script. --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index e69de29..2a39a17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools", "wheel", "setuptools-scm"] From 930f3825d72656ac225fb30015c20e9137e0eb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 19:48:10 +0200 Subject: [PATCH 3/9] Improve installation walkthroughs --- CONTRIBUTING.rst | 10 +++++----- README.rst | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 0642199..1f38c6e 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -35,6 +35,7 @@ You want to contribute some code? Great! Here are a few steps to get you started $ virtualenv venv $ source venv/bin/activate + (venv) $ python -m pip install -U pip (venv) $ pip install -U -e .[validation] (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 - (venv) $ cd testproj - (venv) $ python manage.py generate_swagger ../tests/reference.yaml --overwrite --user admin --url http://test.local:8002/ + (venv) $ python testproj/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 ``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 - # (optional) sort imports with isort and check flake8 linting - (venv) $ isort --apply - (venv) $ flake8 src/drf_yasg testproj tests setup.py # install test dependencies (venv) $ pip install -U -r requirements/test.txt # run tests in the current environment, faster than tox (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 (venv) $ tox diff --git a/README.rst b/README.rst index f262ebc..7d60c10 100644 --- a/README.rst +++ b/README.rst @@ -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 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 $ source venv/bin/activate (venv) $ cd testproj + (venv) $ python -m pip install -U pip (venv) $ pip install -U -r requirements.txt (venv) $ python manage.py migrate (venv) $ python manage.py shell -c "import createsuperuser" From 1946a1204deb06d694ccdf9e7b6d7cc30e5f8d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 20:20:51 +0200 Subject: [PATCH 4/9] Remove requirements/setup.txt and setup_requires --- .travis.yml | 13 ++++++------- requirements.txt | 3 ++- requirements/setup.txt | 3 --- requirements/tox.txt | 2 -- setup.py | 2 -- tox.ini | 2 -- 6 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 requirements/setup.txt diff --git a/.travis.yml b/.travis.yml index 0f40fa8..61f9499 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,14 +15,12 @@ jobs: python: '3.7' dist: xenial sudo: required - - - python: '3.6' + - python: '3.6' env: TOXENV=djmaster - # readthedocs uses python 3.5 for building python: '3.5' env: TOXENV=docs - - - python: '3.6' + - python: '3.6' env: TOXENV=lint - stage: publish @@ -45,13 +43,14 @@ jobs: fast_finish: true install: - - pip install -r requirements/ci.txt + - python -m pip install -U pip + - pip install -r requirements/ci.txt before_script: - - coverage erase + - coverage erase script: - - tox + - tox after_success: - | diff --git a/requirements.txt b/requirements.txt index b7d456c..fd3b279 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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] -r requirements/heroku.txt diff --git a/requirements/setup.txt b/requirements/setup.txt deleted file mode 100644 index bf6789e..0000000 --- a/requirements/setup.txt +++ /dev/null @@ -1,3 +0,0 @@ -# needed to build the package setup_requires in setup.py - -setuptools-scm>=3.0.6 diff --git a/requirements/tox.txt b/requirements/tox.txt index eae549b..a402899 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -1,4 +1,2 @@ # requirements for building and running tox tox>=3.1.2 - --r setup.txt diff --git a/setup.py b/setup.py index 2188995..7ab033d 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ with io.open('README.rst', encoding='utf-8') as readme: description = readme.read() requirements = read_req('base.txt') -requirements_setup = read_req('setup.txt') requirements_validation = read_req('validation.txt') @@ -28,7 +27,6 @@ def drf_yasg_setup(**kwargs): package_dir={'': 'src'}, include_package_data=True, install_requires=requirements, - setup_requires=requirements_setup, extras_require={ 'validation': requirements_validation, }, diff --git a/tox.ini b/tox.ini index 17f283e..a261fd4 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,6 @@ deps = djmaster: https://github.com/django/django/archive/master.tar.gz # other dependencies - -rrequirements/setup.txt -rrequirements/validation.txt -rrequirements/test.txt @@ -37,7 +36,6 @@ commands = [testenv:docs] deps = - -rrequirements/setup.txt -rrequirements/docs.txt commands = python setup.py check --restructuredtext --metadata --strict From 789f118532d65482239954493875a18171baa30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 20:30:02 +0200 Subject: [PATCH 5/9] Update Heroku runtime to Python 3.7.1 --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index 34b35b7..4255f73 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.6.7 +python-3.7.1 From 1fc454fcfabc717c7070c9702dfa4c6f73867987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 21:03:52 +0200 Subject: [PATCH 6/9] Enable isolated_build for tox This enables tox support for PEP517 and PEP518. --- MANIFEST.in | 1 + pyproject.toml | 1 + requirements/tox.txt | 2 +- tox.ini | 15 +++++++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 7611cf8..05aca6e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include README.rst include LICENSE.rst +include pyproject.toml recursive-include requirements * recursive-include src/drf_yasg/static * recursive-include src/drf_yasg/templates * diff --git a/pyproject.toml b/pyproject.toml index 2a39a17..f50ab2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,3 @@ [build-system] requires = ["setuptools", "wheel", "setuptools-scm"] +build-backend = "setuptools.build_meta" diff --git a/requirements/tox.txt b/requirements/tox.txt index a402899..4015c91 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -1,2 +1,2 @@ # requirements for building and running tox -tox>=3.1.2 +tox>=3.3.0 diff --git a/tox.ini b/tox.ini index a261fd4..01696a7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,18 @@ [tox] # 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 = py{27,34,35,36}-django111-drf{37,38,39}, py{34,35,36,37}-django20-drf{37,38,39}, py{35,36,37}-django21-drf{37,38,39}, djmaster, lint, docs +[testenv:.package] +# no additional dependencies besides PEP 517 +deps = + [testenv] deps = django111: Django>=1.11,<2.0 @@ -21,8 +28,8 @@ deps = djmaster: https://github.com/django/django/archive/master.tar.gz # other dependencies - -rrequirements/validation.txt - -rrequirements/test.txt + -r requirements/validation.txt + -r requirements/test.txt commands = pytest -n 2 --cov --cov-config .coveragerc --cov-append --cov-report="" {posargs} @@ -30,13 +37,13 @@ commands = [testenv:lint] skip_install = true deps = - -rrequirements/lint.txt + -r requirements/lint.txt commands = flake8 src/drf_yasg testproj tests setup.py [testenv:docs] deps = - -rrequirements/docs.txt + -r requirements/docs.txt commands = python setup.py check --restructuredtext --metadata --strict sphinx-build -WnEa -b html docs docs/_build/html From a24070446aa97105c94816f2885679e001fe13e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 21:15:29 +0200 Subject: [PATCH 7/9] Also update setuptools with pip --- .travis.yml | 2 +- CONTRIBUTING.rst | 2 +- README.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61f9499..e1ab72a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ jobs: fast_finish: true install: - - python -m pip install -U pip + - python -m pip install -U pip setuptools - pip install -r requirements/ci.txt before_script: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1f38c6e..57893c3 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -35,7 +35,7 @@ You want to contribute some code? Great! Here are a few steps to get you started $ virtualenv venv $ source venv/bin/activate - (venv) $ python -m pip install -U pip + (venv) $ python -m pip install -U pip setuptools (venv) $ pip install -U -e .[validation] (venv) $ pip install -U -r requirements/dev.txt diff --git a/README.rst b/README.rst index 7d60c10..1e7c84c 100644 --- a/README.rst +++ b/README.rst @@ -294,7 +294,7 @@ For additional usage examples, you can take a look at the test project in the `` $ virtualenv venv $ source venv/bin/activate (venv) $ cd testproj - (venv) $ python -m pip install -U pip + (venv) $ python -m pip install -U pip setuptools (venv) $ pip install -U -r requirements.txt (venv) $ python manage.py migrate (venv) $ python manage.py shell -c "import createsuperuser" From cf4106f8f7d1ccdeb0552d3c2ae71a0d733e5fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 21:41:39 +0200 Subject: [PATCH 8/9] Use twine check instead of setup.py check --- requirements/docs.txt | 3 ++- tox.ini | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements/docs.txt b/requirements/docs.txt index b528a74..c5ca67a 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -2,7 +2,8 @@ Sphinx>=1.7.0 sphinx_rtd_theme>=0.2.4 Pillow>=4.3.0 -readme_renderer>=17.2 +readme_renderer[md]>=24.0 +twine>=1.12.1 Django>=2.0 djangorestframework_camel_case>=0.2.0 diff --git a/tox.ini b/tox.ini index 01696a7..f3e37e4 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ commands = deps = -r requirements/docs.txt commands = - python setup.py check --restructuredtext --metadata --strict + twine check .tox/dist/* sphinx-build -WnEa -b html docs docs/_build/html [pytest] From 5652d2a04d8daaa1044cbe7ba35a915a8f8a8e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Wed, 19 Dec 2018 22:19:24 +0200 Subject: [PATCH 9/9] Manually install setuptools-scm for Travis deploy This only works because we still mostly use default build configuration of setuptools and wheel, so we don't really depend on PEP517 builds, only PEP518 build requirements. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index e1ab72a..d21d864 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,10 @@ jobs: - stage: publish 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 env: PYPI_DEPLOY=true deploy: &pypi