Ticket #3696: extras_require-3696-8.diff

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

fix _extra_options, add full stop

  • 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..1cf4b73 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    windows=['pywin32'],
     71    osx=['pyobjc']
     72)
     73
     74_platform_independent = [
     75    _extra_options['dev'],
     76    _extra_options['tls'],
     77    _extra_options['conch'],
     78    _extra_options['soap'],
     79    _extra_options['serial'],
     80]
     81
     82# extras_require is a dictionary of items that can be passed to setup.py
     83# to install optional dependencies. For example, to install the optional
     84# dev dependencies one would type `pip install -e . "twisted[dev]"`
     85# This has been supported by setuptools since 0.5a4
     86EXTRAS_REQUIRE = {
     87    'dev': _extra_options['dev'],
     88    'tls': _extra_options['tls'],
     89    'conch': _extra_options['conch'],
     90    'soap': _extra_options['soap'],
     91    'serial': _extra_options['serial'],
     92    'all_non_plat': _platform_independent,
     93    'windows_plat': [
     94        _extra_options['windows'],
     95        _platform_independent
     96    ],
     97    'osx_plat': [
     98        _extra_options['osx'],
     99        _platform_independent
     100    ],
     101}
    52102
    53103
    54104class ConditionalExtension(Extension):
  • twisted/python/test/test_dist.py

    diff --git twisted/python/test/test_dist.py twisted/python/test/test_dist.py
    index d2288ee..827ad7a 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    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' Distribution 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
     77    def test_extrasRequireDictContainsKeys(self):
     78        """
     79        Test that the L{dist.EXTRA_REQUIRES} dictionary contains all of the
     80        expected keys.
     81        """
     82        self.assertIn('dev', EXTRAS_REQUIRE)
     83        self.assertIn('tls', EXTRAS_REQUIRE)
     84        self.assertIn('conch', EXTRAS_REQUIRE)
     85        self.assertIn('soap', EXTRAS_REQUIRE)
     86        self.assertIn('serial', EXTRAS_REQUIRE)
     87        self.assertIn('all_non_plat', EXTRAS_REQUIRE)
     88        self.assertIn('windows_plat', EXTRAS_REQUIRE)
     89        self.assertIn('osx_plat', EXTRAS_REQUIRE)
     90
    6191
    6292class GetExtensionsTest(TestCase):
    6393    """
  • new file twisted/topfiles/3696.misc

    diff --git twisted/topfiles/3696.misc twisted/topfiles/3696.misc
    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