33import sys
44
55from setuptools import setup , find_packages , Extension
6+ from setuptools .command .build_ext import build_ext
67
78LIBUAST_VERSION = "v1.3.0"
89SDK_VERSION = "v1.4.2"
910SDK_MAJOR = SDK_VERSION .split ('.' )[0 ]
1011PYTHON = "python3"
1112
1213
14+ libraries = ['xml2' ]
15+ sources = ['bblfsh/pyuast.c' ]
16+
17+
18+ class CustomBuildExt (build_ext ):
19+ def run (self ):
20+ global libraries
21+ global sources
22+
23+ if "--global-uast" in sys .argv :
24+ libraries .append ('uast' )
25+ else :
26+ sources .append ('bblfsh/libuast/uast.c' )
27+ sources .append ('bblfsh/libuast/roles.c' )
28+
29+ getLibuast ()
30+ build_ext .run (self )
31+
32+
1333def runc (cmd ):
1434 cmd = cmd .format (** globals ())
1535 print (cmd )
@@ -90,9 +110,6 @@ def clean():
90110
91111
92112def main ():
93- libraries = ['xml2' ]
94- sources = ['bblfsh/pyuast.c' ]
95-
96113 # The --global-uast flag allows to install the python driver using the installed uast library
97114 if "--getdeps" in sys .argv :
98115 doGetDeps ()
@@ -102,12 +119,6 @@ def main():
102119 clean ()
103120 sys .exit (0 )
104121
105- if "--global-uast" in sys .argv :
106- libraries .append ('uast' )
107- else :
108- sources .append ('bblfsh/libuast/uast.c' )
109- sources .append ('bblfsh/libuast/roles.c' )
110-
111122 # download c dependencies
112123 if not os .path .exists ("bblfsh/libuast" ):
113124 doGetDeps ()
@@ -121,9 +132,12 @@ def main():
121132 '/usr/include' , '/usr/include/libxml2' ], sources = sources )
122133
123134 setup (
135+ cmdclass = {
136+ "build_ext" : CustomBuildExt ,
137+ },
124138 name = "bblfsh" ,
125139 description = "Fetches Universal Abstract Syntax Trees from Babelfish." ,
126- version = "2.3.0 " ,
140+ version = "2.3.1 " ,
127141 license = "Apache 2.0" ,
128142 author = "source{d}" ,
129143 author_email = "language-analysis@sourced.tech" ,
0 commit comments