3030import sys
3131
3232try :
33+ # noinspection PyPackageRequirements
3334 from Cython .Build import cythonize
3435except ImportError :
3536 cythonize = None
3637
3738import setuptools
3839
39- with open (
40- os .path .join (
41- os .path .dirname (__file__ ),
42- 'exec_helpers' , '__init__.py'
43- )
44- ) as f :
40+ with open (os .path .join (os .path .dirname (__file__ ), "exec_helpers" , "__init__.py" )) as f :
4541 source = f .read ()
4642
47- with open (' requirements.txt' ) as f :
43+ with open (" requirements.txt" ) as f :
4844 required = f .read ().splitlines ()
4945
50- with open (' README.rst' , ) as f :
46+ with open (" README.rst" ) as f :
5147 long_description = f .read ()
5248
5349
5450def _extension (modpath ):
5551 """Make setuptools.Extension."""
56- source_path = modpath .replace ('.' , '/' ) + ' .py'
52+ source_path = modpath .replace ("." , "/" ) + " .py"
5753 return setuptools .Extension (modpath , [source_path ])
5854
5955
6056requires_optimization = [
61- _extension (' exec_helpers.api' ),
62- _extension (' exec_helpers.constants' ),
63- _extension (' exec_helpers._log_templates' ),
64- _extension (' exec_helpers.exceptions' ),
65- _extension (' exec_helpers.exec_result' ),
66- _extension (' exec_helpers.proc_enums' ),
67- _extension (' exec_helpers._ssh_client_base' ),
68- _extension (' exec_helpers.ssh_auth' ),
69- _extension (' exec_helpers.ssh_client' ),
70- _extension (' exec_helpers.subprocess_runner' ),
57+ _extension (" exec_helpers.api" ),
58+ _extension (" exec_helpers.constants" ),
59+ _extension (" exec_helpers._log_templates" ),
60+ _extension (" exec_helpers.exceptions" ),
61+ _extension (" exec_helpers.exec_result" ),
62+ _extension (" exec_helpers.proc_enums" ),
63+ _extension (" exec_helpers._ssh_client_base" ),
64+ _extension (" exec_helpers.ssh_auth" ),
65+ _extension (" exec_helpers.ssh_client" ),
66+ _extension (" exec_helpers.subprocess_runner" ),
7167]
7268
73- if 'win32' != sys .platform :
74- requires_optimization .append (
75- _extension ('exec_helpers.__init__' )
76- )
69+ if "win32" != sys .platform :
70+ requires_optimization .append (_extension ("exec_helpers.__init__" ))
7771
78- ext_modules = cythonize (
79- requires_optimization ,
80- compiler_directives = dict (
81- always_allow_keywords = True ,
82- binding = True ,
83- embedsignature = True ,
84- overflowcheck = True ,
85- language_level = 3 ,
72+ # noinspection PyCallingNonCallable
73+ ext_modules = (
74+ cythonize (
75+ requires_optimization ,
76+ compiler_directives = dict (
77+ always_allow_keywords = True , binding = True , embedsignature = True , overflowcheck = True , language_level = 3
78+ ),
8679 )
87- ) if cythonize is not None else []
80+ if cythonize is not None
81+ else []
82+ )
8883
8984
9085class BuildFailed (Exception ):
9186 """For install clear scripts."""
87+
9288 pass
9389
9490
@@ -102,12 +98,10 @@ def run(self):
10298
10399 # Copy __init__.py back to repair package.
104100 build_dir = os .path .abspath (self .build_lib )
105- root_dir = os .path .abspath (os .path .join (__file__ , '..' ))
101+ root_dir = os .path .abspath (os .path .join (__file__ , ".." ))
106102 target_dir = build_dir if not self .inplace else root_dir
107103
108- src_files = (
109- os .path .join ('exec_helpers' , '__init__.py' ),
110- )
104+ src_files = (os .path .join ("exec_helpers" , "__init__.py" ),)
111105
112106 for src_file in src_files :
113107 src = os .path .join (root_dir , src_file )
@@ -117,7 +111,7 @@ def run(self):
117111 shutil .copyfile (src , dst )
118112 except (
119113 distutils .errors .DistutilsPlatformError ,
120- getattr (globals ()[' __builtins__' ], ' FileNotFoundError' , OSError )
114+ getattr (globals ()[" __builtins__" ], " FileNotFoundError" , OSError ),
121115 ):
122116 raise BuildFailed ()
123117
@@ -129,7 +123,7 @@ def build_extension(self, ext):
129123 distutils .errors .CCompilerError ,
130124 distutils .errors .DistutilsExecError ,
131125 distutils .errors .DistutilsPlatformError ,
132- ValueError
126+ ValueError ,
133127 ):
134128 raise BuildFailed ()
135129
@@ -181,11 +175,7 @@ def get_simple_vars_from_src(src):
181175 >>> get_simple_vars_from_src(multiple_assign)
182176 OrderedDict([('e', 1), ('f', 1), ('g', 1)])
183177 """
184- ast_data = (
185- ast .Str , ast .Num ,
186- ast .List , ast .Set , ast .Dict , ast .Tuple ,
187- ast .Bytes , ast .NameConstant ,
188- )
178+ ast_data = (ast .Str , ast .Num , ast .List , ast .Set , ast .Dict , ast .Tuple , ast .Bytes , ast .NameConstant )
189179
190180 tree = ast .parse (src )
191181
@@ -197,9 +187,7 @@ def get_simple_vars_from_src(src):
197187 try :
198188 if isinstance (node .value , ast_data ):
199189 value = ast .literal_eval (node .value )
200- elif isinstance ( # NameConstant in python < 3.4
201- node .value , ast .Name
202- ) and isinstance (
190+ elif isinstance (node .value , ast .Name ) and isinstance ( # NameConstant in python < 3.4
203191 node .value .ctx , ast .Load # Read constant
204192 ):
205193 value = ast .literal_eval (node .value )
@@ -208,84 +196,64 @@ def get_simple_vars_from_src(src):
208196 except ValueError :
209197 continue
210198 for tgt in node .targets :
211- if isinstance (
212- tgt , ast .Name
213- ) and isinstance (
214- tgt .ctx , ast .Store
215- ):
199+ if isinstance (tgt , ast .Name ) and isinstance (tgt .ctx , ast .Store ):
216200 result [tgt .id ] = value
217201 return result
218202
219203
220204variables = get_simple_vars_from_src (source )
221205
222206classifiers = [
223- 'Development Status :: 5 - Production/Stable' ,
224-
225- 'Intended Audience :: Developers' ,
226- 'Topic :: Software Development :: Libraries :: Python Modules' ,
227-
228- 'License :: OSI Approved :: Apache Software License' ,
229-
230- 'Programming Language :: Python :: 3' ,
231- 'Programming Language :: Python :: 3.4' ,
232- 'Programming Language :: Python :: 3.5' ,
233- 'Programming Language :: Python :: 3.6' ,
234- 'Programming Language :: Python :: 3.7' ,
235-
236- 'Programming Language :: Python :: Implementation :: CPython' ,
237- 'Programming Language :: Python :: Implementation :: PyPy' ,
207+ "Development Status :: 5 - Production/Stable" ,
208+ "Intended Audience :: Developers" ,
209+ "Topic :: Software Development :: Libraries :: Python Modules" ,
210+ "License :: OSI Approved :: Apache Software License" ,
211+ "Programming Language :: Python :: 3" ,
212+ "Programming Language :: Python :: 3.4" ,
213+ "Programming Language :: Python :: 3.5" ,
214+ "Programming Language :: Python :: 3.6" ,
215+ "Programming Language :: Python :: 3.7" ,
216+ "Programming Language :: Python :: Implementation :: CPython" ,
217+ "Programming Language :: Python :: Implementation :: PyPy" ,
238218]
239219
240- keywords = [
241- 'logging' ,
242- 'debugging' ,
243- 'development' ,
244- ]
220+ keywords = ["logging" , "debugging" , "development" ]
245221
246222setup_args = dict (
247- name = 'exec-helpers' ,
248- author = variables ['__author__' ],
249- author_email = variables ['__author_email__' ],
250- maintainer = ', ' .join (
251- '{name} <{email}>' .format (name = name , email = email )
252- for name , email in variables ['__maintainers__' ].items ()
223+ name = "exec-helpers" ,
224+ author = variables ["__author__" ],
225+ author_email = variables ["__author_email__" ],
226+ maintainer = ", " .join (
227+ "{name} <{email}>" .format (name = name , email = email ) for name , email in variables ["__maintainers__" ].items ()
253228 ),
254- url = variables [' __url__' ],
255- version = variables [' __version__' ],
256- license = variables [' __license__' ],
257- description = variables [' __description__' ],
229+ url = variables [" __url__" ],
230+ version = variables [" __version__" ],
231+ license = variables [" __license__" ],
232+ description = variables [" __description__" ],
258233 long_description = long_description ,
259234 classifiers = classifiers ,
260235 keywords = keywords ,
261- python_requires = ' >=3.4' ,
236+ python_requires = " >=3.4" ,
262237 # While setuptools cannot deal with pre-installed incompatible versions,
263238 # setting a lower bound is not harmful - it makes error messages cleaner. DO
264239 # NOT set an upper bound on setuptools, as that will lead to uninstallable
265240 # situations as progressive releases of projects are done.
266241 # Blacklist setuptools 34.0.0-34.3.2 due to https://github.com/pypa/setuptools/issues/951
267242 # Blacklist setuptools 36.2.0 due to https://github.com/pypa/setuptools/issues/1086
268243 setup_requires = "setuptools >= 21.0.0,!=24.0.0,"
269- "!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
270- "!=36.2.0" ,
244+ "!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
245+ "!=36.2.0" ,
271246 install_requires = required ,
272- package_data = {
273- 'exec_helpers' : ['py.typed' ],
274- },
247+ package_data = {"exec_helpers" : ["py.typed" ]},
275248)
276249if cythonize is not None :
277- setup_args [' ext_modules' ] = ext_modules
278- setup_args [' cmdclass' ] = dict (build_ext = AllowFailRepair )
250+ setup_args [" ext_modules" ] = ext_modules
251+ setup_args [" cmdclass" ] = dict (build_ext = AllowFailRepair )
279252
280253try :
281254 setuptools .setup (** setup_args )
282255except BuildFailed :
283- print (
284- '*' * 80 + '\n '
285- '* Build Failed!\n '
286- '* Use clear scripts version.\n '
287- '*' * 80 + '\n '
288- )
289- del setup_args ['ext_modules' ]
290- del setup_args ['cmdclass' ]
256+ print ("*" * 80 + "\n " "* Build Failed!\n " "* Use clear scripts version.\n " "*" * 80 + "\n " )
257+ del setup_args ["ext_modules" ]
258+ del setup_args ["cmdclass" ]
291259 setuptools .setup (** setup_args )
0 commit comments