Skip to content

Commit

Permalink
mac
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed May 11, 2024
1 parent 6a27137 commit 61fc7ea
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 43 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ add_library(${TARGET_NAME} SHARED
if (MSVC)
target_compile_options(${TARGET_NAME} PRIVATE "/MP")
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")
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()
Expand All @@ -24,7 +27,6 @@ target_include_directories(${TARGET_NAME} PUBLIC

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

if (DEFINED ALL_EXT_OBJ)
Expand All @@ -42,6 +44,7 @@ else()
target_link_libraries(${TARGET_NAME}
${ALL_LIB}
${ALL_EXT_LINK}
"-undefined dynamic_lookup"
)
endif()

Expand Down
2 changes: 1 addition & 1 deletion layer1/CGO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void AssignNewPickColor(CGO* cgo, PickColorManager* pickmgr,
pickmgr->colorNext(color, context, index, bond);
}

int CGO_sz[] = {
std::size_t CGO_sz[] = {
CGO_NULL_SZ,
CGO_NULL_SZ,
CGO_BEGIN_SZ,
Expand Down
2 changes: 1 addition & 1 deletion layer1/CGO.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ inline uchar CLIP_NORMAL_VALUE(float cv){ return ((cv>1.f) ? 127 :
#define CGO_ACCESSIBILITY_ARRAY 0x10
#define CGO_TEX_COORD_ARRAY 0x20

extern int CGO_sz[];
extern std::size_t CGO_sz[];
size_t CGO_sz_size();

// I think CGO rendering functions should not modify CGO's, so the
Expand Down
8 changes: 4 additions & 4 deletions layer2/RepCartoon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ static void do_ring(PyMOLGlobals * G, nuc_acid_data *ndata, int n_atom,
color2 = ColorGet(G, g2_ai->color);
}
CGOPickColor(cgo, g1, g1_ai->masked ? cPickableNoPick : cPickableAtom);
Pickable pickcolor2 = { g2, g2_ai->masked ? cPickableNoPick : cPickableAtom };
Pickable pickcolor2 = { static_cast<unsigned int>(g2), g2_ai->masked ? cPickableNoPick : cPickableAtom };
float axis[3];
subtract3f(g2p, g1p, axis);
CGOColorv(cgo, color1);
Expand Down Expand Up @@ -1046,7 +1046,7 @@ static void do_ring(PyMOLGlobals * G, nuc_acid_data *ndata, int n_atom,
color2 = ColorGet(G, bas_ai->color);
}
CGOPickColor(cgo, sugar_at, sug_ai->masked ? cPickableNoPick : cPickableAtom);
Pickable pickcolor2 = { base_at, bas_ai->masked ? cPickableNoPick : cPickableAtom };
Pickable pickcolor2 = { static_cast<unsigned int>(base_at), bas_ai->masked ? cPickableNoPick : cPickableAtom };
float axis[3];
subtract3f(cs->coordPtr(bas), cs->coordPtr(sug), axis);
CGOColorv(cgo, color1);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ static void do_ring(PyMOLGlobals * G, nuc_acid_data *ndata, int n_atom,
}

CGOPickColor(cgo, sugar_at, sug_ai->masked ? cPickableNoPick : cPickableAtom);
Pickable pickcolor2 = { base_at, bas_ai->masked ? cPickableNoPick : cPickableAtom };
Pickable pickcolor2 = { static_cast<unsigned int>(base_at), bas_ai->masked ? cPickableNoPick : cPickableAtom };
float axis[3];
subtract3f(cs->coordPtr(bas), v_outer, axis);
CGOColorv(cgo, color1);
Expand Down Expand Up @@ -1347,7 +1347,7 @@ static void do_ring(PyMOLGlobals * G, nuc_acid_data *ndata, int n_atom,
color1 = color2 = color;
}
CGOPickColor(cgo, atix[i], ai_i[i]->masked ? cPickableNoPick : cPickableAtom);
Pickable pickcolor2 = { atix[ii], ai_i[ii]->masked ? cPickableNoPick : cPickableAtom };
Pickable pickcolor2 = { static_cast<unsigned int>(atix[ii]), ai_i[ii]->masked ? cPickableNoPick : cPickableAtom };
float axis[3];
subtract3f(v_i[ii], v_i[i], axis);
CGOColorv(cgo, color1);
Expand Down
54 changes: 18 additions & 36 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ def __init__(self,
super().__init__(name, sources=[])
self.sources = sources
self.include_dirs = include_dirs
self.include_dirs.append(sysconfig.get_paths()['include'])
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
self.define_macros = define_macros
Expand All @@ -157,6 +154,11 @@ def __init__(self,


class build_ext_pymol(build_ext):
def initialize_options(self) -> None:
super().initialize_options()
if DEBUG and not WIN:
self.debug = False

def run(self):
for ext in self.extensions:
self.build_cmake(ext)
Expand All @@ -169,48 +171,30 @@ def build_cmake(self, ext):
name_split = ext.name.split('.')
target_name = name_split[-1]
build_temp = pathlib.Path(self.build_temp) / target_name
print(f"BUILDTMP {build_temp}")
build_temp.mkdir(parents=True, exist_ok=True)
extdir = pathlib.Path(self.get_ext_fullpath(ext.name))
extdir.mkdir(parents=True, exist_ok=True)
if not sys.platform == "darwin":
extdir.mkdir(parents=True, exist_ok=True)

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))

if MAC:
ext.libraries.append('python' + sysconfig.get_config_var('VERSION'))

config = 'Debug' if DEBUG else 'Release'
lib_output_dir = str(extdir.parent.absolute())
print(f"LIB OUTPUT DIR: {lib_output_dir}")
all_files = ext.sources
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(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"

shared_suffix = sysconfig.get_config_var('EXT_SUFFIX')

cmake_args = [
f"-DTARGET_NAME={target_name}",
f"-DCMAKE_{lib_mode}_OUTPUT_DIRECTORY={lib_output_dir}",
Expand All @@ -222,10 +206,8 @@ def concat_paths(paths):
f"-DALL_LIB={all_libs}",
f"-DALL_COMP_ARGS={all_comp_args}",
f"-DALL_EXT_LINK={all_ext_link}",
f"-DSHARED_SUFFIX={shared_suffix}"
]
# print(sys.platform)
# print(f"ALL INC DIR: {all_inc_dirs}")
# print(sysconfig.get_paths()['platinclude'])

if all_ext_objs:
cmake_args.append("-DALL_EXT_OBJ=" + all_ext_objs)
Expand All @@ -236,8 +218,6 @@ def concat_paths(paths):
cpu_count = os.cpu_count() or 1
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 @@ -478,9 +458,9 @@ def make_launch_script(self):

if options.osx_frameworks:
ext_link_args += [
"-framework", "OpenGL",
"-framework OpenGL",
] + (not options.no_glut) * [
"-framework", "GLUT",
"-framework GLUT",
]
def_macros += [
("_PYMOL_OSX", None),
Expand Down Expand Up @@ -623,11 +603,14 @@ def get_packages(base, parent='', r=None):
for base in ['modules']
for x in get_packages(base))

# Python includes
inc_dirs.append(sysconfig.get_paths()['include'])
inc_dirs.append(sysconfig.get_paths()['platinclude'])

champ_inc_dirs = ['contrib/champ']
champ_inc_dirs.append(sysconfig.get_paths()['include'])
champ_inc_dirs.append(sysconfig.get_paths()['platinclude'])

if sys.platform == 'linux':
inc_dirs.append(sysconfig.get_paths()['platinclude'])
champ_inc_dirs.append(sysconfig.get_paths()['platinclude'])

ext_modules += [
CMakeExtension(
Expand All @@ -646,7 +629,6 @@ 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 61fc7ea

Please sign in to comment.