Skip to content

Commit 87e18b1

Browse files
committed
fixes for macos build
1 parent 9a02f2a commit 87e18b1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

folly/python/setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@
3636
# Define base libraries needed across all platforms
3737
base_libraries = ['folly', 'glog', 'double-conversion', 'fmt']
3838

39+
LD_PATH = 'LD_LIBRARY_PATH'
3940
if sys.platform == 'darwin':
4041
from distutils import sysconfig
4142
cfg_vars = sysconfig.get_config_vars()
4243
for key in ('CFLAGS', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED', 'PY_LDFLAGS', 'PY_CFLAGS', 'PY_CPPFLAGS'):
4344
if key in cfg_vars:
4445
cfg_vars[key] = cfg_vars[key].replace('-mmacosx-version-min=10.9', '-mmacosx-version-min=12')
46+
4547
if platform.machine() == 'arm64':
4648
# Macos (arm64, homebrew path is different than intel)
4749
library_dirs = ['/opt/homebrew/lib']
4850
else:
4951
library_dirs = ['/usr/local/lib', '/usr/lib']
52+
53+
LD_PATH='DYLD_LIBRARY_PATH'
5054
else:
5155
# Debian/Ubuntu
5256
library_dirs = ['/usr/lib', '/usr/lib/x86_64-linux-gnu']
@@ -66,14 +70,14 @@
6670
os.environ['PYTHONPATH'] = pypath
6771

6872
# Add (prepend) library paths from LD_LIBRARY_PATHs
69-
if ldpath := os.environ.get('LD_LIBRARY_PATH'):
73+
if ldpath := os.environ.get(LD_PATH):
7074
ldpaths = ldpath.split(':')
7175
library_dirs[:0] = ldpaths
7276
# make sure folly library path is included
7377
if folly_lib and folly_lib not in ldpaths:
74-
print(f'export LD_LIBRARY_PATH="{folly_lib}:{ldpath}"\n')
78+
print(f'export {LD_PATH}="{folly_lib}:{ldpath}"\n')
7579
else:
76-
print(f'export LD_LIBRARY_PATH="{ldpath}"\n')
80+
print(f'export {LD_PATH}="{ldpath}"\n')
7781

7882
exts = [
7983
Extension(

folly/python/test/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@
1414
# Define base libraries needed across all platforms
1515
base_libraries = ['folly', 'glog', 'double-conversion', 'fmt']
1616

17+
LD_PATH = 'LD_LIBRARY_PATH'
1718
if sys.platform == 'darwin':
1819
from distutils import sysconfig
1920
cfg_vars = sysconfig.get_config_vars()
2021
for key in ('CFLAGS', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED', 'PY_LDFLAGS', 'PY_CFLAGS', 'PY_CPPFLAGS'):
2122
if key in cfg_vars:
2223
cfg_vars[key] = cfg_vars[key].replace('-mmacosx-version-min=10.9', '-mmacosx-version-min=12')
24+
2325
if platform.machine() == 'arm64':
2426
# Macos (arm64, homebrew path is different than intel)
2527
library_dirs = ['/opt/homebrew/lib']
2628
else:
2729
library_dirs = ['/usr/local/lib', '/usr/lib']
30+
31+
LD_PATH='DYLD_LIBRARY_PATH'
2832
else:
2933
# Debian/Ubuntu
3034
library_dirs = ['/usr/lib', '/usr/lib/x86_64-linux-gnu']
3135
# add libunwind explicitly
3236
base_libraries.append('unwind')
3337

3438
# Add (prepend) library paths from LD_LIBRARY_PATHs and calculate include paths
35-
if ldpath := os.environ.get('LD_LIBRARY_PATH'):
39+
if ldpath := os.environ.get(LD_PATH):
3640
library_dirs[:0] = ldpath.split(':')
3741
include_dirs.extend(path for path in (re.sub(r'/lib$', '/include', p) for p in ldpath.split(':')))
3842

0 commit comments

Comments
 (0)