1- import sys
21import os
32import platform
4- import fnmatch
53import setuptools
4+ from glob import glob
65
76target = platform .system ().lower ()
87PLATFORMS = {'windows' , 'linux' , 'darwin' , 'cygwin' }
@@ -27,15 +26,15 @@ def run_setup(with_binary):
2726 include_dirs = ["src/systemrdl/parser/ext/antlr4-cpp-runtime" ],
2827
2928 # Rather than listing each C++ file (Antlr has a lot!), discover them automatically
30- sources = get_files ("src/systemrdl/parser/ext" , "* .cpp" ),
31- depends = get_files ("src/systemrdl/parser/ext" , "* .h" ),
29+ sources = glob ("src/systemrdl/parser/ext/**/* .cpp" , recursive = True ),
30+ depends = glob ("src/systemrdl/parser/ext/**/* .h" , recursive = True ),
3231
3332 extra_compile_args = extra_compile_args .get (target , []),
34- define_macros = [("Py_LIMITED_API" , "0x03060000 " )],
33+ define_macros = [("Py_LIMITED_API" , "0x03070000 " )],
3534 py_limited_api = True ,
3635 )
3736 ext_modules = [parser_ext ]
38- options = {"bdist_wheel" : {"py_limited_api" : "cp36 " }}
37+ options = {"bdist_wheel" : {"py_limited_api" : "cp37 " }}
3938 else :
4039 ext_modules = []
4140 options = {}
@@ -50,27 +49,14 @@ def run_setup(with_binary):
5049#===============================================================================
5150from setuptools .command .build_ext import build_ext
5251
53- def get_files (path , pattern ):
54- """
55- Recursive file search that is compatible with python3.4 and older
56- """
57- matches = []
58- for root , _ , filenames in os .walk (path ):
59- for filename in fnmatch .filter (filenames , pattern ):
60- matches .append (os .path .join (root , filename ))
61- return matches
62-
63-
6452class BuildFailed (Exception ):
6553 pass
6654
67-
6855class ve_build_ext (build_ext ):
6956 """
7057 This class extends setuptools to fail with a common BuildFailed exception
7158 if a build fails
7259 """
73-
7460 def run (self ):
7561 try :
7662 build_ext .run (self )
@@ -83,29 +69,15 @@ def build_extension(self, ext):
8369 except Exception :
8470 raise BuildFailed ()
8571
86-
87- # Detect if an alternate interpreter is being used
88- is_jython = "java" in sys .platform
89- is_pypy = hasattr (sys , "pypy_version_info" )
90-
91- # Antlr accelerator is no longer supported on older Python versions
92- is_old_python = sys .version_info [0 :2 ] <= (3 , 5 )
93-
94- # Force using fallback python parser under some conditions
95- using_fallback = is_jython or is_pypy or is_old_python
96-
97- if 'SYSTEMRDL_SKIP_BINARY_BUILD' in os .environ :
98- using_fallback = True
99-
100- if not using_fallback :
101- try :
102- run_setup (with_binary = True )
103- except BuildFailed :
104- if 'SYSTEMRDL_REQUIRE_BINARY_BUILD' in os .environ :
105- # Force failure if binary build is required
106- raise
107- else :
108- using_fallback = True
72+ using_fallback = False
73+ try :
74+ run_setup (with_binary = True )
75+ except BuildFailed :
76+ if 'SYSTEMRDL_REQUIRE_BINARY_BUILD' in os .environ :
77+ # Force failure if binary build is required
78+ raise
79+ else :
80+ using_fallback = True
10981
11082if using_fallback :
11183 run_setup (with_binary = False )
0 commit comments