22
33from __future__ import unicode_literals
44
5+ from codecs import open # pylint:disable=redefined-builtin
6+ from collections import defaultdict
57from os .path import dirname , join
6- import platform
78import sys
8- from sys import version_info
99
1010from setuptools import setup , find_packages
1111from setuptools .command .test import test as TestCommand
3232
3333
3434class PyTest (TestCommand ):
35+ # pylint:disable=attribute-defined-outside-init
36+
3537 user_options = [(b'pytest-args=' , b'a' , b"Arguments to pass to py.test" )]
3638
3739 def initialize_options (self ):
@@ -55,26 +57,45 @@ def main():
5557 install_requires = ['requests>=2.4.3' , 'six>=1.4.0' , 'requests-toolbelt>=0.4.0' ]
5658 redis_requires = ['redis>=2.10.3' ]
5759 jwt_requires = ['pyjwt>=1.3.0' , 'cryptography>=0.9.2' ]
58- if version_info < (3 , 4 ):
59- install_requires .append ('enum34>=1.0.4' )
60- elif version_info < (2 , 7 ):
61- install_requires .append ('ordereddict>=1.1' )
60+ extra_requires = defaultdict (list )
61+ extra_requires .update ({'jwt' : jwt_requires , 'redis' : redis_requires , 'all' : jwt_requires + redis_requires })
62+ conditional_dependencies = {
63+ # Newer versions of pip and wheel, which support PEP 426, allow
64+ # environment markers for conditional dependencies to use operators
65+ # such as `<` and `<=` [1]. However, older versions of pip and wheel
66+ # only support PEP 345, which only allows operators `==` and `in` (and
67+ # their negations) along with string constants [2]. To get the widest
68+ # range of support, we'll only use the `==` operator, which means
69+ # explicitly listing all supported Python versions that need the extra
70+ # dependencies.
71+ #
72+ # [1] <https://www.python.org/dev/peps/pep-0426/#environment-markers>
73+ # [2] <https://www.python.org/dev/peps/pep-0345/#environment-markers>
74+ 'enum34>=1.0.4' : ['2.6' , '2.7' , '3.3' ], # <'3.4'
75+ 'ordereddict>=1.1' : ['2.6' ], # <'2.7'
76+ }
77+ for requirement , python_versions in conditional_dependencies .items ():
78+ for python_version in python_versions :
79+ # <https://wheel.readthedocs.org/en/latest/#defining-conditional-dependencies>
80+ python_conditional = 'python_version=="{0}"' .format (python_version )
81+ key = ':{0}' .format (python_conditional )
82+ extra_requires [key ].append (requirement )
6283 setup (
6384 name = 'boxsdk' ,
6485 version = '1.4.2' ,
6586 description = 'Official Box Python SDK' ,
66- long_description = open (join (base_dir , 'README.rst' )).read (),
87+ long_description = open (join (base_dir , 'README.rst' ), encoding = 'utf-8' ).read (),
6788 author = 'Box' ,
68896990 url = 'http://opensource.box.com' ,
70- packages = find_packages (exclude = ['demo' , 'docs' , 'test' ]),
91+ packages = find_packages (exclude = ['demo' , 'docs' , 'test' , 'test*' , '*test' , '*test*' ]),
7192 install_requires = install_requires ,
72- extras_require = { 'jwt' : jwt_requires , 'redis' : redis_requires , 'all' : jwt_requires + redis_requires } ,
93+ extras_require = extra_requires ,
7394 tests_require = ['pytest' , 'pytest-xdist' , 'mock' , 'sqlalchemy' , 'bottle' , 'jsonpatch' ],
7495 cmdclass = {'test' : PyTest },
7596 classifiers = CLASSIFIERS ,
7697 keywords = 'box oauth2 sdk' ,
77- license = open ( join ( base_dir , ' LICENSE' )). read () ,
98+ license = 'Apache Software License, Version 2.0, http://www.apache.org/licenses/ LICENSE-2.0' ,
7899 )
79100
80101
0 commit comments