Ticket #3696: extras_require-3696-14.diff

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

fix twistedchecker, dependency on setuptools

  • 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..2fec522 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.
     56EXTRA_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
     74PLATFORM_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..5a131f4 100644
    Tests for parts of our release automation system. 
    99import os
    1010import sys
    1111
    12 from distutils.core import Distribution
    1312
    1413from twisted.trial.unittest import TestCase
    1514
    1615from twisted.python import dist
    1716from twisted.python.dist import (get_setup_args, ConditionalExtension,
    18     build_scripts_twisted)
     17                                 build_scripts_twisted, EXTRAS_REQUIRE)
    1918from twisted.python.filepath import FilePath
    2019
     20usesSetuptools = None
     21try:
     22    from setuptools.dist import Distribution
     23    usesSetuptools = True
     24except ImportError:
     25    from disutils.core import Distribution
     26    usesSetuptools = None
     27
    2128
    2229
    2330class SetupTest(TestCase):
    class SetupTest(TestCase): 
    5966
    6067
    6168
     69class OptionalDependenciesTests(TestCase):
     70    """
     71    Tests for L{dist.EXTRA_REQUIRES}
     72    """
     73    if usesSetuptools is None:
     74        skip = "cannot test without setuptools"
     75
     76
     77    def test_distributeTakesExtrasRequire(self):
     78        """
     79        Setuptools' Distribution object can use extra_requires.
     80        """
     81        extras = dict(im_an_extra_dependency="thing")
     82        attrs = dict(extras_require=extras)
     83        distribution = Distribution(attrs)
     84        self.assertEqual(
     85            extras,
     86            distribution.extras_require
     87        )
     88
     89
     90    def test_extrasRequireDictContainsKeys(self):
     91        """
     92        L{dist.EXTRA_REQUIRES} C{dev} option contains a valid
     93        list with correct dependecies.
     94        """
     95        self.assertIn('dev', EXTRAS_REQUIRE)
     96        self.assertIn('tls', EXTRAS_REQUIRE)
     97        self.assertIn('conch', EXTRAS_REQUIRE)
     98        self.assertIn('soap', EXTRAS_REQUIRE)
     99        self.assertIn('serial', EXTRAS_REQUIRE)
     100        self.assertIn('all_non_platform', EXTRAS_REQUIRE)
     101        self.assertIn('osx_platform', EXTRAS_REQUIRE)
     102        self.assertIn('windows_platform', EXTRAS_REQUIRE)
     103
     104
     105    def test_extrasRequiresDevDepsAreValid(self):
     106        """
     107        L{dist.EXTRA_REQUIRES} C{dev} option contains the correct
     108        dependencies.
     109        """
     110        deps = EXTRAS_REQUIRE['dev']
     111        self.assertIn('twistedchecker >= 0.2.0', deps)
     112        self.assertIn('pyflakes >= 0.8.1', deps)
     113        self.assertIn('twisted-dev-tools >= 0.0.2', deps)
     114        self.assertIn('python-subunit', deps)
     115        self.assertIn('sphinx >= 1.2.2', deps)
     116        self.assertIn('pydoctor >= 0.5', deps)
     117
     118
     119    def test_extrasRequiresTlsDepsAreValid(self):
     120        """
     121        L{dist.EXTRA_REQUIRES} C{tls} option contains the correct
     122        dependencies.
     123        """
     124        deps = EXTRAS_REQUIRE['tls']
     125        self.assertIn('pyopenssl >= 0.11', deps)
     126        self.assertIn('service_identity', deps)
     127
     128
     129    def test_extrasRequiresConchDepsAreValid(self):
     130        """
     131        L{dist.EXTRA_REQUIRES} C{conch} option contains the correct
     132        dependencies.
     133        """
     134        deps = EXTRAS_REQUIRE['conch']
     135        self.assertIn('gmpy', deps)
     136        self.assertIn('pyasn1', deps)
     137        self.assertIn('pycrypto', deps)
     138
     139
     140    def test_extrasRequiresSoapDepsAreValid(self):
     141        """
     142        L{dist.EXTRA_REQUIRES} C{soap} option contains the correct
     143        dependecies.
     144        """
     145        self.assertIn(
     146            'soappy',
     147            EXTRAS_REQUIRE['soap']
     148        )
     149
     150
     151    def test_extrasRequiresSerialDepsAreValid(self):
     152        """
     153        L{dist.EXTRA_REQUIRES} C{serial} option contains the correct
     154        dependencies.
     155        """
     156        self.assertIn(
     157            'pyserial',
     158            EXTRAS_REQUIRE['serial']
     159        )
     160
     161
     162    def test_extrasRequiresAllNonPlatformDepsAreValid(self):
     163        """
     164        L{dist.EXTRA_REQUIRES} C{all_non_platform} option contains the
     165        correct dependencies.
     166        """
     167        deps = EXTRAS_REQUIRE['all_non_platform']
     168        self.assertIn('pyopenssl >= 0.11', deps)
     169        self.assertIn('service_identity', deps)
     170        self.assertIn('gmpy', deps)
     171        self.assertIn('pyasn1', deps)
     172        self.assertIn('pycrypto', deps)
     173        self.assertIn('soappy', deps)
     174        self.assertIn('pyserial', deps)
     175
     176
     177    def test_extrasRequiresOsxPlatformDepsAreValid(self):
     178        """
     179        L{dist.EXTRA_REQUIRES} C{osx_platform} option contains the correct
     180        dependecies.
     181        """
     182        deps = EXTRAS_REQUIRE['osx_platform']
     183        self.assertIn('pyopenssl >= 0.11', deps)
     184        self.assertIn('service_identity', deps)
     185        self.assertIn('gmpy', deps)
     186        self.assertIn('pyasn1', deps)
     187        self.assertIn('pycrypto', deps)
     188        self.assertIn('soappy', deps)
     189        self.assertIn('pyserial', deps)
     190        self.assertIn('pyobjc', deps)
     191
     192
     193    def test_extrasRequiresWindowsPlatformDepsAreValid(self):
     194        """
     195        L{dist.EXTRA_REQUIRES} C{windows_platform} option contains the correct
     196        dependecies.
     197        """
     198        deps = EXTRAS_REQUIRE['windows_platform']
     199        self.assertIn('pyopenssl >= 0.11', deps)
     200        self.assertIn('service_identity', deps)
     201        self.assertIn('gmpy', deps)
     202        self.assertIn('pyasn1', deps)
     203        self.assertIn('pycrypto', deps)
     204        self.assertIn('soappy', deps)
     205        self.assertIn('pyserial', deps)
     206        self.assertIn('pypiwin32', deps)
     207
     208
     209
    62210class GetExtensionsTest(TestCase):
    63211    """
    64212    Tests for L{dist.getExtensions}.
  • 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