diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fca147a7..c90ea815e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,14 +9,12 @@ add_library(${TARGET_NAME} SHARED if (MSVC) target_compile_options(${TARGET_NAME} PRIVATE "/MP") - set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ${SHARED_SUFFIX}) -elseif (APPLE) - set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ${SHARED_SUFFIX}) - target_compile_options(${TARGET_NAME} PRIVATE ${ALL_COMP_ARGS}) else() target_compile_options(${TARGET_NAME} PRIVATE ${ALL_COMP_ARGS}) endif() +set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ${SHARED_SUFFIX}) + target_compile_features(${TARGET_NAME} PRIVATE cxx_std_17) set_target_properties(${TARGET_NAME} PROPERTIES PREFIX "") diff --git a/setup.py b/setup.py index 7892f3aa6..ce00e8781 100644 --- a/setup.py +++ b/setup.py @@ -176,7 +176,7 @@ def build_cmake(self, ext): build_temp = pathlib.Path(self.build_temp) / target_name build_temp.mkdir(parents=True, exist_ok=True) extdir = pathlib.Path(self.get_ext_fullpath(ext.name)) - if not sys.platform == "darwin": + if sys.platform == "linux": # TODO: Recheck linux extdir.mkdir(parents=True, exist_ok=True) def concat_paths(paths): @@ -196,7 +196,6 @@ def concat_paths(paths): lib_mode = "RUNTIME" if WIN else "LIBRARY" shared_suffix = sysconfig.get_config_var('EXT_SUFFIX') - print(f"shared_suffix: {shared_suffix}") cmake_args = [ f"-DTARGET_NAME={target_name}", @@ -222,6 +221,13 @@ def concat_paths(paths): self.spawn(['cmake', str(cwd)] + cmake_args) if not self.dry_run: self.spawn(['cmake', '--build', '.'] + build_args) + + if WIN: + # Move up from VS release folder + cmake_lib_loc = pathlib.Path(lib_output_dir, "Release", f"{target_name}{shared_suffix}") + if cmake_lib_loc.exists(): + shutil.move(cmake_lib_loc, extdir) + # Troubleshooting: if fail on line above then delete all possible # temporary CMake files including "CMakeCache.txt" in top level dir. os.chdir(str(cwd)) @@ -273,29 +279,9 @@ def install_lib_to(self, sub_dir_list: list[str], lib_name: str) -> None: dst = pathlib.Path(self.install_platlib, *sub_dir_list, f"{lib_name}{suffix}") self.copy(str(lib_path), dst) - def delete_conflicting_cmake_dir(self, sub_dir_list: list[str], lib_name: str) -> None: - """ - Deletes the conflicting directory if it exists. - :sub_dir_list: The subdirectories where the library is located - relative to the build_lib and install_platlib directories. - :lib_name: The filename of the library (without the extension). - """ - cmake_folder = pathlib.Path(self.build_lib, *sub_dir_list, f"{lib_name}{sysconfig.get_config_var('EXT_SUFFIX')}") - print(cmake_folder) - print(f"DELETE {cmake_folder}") - print(cmake_folder.exists()) - if cmake_folder.exists() and cmake_folder.is_dir(): - shutil.rmtree(cmake_folder) - print(cmake_folder.exists()) - # if lib_name == "_champ": - # exit(1) def run(self): - self.delete_conflicting_cmake_dir(["pymol"], "_cmd") - self.delete_conflicting_cmake_dir(["chempy", "champ"], "_champ") super().run() self.install_pymol_path() - self.install_lib_to(["pymol"], "_cmd") - self.install_lib_to(["chempy", "champ"], "_champ") if not self.no_launcher: self.make_launch_script()