Skip to content

Commit

Permalink
looks good
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed May 11, 2024
1 parent 8951ed8 commit 9cad8ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_library(${TARGET_NAME} SHARED

if (MSVC)
target_compile_options(${TARGET_NAME} PRIVATE "/MP")
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")
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})
Expand Down
2 changes: 1 addition & 1 deletion contrib/champ/champ_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ static PyMethodDef champ_methods[] = {
{NULL, NULL} /* sentinel */
};

PyObject * PyInit__champ(void)
PyMODINIT_FUNC PyInit__champ(void)
{
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
Expand Down
35 changes: 25 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ 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}",
Expand Down Expand Up @@ -264,23 +265,37 @@ def install_lib_to(self, sub_dir_list: list[str], lib_name: str) -> None:
:lib_name: The filename of the library (without the extension).
"""
lib_path = pathlib.Path(self.build_lib, *sub_dir_list)
suffix = sysconfig.get_config_var('EXT_SUFFIX')
if WIN:
lib_path = lib_path / "Release" / f"{lib_name}.pyd"
lib_path = lib_path / "Release" / f"{lib_name}{suffix}"
else:
lib_path = lib_path / f"{lib_name}.so"
dst = pathlib.Path(self.install_platlib, *sub_dir_list)
self.copy(str(lib_path), str(dst))
lib_path = lib_path / f"{lib_name}{suffix}"
dst = pathlib.Path(self.install_platlib, *sub_dir_list, f"{lib_name}{suffix}")
self.copy(str(lib_path), dst)

def install_pymol_lib(self) -> None:
def delete_conflicting_cmake_dir(self, sub_dir_list: list[str], lib_name: str) -> None:
"""
Installs PyMOL _cmd library
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).
"""
self.install_lib_to(["pymol"], "_cmd")

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):
install.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_pymol_lib()
self.install_lib_to(["pymol"], "_cmd")
self.install_lib_to(["chempy", "champ"], "_champ")

if not self.no_launcher:
self.make_launch_script()
Expand Down

0 comments on commit 9cad8ce

Please sign in to comment.