Ticket #3696: extras_require-3696-12.diff

File extras_require-3696-12.diff, 11.7 KB (added by Chris Wolfe, 5 years ago)

reduction

  • docs/index.rst

    diff --git docs/index.rst docs/index.rst
    index 1172a49..a4eaf5f 100644
    Contents: 
    77    :maxdepth: 2
    88    :includehidden:
    99
     10    installation/index
    1011    core/index
    1112    conch/index
    1213    lore/index
  • new file docs/installation/howto/optional.rst

    diff --git docs/installation/howto/optional.rst docs/installation/howto/optional.rst
    new file mode 100644
    index 0000000..a92343e
    - +  
     1
     2:LastChangedDate: $LastChangedDate$
     3:LastChangedRevision: $LastChangedRevision$
     4:LastChangedBy: $LastChangedBy$
     5
     6Installing Optional Dependencies
     7================================
     8
     9This document describes the optional dependencies that Twisted supports.
     10The dependencies are python packages that Twisted's developers have found useful either for developing Twisted itself or for developing Twisted applications.
     11
     12The intended audience of this document is someone who is familiar with installing optional dependencies using `pip`_.
     13
     14If you are unfamiliar with the installation of optional dependencies, the `python packaging tutorial`_ can show you how.
     15For a deeper explanation of what optional dependencies are and how they are declared, please see the `setuptools documentation`_.
     16
     17The following optional dependencies are supported:
     18
     19* **dev** - packages that aid in the development of Twisted itself.
     20    * `TwistedChecker`_
     21    * `pyflakes`_
     22    * `twisted-dev-tools`_
     23    * `python-subunit`_
     24    * `Sphinx`_
     25    * `pydoctor`_
     26
     27* **tls** - packages that are needed to work with TLS.
     28    * `pyOpenSSL`_
     29    * `service_identity`_
     30
     31* **conch** - packages for working with conch/SSH.
     32    * `gmpy`_
     33    * `pyasn1`_
     34    * `pycrypto`_
     35
     36* **soap** - the `SOAPpy`_ package to work with SOAP.
     37
     38* **serial** - the `pyserial`_ package to work with serial data.
     39
     40* **all_non_platform** - installs **tls**, **conch**, **soap**, and **serial** options.
     41
     42* **osx_platform** - **all_non_platform** options and `pyobjc`_ to work with Objective-C apis.
     43
     44* **windows_platform** - **all_non_platform** options and `pypiwin32`_ to work with Windows's apis.
     45
     46.. _pip: https://pip.pypa.io/en/latest/quickstart.html
     47.. _TwistedChecker: https://pypi.python.org/pypi/TwistedChecker
     48.. _pyflakes: https://pypi.python.org/pypi/pyflakes
     49.. _twisted-dev-tools: https://pypi.python.org/pypi/twisted-dev-tools
     50.. _python-subunit: https://pypi.python.org/pypi/python-subunit
     51.. _Sphinx: https://pypi.python.org/pypi/Sphinx/1.3b1
     52.. _pydoctor: https://pypi.python.org/pypi/pydoctor
     53.. _pyOpenSSL: https://pypi.python.org/pypi/pyOpenSSL
     54.. _service_identity: https://pypi.python.org/pypi/service_identity
     55.. _gmpy: https://pypi.python.org/pypi/gmpy/1.17
     56.. _pyasn1: https://pypi.python.org/pypi/pyasn1
     57.. _pycrypto: https://pypi.python.org/pypi/pycrypto
     58.. _SOAPpy: https://pypi.python.org/pypi/SOAPpy
     59.. _pyserial: https://pypi.python.org/pypi/pyserial
     60.. _pyobjc: https://pypi.python.org/pypi/pyobjc
     61.. _pypiwin32: https://pypi.python.org/pypi/pypiwin32
     62.. _`setuptools documentation`: https://pythonhosted.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
     63.. _`python packaging tutorial`: https://packaging.python.org/en/latest/installing.html#examples
  • new file docs/installation/index.rst

    diff --git docs/installation/index.rst docs/installation/index.rst
    new file mode 100644
    index 0000000..16617e2
    - +  
     1
     2:LastChangedDate: $LastChangedDate$
     3:LastChangedRevision: $LastChangedRevision$
     4:LastChangedBy: $LastChangedBy$
     5
     6Installing Twisted
     7==================
     8
     9.. toctree::
     10   :hidden:
     11
     12   howto/optional
     13
     14- :doc:`Installing Optional Dependencies <howto/optional>`: documentation on how to install Twisted's optional dependencies.
  • setup.py

    diff --git setup.py setup.py
    index 26f052b..e63f1b5 100755
    dependency resolution is disabled. 
    5454
    5555    from twisted.python.dist import (
    5656        STATIC_PACKAGE_METADATA, getDataFiles, getExtensions, getAllScripts,
    57         getPackages, setup)
     57        getPackages, setup, EXTRAS_REQUIRE)
    5858
    5959    scripts = getAllScripts()
    6060
    dependency resolution is disabled. 
    6262        packages=getPackages('twisted'),
    6363        conditionalExtensions=getExtensions(),
    6464        scripts=scripts,
     65        extras_require=EXTRAS_REQUIRE,
    6566        data_files=getDataFiles('twisted'),
    6667        **STATIC_PACKAGE_METADATA))
    6768
  • twisted/python/dist.py

    diff --git twisted/python/dist.py twisted/python/dist.py
    index 63b36b3..ae46d17 100644
    twisted_subprojects = ["conch", "lore", "mail", "names", 
    4949                       "news", "pair", "runner", "web",
    5050                       "words"]
    5151
     52# These are the actual package names and versions that will
     53# be used by extras_require. This is not passed to setup
     54# directly so that combinations of the packages can be created
     55# without the need to copy package names multiple times.
     56_extra_options = dict(
     57    dev=['twistedchecker >= 0.2.0',
     58         'pyflakes >= 0.8.1',
     59         'twisted-dev-tools >= 0.0.2',
     60         'python-subunit',
     61         'sphinx >= 1.2.2',
     62         'pydoctor >= 0.5'],
     63    tls=['pyopenssl >= 0.11',
     64         'service_identity'],
     65    conch=['gmpy',
     66           'pyasn1',
     67           'pycrypto'],
     68    soap=['soappy'],
     69    serial=['pyserial'],
     70    osx=['pyobjc'],
     71    windows=['pypiwin32']
     72)
     73
     74_platform_independent = (
     75    _extra_options['tls'] +
     76    _extra_options['conch'] +
     77    _extra_options['soap'] +
     78    _extra_options['serial']
     79)
     80
     81# extras_require is a dictionary of items that can be passed to setup.py
     82# to install optional dependencies. For example, to install the optional
     83# dev dependencies one would type `pip install -e ".[dev]"`
     84# This has been supported by setuptools since 0.5a4
     85EXTRAS_REQUIRE = {
     86    'dev': _extra_options['dev'],
     87    'tls': _extra_options['tls'],
     88    'conch': _extra_options['conch'],
     89    'soap': _extra_options['soap'],
     90    'serial': _extra_options['serial'],
     91    'all_non_platform': _platform_independent,
     92    'osx_platform': (
     93        _extra_options['osx'] + _platform_independent
     94    ),
     95    'windows_platform': (
     96        _extra_options['windows'] + _platform_independent
     97    ),
     98}
    5299
    53100
    54101class ConditionalExtension(Extension):
  • twisted/python/test/test_dist.py

    diff --git twisted/python/test/test_dist.py twisted/python/test/test_dist.py
    index d2288ee..5cfccd3 100644
    Tests for parts of our release automation system. 
    99import os
    1010import sys
    1111
    12 from distutils.core import Distribution
     12from setuptools.dist import Distribution
    1313
    1414from twisted.trial.unittest import TestCase
    1515
    1616from twisted.python import dist
    1717from twisted.python.dist import (get_setup_args, ConditionalExtension,
    18     build_scripts_twisted)
     18                                 build_scripts_twisted, EXTRAS_REQUIRE)
    1919from twisted.python.filepath import FilePath
    2020
    2121
    class SetupTest(TestCase): 
    5858        self.assertEqual(ext.define_macros, [("whatever", 2), ("WIN32", 1)])
    5959
    6060
     61class OptionalDependenciesTests(TestCase):
     62    """
     63    Tests for L{dist.EXTRA_REQUIRES}
     64    """
     65    def test_distributeTakesExtrasRequire(self):
     66        """
     67        Setuptools' Distribution object can use extra_requires.
     68        """
     69        extras = dict(im_an_extra_dependency="thing")
     70        attrs = dict(extras_require=extras)
     71        dist = Distribution(attrs)
     72        self.assertEqual(
     73            extras,
     74            dist.extras_require
     75        )
     76
     77
     78    def test_extrasRequireDictContainsKeys(self):
     79        """
     80        L{dist.EXTRA_REQUIRES} C{dev} option contains a valid
     81        list with correct dependecies.
     82        """
     83        self.assertIn('dev', EXTRAS_REQUIRE)
     84        self.assertIn('tls', EXTRAS_REQUIRE)
     85        self.assertIn('conch', EXTRAS_REQUIRE)
     86        self.assertIn('soap', EXTRAS_REQUIRE)
     87        self.assertIn('serial', EXTRAS_REQUIRE)
     88        self.assertIn('all_non_platform', EXTRAS_REQUIRE)
     89        self.assertIn('osx_platform', EXTRAS_REQUIRE)
     90        self.assertIn('windows_platform', EXTRAS_REQUIRE)
     91
     92
     93    def test_extrasRequiresDevDepsAreValid(self):
     94        """
     95        L{dist.EXTRA_REQUIRES} C{dev} option contains the correct
     96        dependencies.
     97        """
     98        deps = EXTRAS_REQUIRE['dev']
     99        self.assertIn('twistedchecker >= 0.2.0', deps)
     100        self.assertIn('pyflakes >= 0.8.1', deps)
     101        self.assertIn('twisted-dev-tools >= 0.0.2', deps)
     102        self.assertIn('python-subunit', deps)
     103        self.assertIn('sphinx >= 1.2.2', deps)
     104        self.assertIn('pydoctor >= 0.5', deps)
     105
     106
     107    def test_extrasRequiresTlsDepsAreValid(self):
     108        """
     109        L{dist.EXTRA_REQUIRES} C{tls} option contains the correct
     110        dependencies.
     111        """
     112        deps = EXTRAS_REQUIRE['tls']
     113        self.assertIn('pyopenssl >= 0.11', deps)
     114        self.assertIn('service_identity', deps)
     115
     116
     117    def test_extrasRequiresConchDepsAreValid(self):
     118        """
     119        L{dist.EXTRA_REQUIRES} C{conch} option contains the correct
     120        dependencies.
     121        """
     122        deps = EXTRAS_REQUIRE['conch']
     123        self.assertIn('gmpy', deps)
     124        self.assertIn('pyasn1', deps)
     125        self.assertIn('pycrypto', deps)
     126
     127
     128    def test_extrasRequiresSoapDepsAreValid(self):
     129        """
     130        L{dist.EXTRA_REQUIRES} C{soap} option contains the correct
     131        dependecies.
     132        """
     133        self.assertIn(
     134            'soappy',
     135            EXTRAS_REQUIRE['soap']
     136        )
     137
     138
     139    def test_extrasRequiresSerialDepsAreValid(self):
     140        """
     141        L{dist.EXTRA_REQUIRES} C{serial} option contains the correct
     142        dependencies.
     143        """
     144        self.assertIn(
     145            'pyserial',
     146            EXTRAS_REQUIRE['serial']
     147        )
     148
     149
     150    def test_extrasRequiresAllNonPlatformDepsAreValid(self):
     151        """
     152        L{dist.EXTRA_REQUIRES} C{all_non_platform} option contains the
     153        correct dependencies.
     154        """
     155        deps = EXTRAS_REQUIRE['all_non_platform']
     156        self.assertIn('pyopenssl >= 0.11', deps)
     157        self.assertIn('service_identity', deps)
     158        self.assertIn('gmpy', deps)
     159        self.assertIn('pyasn1', deps)
     160        self.assertIn('pycrypto', deps)
     161        self.assertIn('soappy', deps)
     162        self.assertIn('pyserial', deps)
     163
     164
     165    def test_extrasRequiresOsxPlatformDepsAreValid(self):
     166        """
     167        L{dist.EXTRA_REQUIRES} C{osx_platform} option contains the correct
     168        dependecies.
     169        """
     170        deps = EXTRAS_REQUIRE['osx_platform']
     171        self.assertIn('pyopenssl >= 0.11', deps)
     172        self.assertIn('service_identity', deps)
     173        self.assertIn('gmpy', deps)
     174        self.assertIn('pyasn1', deps)
     175        self.assertIn('pycrypto', deps)
     176        self.assertIn('soappy', deps)
     177        self.assertIn('pyserial', deps)
     178        self.assertIn('pyobjc', deps)
     179
     180
     181    def test_extrasRequiresWindowsPlatformDepsAreValid(self):
     182        """
     183        L{dist.EXTRA_REQUIRES} C{windows_platform} option contains the correct
     184        dependecies.
     185        """
     186        deps = EXTRAS_REQUIRE['windows_platform']
     187        self.assertIn('pyopenssl >= 0.11', deps)
     188        self.assertIn('service_identity', deps)
     189        self.assertIn('gmpy', deps)
     190        self.assertIn('pyasn1', deps)
     191        self.assertIn('pycrypto', deps)
     192        self.assertIn('soappy', deps)
     193        self.assertIn('pyserial', deps)
     194        self.assertIn('pypiwin32', deps)
     195
    61196
    62197class GetExtensionsTest(TestCase):
    63198    """
  • new file twisted/topfiles/3696.feature

    diff --git twisted/topfiles/3696.feature twisted/topfiles/3696.feature
    new file mode 100644
    index 0000000..24d3d09
    - +  
     1Optional dependencies can be installed using the extra_requires facility provided by setuptools.
     2 No newline at end of file