Ticket #3696: extras_require-3696-2.diff

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

extra_requires implementation, tests, news file

  • 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 9566039..1ff46d0 100644
    twisted_subprojects = ["conch", "lore", "mail", "names", 
    5050                       "words"]
    5151
    5252
     53# extras_require is a dictionary of items that can be passed to setup.py
     54# to install optional dependencies. For example, to install the optional
     55# dev dependencies one would type `pip install -e . "twisted[dev]"`
     56# This has been supported by setuptools since 0.5a4
     57EXTRAS_REQUIRE = dict(
     58    docs = ['sphinx >= 1.2.2',
     59            'pydoctor >= 0.5'],
     60    dev = ['twistedchecker >= 0.2.0',
     61           'pyflakes >= 0.8.1',
     62           'twisted-dev-tools >= 0.0.2'],
     63    ssl = ['pyopenssl',
     64           'service_identity',
     65           'PyCrypto'],
     66    conch = ['gmpy', 'pyasn1'],
     67    subunit = ['python-subunit'],
     68    soap = ['soappy'],
     69    windows = ['pywin32'],
     70    cocoa = ['pyobjc'],
     71    serial = ['pyserial'],
     72    gtk = ['PyGTK'],
     73    pam = ['pam'],
     74    wx = ['wxPython'],
     75)
     76
    5377
    5478class ConditionalExtension(Extension):
    5579    """
  • twisted/python/test/test_dist.py

    diff --git twisted/python/test/test_dist.py twisted/python/test/test_dist.py
    index d2288ee..17954d3 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 OptionalDependenciesTest(TestCase):
     62    """
     63    Tests for L{dist.EXTRA_REQUIRES}
     64
     65    Test whether or not the setuptools generates the correct Distribution
     66    object when extra_requires are passed to it. As long as the distribution
     67    object looks correct, it *should* generate the correct egg_info.
     68    """
     69    def test_distributeTakesExtrasRequire(self):
     70        """
     71        Test that setuptools Distribtution object can use extra_requires.
     72        """
     73        attrs = dict(extras_require=EXTRAS_REQUIRE)
     74        dist = Distribution(attrs)
     75        self.assertEqual(dist.extras_require, EXTRAS_REQUIRE)
     76
    6177
    6278class GetExtensionsTest(TestCase):
    6379    """
  • new file twisted/topfiles/3696.misc

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