8
8
from setuptools .command .build_ext import build_ext
9
9
from distutils .version import LooseVersion
10
10
11
- with Path ("README.md" ).open () as readme_file :
11
+ with ( Path (__file__ ). resolve (). parent / "README.md" ).open () as readme_file :
12
12
long_description = readme_file .read ()
13
13
14
14
@@ -30,31 +30,25 @@ def run(self):
30
30
self .build_extension (ext )
31
31
32
32
def build_extension (self , ext ):
33
- extdir = os .path .abspath (os .path .dirname (self .get_ext_fullpath (ext .name )))
34
-
35
- # required for auto-detection of auxiliary "native" libs
36
- if not extdir .endswith (os .path .sep ):
37
- extdir += os .path .sep
33
+ ext_dir = Path (self .get_ext_fullpath (ext .name )).parent .resolve ()
38
34
39
35
build_type = os .environ .get ("BUILD_TYPE" , "Release" )
40
36
build_args = ["--config" , build_type ]
41
37
42
38
cmake_args = [
43
- "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir ,
39
+ "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}/" . format ( ext_dir ) ,
44
40
"-DPYTHON_EXECUTABLE={}" .format (sys .executable ),
45
41
"-DEXAMPLE_VERSION_INFO={}" .format (self .distribution .get_version ()),
46
- "-DCMAKE_BUILD_TYPE=" + build_type ,
47
- "-DUSE_PYTHON_EXTENSION=OFF" ,
42
+ "-DCMAKE_BUILD_TYPE={}" .format (build_type ),
48
43
"-DBUILD_EXAMPLES=OFF" ,
49
44
"-DBUILD_TESTS=OFF" ,
50
45
"-DBUILD_SHARED_LIBS=OFF" ,
51
46
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" ,
52
- "-DCMAKE_INSTALL_RPATH={}" . format ( " $ORIGIN") ,
47
+ "-DCMAKE_INSTALL_RPATH=$ORIGIN" ,
53
48
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON" ,
54
49
]
55
50
56
- if not os .path .exists (self .build_temp ):
57
- os .makedirs (self .build_temp )
51
+ Path (self .build_temp ).mkdir (exist_ok = True , parents = True )
58
52
59
53
subprocess .check_call (["cmake" , str (Path ("." ).resolve ())] + cmake_args , cwd = self .build_temp )
60
54
subprocess .check_call (["cmake" , "--build" , "." , "--target" , "_franky" ] + build_args , cwd = self .build_temp )
0 commit comments