@@ -115,16 +115,18 @@ def ccompile(self, name, check_duplicate_name=True):
115
115
m .update (block )
116
116
cur_checksum = m .hexdigest ()
117
117
118
+ install_dir = _install_dir_for (name )
119
+
118
120
# see if there is already a checksum file
119
- checksum_file = DIR / f'{ name } { EXT_SUFFIX } .sha256'
121
+ checksum_file = install_dir / f'{ name } { EXT_SUFFIX } .sha256'
120
122
available_checksum = ""
121
123
if checksum_file .exists ():
122
124
# read checksum file
123
125
with open (checksum_file , "r" ) as f :
124
126
available_checksum = f .readline ()
125
127
126
128
# note, the suffix is already a string like '.so'
127
- lib_file = DIR / f'{ name } { EXT_SUFFIX } '
129
+ lib_file = install_dir / f'{ name } { EXT_SUFFIX } '
128
130
129
131
if check_duplicate_name and available_checksum != cur_checksum and name in compiled_registry :
130
132
print (f"\n \n WARNING: module with name '{ name } ' was already compiled, but with different source code. "
@@ -140,7 +142,7 @@ def ccompile(self, name, check_duplicate_name=True):
140
142
if available_checksum != cur_checksum or not lib_file .exists ():
141
143
module = Extension (name , sources = [str (source_file )])
142
144
verbosity = '--verbose' if sys .flags .verbose else '--quiet'
143
- args = [verbosity , 'build' , 'install_lib' , '-f' , f'--install-dir={ DIR } ' , 'clean' ]
145
+ args = [verbosity , 'build' , 'install_lib' , '-f' , f'--install-dir={ install_dir } ' , 'clean' ]
144
146
setup (
145
147
script_name = 'setup' ,
146
148
script_args = args ,
@@ -402,7 +404,7 @@ def __repr__(self):
402
404
return "<CPyExtFunction %s>" % self .name
403
405
404
406
def test (self ):
405
- sys .path .insert (0 , str (DIR ))
407
+ sys .path .insert (0 , str (_install_dir_for ( self . name ) ))
406
408
try :
407
409
cmodule = __import__ (self .name )
408
410
finally :
@@ -509,6 +511,10 @@ def get_value(self, key, args, kwds):
509
511
return Formatter .get_value (key , args , kwds )
510
512
511
513
514
+ def _install_dir_for (name ):
515
+ return DIR / 'build' / name
516
+
517
+
512
518
def _compile_module (c_source , name ):
513
519
source_file = DIR / f'{ name } .c'
514
520
with open (source_file , "wb" , buffering = 0 ) as f :
@@ -521,7 +527,7 @@ def _compile_module(c_source, name):
521
527
except FileNotFoundError :
522
528
raise SystemError ("source file %s not available" % (source_file ,))
523
529
ccompile (None , name )
524
- sys .path .insert (0 , str (DIR ))
530
+ sys .path .insert (0 , str (_install_dir_for ( name ) ))
525
531
try :
526
532
cmodule = __import__ (name )
527
533
finally :
0 commit comments