Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed May 10, 2024
1 parent ef5c74a commit 6a27137
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_include_directories(${TARGET_NAME} PUBLIC

target_link_directories(${TARGET_NAME} PUBLIC
${ALL_LIB_DIR}
${PYTHON_LIBRARIES}
)

if (DEFINED ALL_EXT_OBJ)
Expand Down
28 changes: 23 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __init__(self,
self.sources = sources
self.include_dirs = include_dirs
self.include_dirs.append(sysconfig.get_paths()['include'])
if sys.platform.startswith('linux'):
if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
self.include_dirs.append(sysconfig.get_paths()['platinclude'])
self.libraries = libraries
self.library_dirs = library_dirs
Expand Down Expand Up @@ -176,9 +176,14 @@ def build_cmake(self, ext):

def concat_paths(paths):
return ''.join(path.replace('\\', '/') + ";" for path in paths)
if not MAC:
py_lib = pathlib.Path(sysconfig.get_paths()['stdlib']).parent / 'libs'
else:
py_lib = pathlib.Path(sysconfig.get_paths()['stdlib'])
#ext.library_dirs.append(str(py_lib))

py_lib = pathlib.Path(sysconfig.get_paths()['stdlib']).parent / 'libs'
ext.library_dirs.append(str(py_lib))
if MAC:
ext.libraries.append('python' + sysconfig.get_config_var('VERSION'))

config = 'Debug' if DEBUG else 'Release'
lib_output_dir = str(extdir.parent.absolute())
Expand All @@ -187,12 +192,23 @@ def concat_paths(paths):
all_src = concat_paths(all_files)
all_defs = ''.join(mac[0] + ";" for mac in ext.define_macros)
all_libs = ''.join(f"{lib};" for lib in ext.libraries)
all_ext_link = ''.join(f"{arg};" for arg in ext.extra_link_args)
all_ext_link = ' '.join(ext.extra_link_args)
all_comp_args = ''.join(f"{arg};" for arg in ext.extra_compile_args)
all_lib_dirs = concat_paths(ext.library_dirs)
#all_lib_dirs = ' '.join(ext.library_dirs)
#all_lib_dirs = []
#for lib_dir in ext.library_dirs:
# all_lib_dirs.append('-L"{}"'.format(lib_dir))
# all_lib_dirs.append('-Wl,-rpath,"{}"'.format(lib_dir))
#all_lib_dirs = ' '.join(all_lib_dirs)
all_inc_dirs = concat_paths(ext.include_dirs)
all_ext_objs = concat_paths(ext.extra_objects)

print(all_lib_dirs)
print(all_libs)
#print(pathlib.Path(sysconfig.get_paths()['stdlib']).parent)
#exit(1)

lib_mode = "RUNTIME" if WIN else "LIBRARY"

cmake_args = [
Expand Down Expand Up @@ -221,6 +237,7 @@ def concat_paths(paths):
build_args += [f'-j{cpu_count}']

print(cmake_args)
#exit(1)
os.chdir(str(build_temp))
self.spawn(['cmake', str(cwd)] + cmake_args)
if not self.dry_run:
Expand Down Expand Up @@ -625,10 +642,11 @@ def get_packages(base, parent='', r=None):
extra_objects=ext_objects,
),

Extension(
CMakeExtension(
name="chempy.champ._champ",
sources=get_sources(['contrib/champ']),
include_dirs=champ_inc_dirs,
library_dirs=lib_dirs,
),
]

Expand Down

0 comments on commit 6a27137

Please sign in to comment.