Skip to content

Commit

Permalink
Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed May 11, 2024
1 parent 9c98253 commit 7edf399
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion layer4/Cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6531,7 +6531,7 @@ static PyMethodDef Cmd_methods[] = {
extern "C" {
#endif

PyObject * PyInit__cmd(void)
PyMODINIT_FUNC PyInit__cmd(void)
{
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
Expand Down
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,32 @@ def finalize_options(self):
self.pymol_path = install_pymol.change_root(
self.root, self.pymol_path)

def install_lib_to(self, sub_dir_list: list[str], lib_name: str) -> None:
"""
Installs a library to the appropriate directory depending on the
operating system.
: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).
"""
lib_path = pathlib.Path(self.build_lib, *sub_dir_list)
if WIN:
lib_path = lib_path / "Release" / f"{lib_name}.pyd"
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))

def install_pymol_lib(self) -> None:
"""
Installs PyMOL _cmd library
"""
self.install_lib_to(["pymol"], "_cmd")

def run(self):
install.run(self)
self.install_pymol_path()
self.install_pymol_lib()

if not self.no_launcher:
self.make_launch_script()
Expand Down Expand Up @@ -605,6 +628,9 @@ def get_packages(base, parent='', r=None):
champ_inc_dirs.append(sysconfig.get_paths()['include'])
champ_inc_dirs.append(sysconfig.get_paths()['platinclude'])

if WIN:
py_lib = pathlib.Path(sysconfig.get_paths()['stdlib']).parent / 'libs'
lib_dirs.append(str(py_lib))

ext_modules += [
CMakeExtension(
Expand All @@ -622,6 +648,7 @@ def get_packages(base, parent='', r=None):
name="chempy.champ._champ",
sources=get_sources(['contrib/champ']),
include_dirs=champ_inc_dirs,
library_dirs=lib_dirs,
),
]

Expand Down

0 comments on commit 7edf399

Please sign in to comment.