From 911a3b953ee5c09f01ea514d3b7656506264996f Mon Sep 17 00:00:00 2001 From: Oliver Sauder Date: Wed, 9 Oct 2019 11:28:48 +0400 Subject: [PATCH] Split requirements files up following DRF example Fixes #712 Fixes #635 This way not all dependency need to be installed for the different testing steps. --- .pyup.yml | 14 +++++++++++++- .travis.yml | 4 +++- README.rst | 5 ++--- docs/conf.py | 2 +- docs/getting-started.md | 3 +-- requirements-development.txt | 16 ---------------- requirements.txt | 14 +++++++++++++- requirements/requirements-codestyle.txt | 3 +++ requirements/requirements-documentation.txt | 3 +++ requirements/requirements-optionals.txt | 2 ++ requirements/requirements-packaging.txt | 1 + requirements/requirements-testing.txt | 7 +++++++ tox.ini | 18 ++++++++++++------ 13 files changed, 61 insertions(+), 31 deletions(-) delete mode 100644 requirements-development.txt create mode 100644 requirements/requirements-codestyle.txt create mode 100644 requirements/requirements-documentation.txt create mode 100644 requirements/requirements-optionals.txt create mode 100644 requirements/requirements-packaging.txt create mode 100644 requirements/requirements-testing.txt diff --git a/.pyup.yml b/.pyup.yml index 02f8ed991..c4b52e374 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -1,5 +1,17 @@ search: False requirements: - - requirements-development.txt: + - requirements/requirements-codestyle.txt: + update: all + pin: True + - requirements/requirements-documentation.txt: + update: all + pin: True + - requirements/requirements-optionals.txt: + update: all + pin: True + - requirements/requirements-packaging.txt: + update: all + pin: True + - requirements/requirements-testing.txt: update: all pin: True diff --git a/.travis.yml b/.travis.yml index b459f10f1..6d6ccfb23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,9 @@ matrix: include: - python: 3.6 - env: TOXENV=flake8 + env: TOXENV=lint + - python: 3.6 + env: TOXENV=docs - python: 3.5 env: TOXENV=py35-django111-drf310 diff --git a/README.rst b/README.rst index 2a53723ce..f1561464e 100644 --- a/README.rst +++ b/README.rst @@ -126,8 +126,7 @@ installed and activated: $ git clone https://github.com/django-json-api/django-rest-framework-json-api.git $ cd django-rest-framework-json-api - $ pip install -r example/requirements.txt - $ pip install -e . + $ pip install -U -e . -r requirements.txt $ django-admin migrate --settings=example.settings $ django-admin loaddata drf_example --settings=example.settings $ django-admin runserver --settings=example.settings @@ -143,7 +142,7 @@ installed and activated: :: - $ pip install -Ur requirements-development.txt + $ pip install -Ur requirements.txt $ flake8 $ pytest diff --git a/docs/conf.py b/docs/conf.py index 88111be3a..ee435d368 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,7 +31,7 @@ django.setup() # Auto-generate API documentation. -main(['-o', '_build/apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api']) +main(['-o', 'apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api']) # -- General configuration ------------------------------------------------ diff --git a/docs/getting-started.md b/docs/getting-started.md index d89eb248a..9083ee41d 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -75,8 +75,7 @@ From Source cd django-rest-framework-json-api python3 -m venv env source env/bin/activate - pip install -r example/requirements.txt - pip install -e . + pip install -U -e . r requirements.txt django-admin migrate --settings=example.settings django-admin loaddata drf_example --settings=example.settings django-admin runserver --settings=example.settings diff --git a/requirements-development.txt b/requirements-development.txt deleted file mode 100644 index a8115e166..000000000 --- a/requirements-development.txt +++ /dev/null @@ -1,16 +0,0 @@ --e . -django-debug-toolbar==2.0 -django-filter==2.2.0 -django-polymorphic==2.1.2 -Faker==2.0.2 -factory-boy==2.12.0 -flake8==3.7.7 -flake8-isort==2.7.0 -isort==4.3.21 -pytest==5.2.1 -pytest-cov==2.8.1 -pytest-django==3.5.1 -pytest-factoryboy==2.0.3 -recommonmark==0.6.0 -Sphinx==2.2.0 -sphinx_rtd_theme==0.4.3 diff --git a/requirements.txt b/requirements.txt index 8d1c8b69c..862b4aa82 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,13 @@ - +# The base set of requirements for Django REST framework JSON API is actually +# fairly small, but for the purposes of development and testing +# there are a number of packages that are useful to install. + +# Laying these out as separate requirements files, allows us to +# only included the relevant sets when running tox, and ensures +# we are only ever declaring our dependencies in one place. + +-r requirements/requirements-optionals.txt +-r requirements/requirements-testing.txt +-r requirements/requirements-documentation.txt +-r requirements/requirements-codestyle.txt +-r requirements/requirements-packaging.txt diff --git a/requirements/requirements-codestyle.txt b/requirements/requirements-codestyle.txt new file mode 100644 index 000000000..49ef62acd --- /dev/null +++ b/requirements/requirements-codestyle.txt @@ -0,0 +1,3 @@ +flake8==3.7.7 +flake8-isort==2.7.0 +isort==4.3.21 diff --git a/requirements/requirements-documentation.txt b/requirements/requirements-documentation.txt new file mode 100644 index 000000000..19d59a2e4 --- /dev/null +++ b/requirements/requirements-documentation.txt @@ -0,0 +1,3 @@ +recommonmark==0.6.0 +Sphinx==2.2.0 +sphinx_rtd_theme==0.4.3 diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt new file mode 100644 index 000000000..cc5f81b3f --- /dev/null +++ b/requirements/requirements-optionals.txt @@ -0,0 +1,2 @@ +django-filter==2.2.0 +django-polymorphic==2.1.2 diff --git a/requirements/requirements-packaging.txt b/requirements/requirements-packaging.txt new file mode 100644 index 000000000..f3c2cd3e2 --- /dev/null +++ b/requirements/requirements-packaging.txt @@ -0,0 +1 @@ +twine==2.0.0 diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt new file mode 100644 index 000000000..836971ec2 --- /dev/null +++ b/requirements/requirements-testing.txt @@ -0,0 +1,7 @@ +django-debug-toolbar==2.0 +factory-boy==2.12.0 +Faker==2.0.2 +pytest==5.2.1 +pytest-cov==2.8.1 +pytest-django==3.5.1 +pytest-factoryboy==2.0.3 diff --git a/tox.ini b/tox.ini index 3431b4ead..139929466 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = py{35,36}-django111-drf{310,master}, py{35,36,37}-django{21,22}-drf{310,master}, + lint,docs [testenv] deps = @@ -10,7 +11,8 @@ deps = django22: Django>=2.2,<2.3 drf310: djangorestframework>=3.10.2,<3.11 drfmaster: https://github.com/encode/django-rest-framework/archive/master.zip - -rrequirements-development.txt + -rrequirements/requirements-testing.txt + -rrequirements/requirements-optionals.txt setenv = PYTHONPATH = {toxinidir} @@ -19,15 +21,19 @@ setenv = commands = pytest --cov --no-cov-on-fail --cov-report xml {posargs} -[testenv:flake8] +[testenv:lint] basepython = python3.6 deps = - -rrequirements-development.txt + -rrequirements/requirements-codestyle.txt + -rrequirements/requirements-testing.txt + -rrequirements/requirements-optionals.txt commands = flake8 -[testenv:sphinx] +[testenv:docs] basepython = python3.6 deps = - -rrequirements-development.txt + -rrequirements/requirements-testing.txt + -rrequirements/requirements-optionals.txt + -rrequirements/requirements-documentation.txt commands = - sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html + sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html