Skip to content

Commit 5f2f129

Browse files
committed
DEV: resolve distutils extension path lazily.
Avoid multiple target-python queries when not needed.
1 parent 6e93c58 commit 5f2f129

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/extensions/SConscript

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,28 @@ test = env.Alias('test', develop,
3030
'$python -m pyobjcryst.tests.run')
3131
AlwaysBuild(test)
3232

33-
# normal install - trick distutils into using this module.
34-
distmodfile = pyoutput('\n'.join([
35-
"from setuptools import Distribution, Extension",
36-
"ext = Extension('pyobjcryst._pyobjcryst', [])",
37-
"attrs = dict(ext_modules=[ext])",
38-
"dist = Distribution(attrs)",
39-
"bcmd = dist.get_command_obj('build_ext')",
40-
"bcmd.finalize_options()",
41-
"print(bcmd.get_ext_fullpath(ext.name))",
42-
]))
33+
def resolve_distutils_target(target, source, env):
34+
tgt = pyoutput('\n'.join([
35+
"from setuptools import Distribution, Extension",
36+
"ext = Extension('pyobjcryst._pyobjcryst', [])",
37+
"attrs = dict(ext_modules=[ext])",
38+
"dist = Distribution(attrs)",
39+
"bcmd = dist.get_command_obj('build_ext')",
40+
"bcmd.finalize_options()",
41+
"print(bcmd.get_ext_fullpath(ext.name))",
42+
]))
43+
env['distsofile'] = env.File(tgt)
44+
return 0
45+
4346
cmd_install = '$python setup.py install'
4447
if 'prefix' in env:
45-
cmd_install += ' --prefix=' + env['prefix']
48+
cmd_install += ' --prefix=$prefix'
49+
4650
install = env.Alias('install', module, [
47-
Mkdir(os.path.dirname(distmodfile)),
48-
Copy(distmodfile, '$SOURCE'),
49-
Touch(distmodfile),
51+
resolve_distutils_target,
52+
Mkdir('$distsofile.dir'),
53+
Copy('$distsofile', '$SOURCE'),
54+
Touch('$distsofile'),
5055
cmd_install,
5156
])
5257
AlwaysBuild(install)

0 commit comments

Comments
 (0)