From c601faf9943610dbe5f9863ac02be503b487ae7f Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Fri, 29 Dec 2017 16:11:47 +0100 Subject: [PATCH] Use extras_require instead of dev-requirements.txt (#318) * Use extras_require instead of dev-requirements.txt * Better phrasing * Make names reflects dir names, add docs Keep docs-requirements.txt for now, but the plan is to get rid of it. * Explain docs building --- .github/CONTRIBUTING.rst | 31 +++++++++++++++---------------- MANIFEST.in | 2 +- dev-requirements.txt | 6 ------ docs-requirements.txt | 4 +--- setup.py | 16 ++++++++++++++++ tox.ini | 12 ++++++------ 6 files changed, 39 insertions(+), 32 deletions(-) delete mode 100644 dev-requirements.txt diff --git a/.github/CONTRIBUTING.rst b/.github/CONTRIBUTING.rst index 9822f892..ae35dc1d 100644 --- a/.github/CONTRIBUTING.rst +++ b/.github/CONTRIBUTING.rst @@ -151,34 +151,33 @@ We highly recommend to develop using the latest Python 3 release because ``attrs First create a `virtual environment `_. It’s out of scope for this document to list all the ways to manage virtual environments in Python but if you don’t have already a pet way, take some time to look at tools like `pew `_, `virtualfish `_, and `virtualenvwrapper `_. -Next get an up to date checkout of the ``attrs`` repository: +Next, get an up to date checkout of the ``attrs`` repository: .. code-block:: bash - git checkout git@github.com:python-attrs/attrs.git + $ git checkout git@github.com:python-attrs/attrs.git -Change into the newly created directory and **after activating your virtual environment** install an editable version of ``attrs``: +Change into the newly created directory and **after activating your virtual environment** install an editable version of ``attrs`` along with its tests and docs requirements: .. code-block:: bash - cd attrs - pip install -e . - -If you run the virtual environment’s Python and try to ``import attr`` it should work! - -To run the test suite, you'll need our development dependencies which can be installed using - -.. code-block:: bash - - pip install -r dev-requirements.txt + $ cd attrs + $ pip install -e .[dev] At this point .. code-block:: bash - python -m pytest + $ python -m pytest -should work and pass! +should work and pass, as should: + +.. code-block:: bash + + $ cd docs + $ make html + +The built documentation can then be found in ``docs/_build/html/``. Governance @@ -205,7 +204,7 @@ Thank you for considering contributing to ``attrs``! .. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/ .. _`PEP 257`: https://www.python.org/dev/peps/pep-0257/ .. _`good test docstrings`: https://jml.io/pages/test-docstrings.html -.. _`Code of Conduct`: https://github.com/python-attrs/attrs/blob/master/CODE_OF_CONDUCT.rst +.. _`Code of Conduct`: https://github.com/python-attrs/attrs/blob/master/.github/CODE_OF_CONDUCT.rst .. _changelog: https://github.com/python-attrs/attrs/blob/master/CHANGELOG.rst .. _`backward compatibility`: http://www.attrs.org/en/latest/backward-compatibility.html .. _tox: https://tox.readthedocs.io/ diff --git a/MANIFEST.in b/MANIFEST.in index 1ebde1bd..33b07a82 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,7 @@ include LICENSE *.rst *.toml exclude .github/*.md .travis.yml # Tests -include tox.ini .coveragerc conftest.py dev-requirements.txt docs-requirements.txt +include tox.ini .coveragerc conftest.py docs-requirements.txt recursive-include tests *.py recursive-include .github *.rst diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index bbd6b920..00000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -coverage -hypothesis -pympler -pytest -six -zope.interface diff --git a/docs-requirements.txt b/docs-requirements.txt index c473e1e4..142b6ca3 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -1,3 +1 @@ --e . -sphinx -zope.interface +-e .[docs] diff --git a/setup.py b/setup.py index 232d3f5e..a269c27c 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,21 @@ CLASSIFIERS = [ "Topic :: Software Development :: Libraries :: Python Modules", ] INSTALL_REQUIRES = [] +EXTRAS_REQUIRE = { + "docs": [ + "sphinx", + "zope.interface", + ], + "tests": [ + "coverage", + "hypothesis", + "pympler", + "pytest", + "six", + "zope.interface", + ], +} +EXTRAS_REQUIRE["dev"] = EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["docs"] ############################################################################### @@ -92,4 +107,5 @@ if __name__ == "__main__": zip_safe=False, classifiers=CLASSIFIERS, install_requires=INSTALL_REQUIRES, + extras_require=EXTRAS_REQUIRE, ) diff --git a/tox.ini b/tox.ini index e02c3301..fea96ead 100644 --- a/tox.ini +++ b/tox.ini @@ -7,17 +7,17 @@ envlist = isort,py27,py34,py35,py36,pypy,pypy3,flake8,manifest,docs,readme,chang # https://github.com/pypa/setuptools/issues/1042 from breaking our builds. setenv = VIRTUALENV_NO_DOWNLOAD=1 -deps = -rdev-requirements.txt +deps = .[tests] commands = python -m pytest {posargs} [testenv:py27] -deps = -rdev-requirements.txt +deps = .[tests] commands = coverage run --parallel -m pytest {posargs} [testenv:py36] -deps = -rdev-requirements.txt +deps = .[tests] commands = coverage run --parallel -m pytest {posargs} @@ -35,7 +35,7 @@ commands = basepython = python3.6 # Needs a full install so isort can determine own/foreign imports. deps = - -rdev-requirements.txt + .[tests] flake8 flake8-isort commands = flake8 src tests setup.py conftest.py docs/conf.py @@ -45,7 +45,7 @@ commands = flake8 src tests setup.py conftest.py docs/conf.py basepython = python3.6 # Needs a full install so isort can determine own/foreign imports. deps = - -rdev-requirements.txt + .[tests] isort commands = isort --recursive setup.py conftest.py src tests @@ -55,7 +55,7 @@ commands = basepython = python3.6 setenv = PYTHONHASHSEED = 0 -deps = -rdocs-requirements.txt +deps = .[docs] commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html