Skip to content

Commit 541d4f3

Browse files
committed
Update conda & scons recipes for macOS
1 parent 757b436 commit 541d4f3

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

SConstruct

+27-17
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@ import os
2020
from os.path import join as pjoin
2121
import platform
2222

23+
2324
def subdictionary(d, keyset):
2425
return dict(kv for kv in d.items() if kv[0] in keyset)
2526

27+
2628
def getsyspaths(*names):
2729
pall = sum((os.environ.get(n, '').split(os.pathsep) for n in names), [])
2830
rv = [p for p in pall if os.path.exists(p)]
2931
return rv
3032

33+
3134
# copy system environment variables related to compilation
3235
DefaultEnvironment(ENV=subdictionary(os.environ, '''
3336
PATH CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
3437
LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
3538
MACOSX_DEPLOYMENT_TARGET
3639
'''.split())
37-
)
40+
)
3841

3942
# Create construction environment
4043
env = DefaultEnvironment().Clone()
@@ -45,6 +48,8 @@ env.EnsureSConsVersion(0, 98, 1)
4548
# Customizable compile variables
4649
vars = Variables('sconsvars.py')
4750

51+
# TODO: also amend paths when VIRTUAL_ENV variable exists,
52+
# if CONDA_PREFIX does not exist ?
4853
if 'CONDA_PREFIX' in os.environ:
4954
# building for a conda environment
5055
vars.Add(PathVariable(
@@ -56,18 +61,18 @@ if 'CONDA_PREFIX' in os.environ:
5661
vars.Add(PathVariable(
5762
'libdir',
5863
'installation directory for compiled library [prefix/Library/lib]',
59-
pjoin(env['prefix'],'Library', 'Lib'),
64+
pjoin(env['prefix'], 'Library', 'Lib'),
6065
PathVariable.PathAccept))
6166
vars.Add(PathVariable(
6267
'includedir',
6368
'installation directory for C++ header files [prefix/Library/include]',
64-
pjoin(env['prefix'],'Library', 'include'),
69+
pjoin(env['prefix'], 'Library', 'include'),
6570
PathVariable.PathAccept))
6671
else:
6772
vars.Add(PathVariable(
6873
'libdir',
6974
'installation directory for compiled library [prefix/lib]',
70-
pjoin(env['prefix'], 'Lib'),
75+
pjoin(env['prefix'], 'lib'),
7176
PathVariable.PathAccept))
7277
vars.Add(PathVariable(
7378
'includedir',
@@ -111,22 +116,27 @@ env.Help(MY_SCONS_HELP % vars.GenerateHelpText(env))
111116
if platform.system().lower() == "windows":
112117
# See https://scons.org/faq.html#Linking_on_Windows_gives_me_an_error
113118
env['ENV']['TMP'] = os.environ['TMP']
114-
# the CPPPATH directories are checked by scons dependency scanner
115-
cpppath = getsyspaths('CPLUS_INCLUDE_PATH', 'CPATH')
116-
env.AppendUnique(CPPPATH=cpppath)
117-
# Insert LIBRARY_PATH explicitly because some compilers
118-
# ignore it in the system environment.
119-
env.PrependUnique(LIBPATH=getsyspaths('LIBRARY_PATH'))
120-
if 'CONDA_PREFIX' in os.environ:
121-
env.Append(CPPPATH=pjoin(os.environ['CONDA_PREFIX'],'include'))
122-
env.Append(CPPPATH=pjoin(os.environ['CONDA_PREFIX'],'Library','include'))
123-
env.Append(LIBPATH=pjoin(os.environ['CONDA_PREFIX'],'Library','lib'))
124-
# This disable automated versioned named e.g. libboost_date_time-vc142-mt-s-x64-1_73.lib
125-
# so we can use conda-installed libraries
126-
env.AppendUnique(CPPDEFINES='BOOST_ALL_NO_LIB')
127119
# Prevent the generation of an import lib (.lib) in addition to the dll
128120
# Unused as we are using as static library for windows
129121
# env.AppendUnique(no_import_lib=1)
122+
if 'CONDA_PREFIX' in os.environ:
123+
env.Append(CPPPATH=pjoin(os.environ['CONDA_PREFIX'], 'include'))
124+
env.Append(CPPPATH=pjoin(os.environ['CONDA_PREFIX'], 'Library', 'include'))
125+
env.Append(LIBPATH=pjoin(os.environ['CONDA_PREFIX'], 'Library', 'lib'))
126+
else:
127+
if 'CONDA_PREFIX' in os.environ:
128+
env.Append(CPPPATH=pjoin(os.environ['CONDA_PREFIX'], 'include'))
129+
env.Append(LIBPATH=pjoin(os.environ['CONDA_PREFIX'], 'lib'))
130+
131+
# the CPPPATH directories are checked by scons dependency scanner
132+
cpppath = getsyspaths('CPLUS_INCLUDE_PATH', 'CPATH')
133+
env.AppendUnique(CPPPATH=cpppath)
134+
# Insert LIBRARY_PATH explicitly because some compilers
135+
# ignore it in the system environment.
136+
env.PrependUnique(LIBPATH=getsyspaths('LIBRARY_PATH'))
137+
# This disable automated versioned named e.g. libboost_date_time-vc142-mt-s-x64-1_73.lib
138+
# so we can use conda-installed libraries
139+
env.AppendUnique(CPPDEFINES='BOOST_ALL_NO_LIB')
130140

131141
builddir = env.Dir('build/%s-%s' % (env['build'], platform.machine()))
132142

conda-recipe/conda_build_config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
boost:
22
- 1.67
3+
4+
# only for local build ? see https://github.com/conda/conda-build/issues/4064#issuecomment-702983257
5+
#CONDA_BUILD_SYSROOT:
6+
# - /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

conda-recipe/meta.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package:
77
source:
88
# git_url: https://github.com/diffpy/libobjcryst.git
99
git_url: ..
10+
# path: .. # To build from modified local tree
1011

1112
build:
1213
number: 0

0 commit comments

Comments
 (0)