Skip to content

Commit 08a8cee

Browse files
Merge pull request #599 from insertinterestingnamehere/pydynd
Fully remove libpydynd
2 parents 8f81b2f + 9051e87 commit 08a8cee

3 files changed

Lines changed: 49 additions & 75 deletions

File tree

CMakeLists.txt

Lines changed: 45 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -164,38 +164,6 @@ else()
164164
set(DYND_CUDA_01 0)
165165
endif()
166166

167-
set(pydynd_SRC
168-
dynd/include/conversions.hpp
169-
dynd/include/copy_from_numpy_arrfunc.hpp
170-
dynd/include/exception_translation.hpp
171-
dynd/include/functional.hpp
172-
dynd/include/git_version.hpp
173-
dynd/include/init.hpp
174-
dynd/include/type_functions.hpp
175-
dynd/include/utility_functions.hpp
176-
dynd/include/visibility.hpp
177-
dynd/src/conversions.cpp
178-
${CMAKE_CURRENT_BINARY_DIR}/dynd/src/git_version.cpp
179-
dynd/src/git_version.cpp.in
180-
)
181-
182-
add_library(pydynd SHARED ${pydynd_SRC})
183-
set_property(
184-
TARGET pydynd
185-
PROPERTY COMPILE_DEFINITIONS PYDYND_EXPORT
186-
)
187-
188-
if(APPLE)
189-
set_target_properties(pydynd PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
190-
elseif(WIN32)
191-
target_link_libraries(pydynd "${PYTHON_LIBRARIES}")
192-
endif()
193-
if(DYND_INSTALL_LIB)
194-
target_link_libraries(pydynd "${LIBDYND_LIBRARIES}")
195-
else()
196-
target_link_libraries(pydynd libdynd)
197-
endif()
198-
199167
foreach(pyx_api_file dynd/nd/array.pyx dynd/nd/callable.pyx dynd/ndt/type.pyx)
200168
set_source_files_properties(${pyx_api_file} PROPERTIES CYTHON_API 1)
201169
set_source_files_properties(${pyx_api_file} PROPERTIES CYTHON_PUBLIC 1)
@@ -205,53 +173,68 @@ set_source_files_properties(dynd/config.pyx PROPERTIES CYTHON_API 1)
205173

206174
cython_add_module(dynd.nd.array dynd.nd.array_pyx True
207175
# Additional C++ source files:
208-
dynd/src/array_as_pep3118.cpp
209-
dynd/src/assign.cpp
210176
dynd/include/do_import_array.hpp
211177
dynd/include/numpy_interop.hpp
178+
dynd/src/array_as_pep3118.cpp
212179
dynd/src/array_as_numpy.cpp
213180
dynd/src/array_from_py.cpp
214181
dynd/src/array_from_py_typededuction.cpp
182+
dynd/src/assign.cpp
183+
dynd/src/conversions.cpp
215184
dynd/src/copy_from_numpy_arrfunc.cpp
216185
dynd/src/init.cpp
217186
dynd/src/functional.cpp
218187
dynd/src/numpy_interop.cpp
219188
dynd/src/types/pyobject_type.cpp
220189
)
221-
set_property(
222-
TARGET dynd.nd.array
223-
PROPERTY COMPILE_DEFINITIONS PYDYND_EXPORT
224-
)
225190

226-
foreach(module dynd.config dynd.ndt.type dynd.ndt.json dynd.nd.callable dynd.nd.functional dynd.nd.registry)
227-
cython_add_module(${module} ${module}_pyx True)
228-
endforeach(module)
229-
230-
foreach(module dynd.config dynd.ndt.type dynd.ndt.json dynd.nd.array dynd.nd.callable dynd.nd.functional dynd.nd.registry)
231-
# Make sure libpydynd is on the rpath.
232-
# This has no effect on Windows.
233-
if(APPLE)
234-
set(module_install_rpath "@loader_path")
235-
else()
236-
set(module_install_rpath "$ORIGIN")
237-
endif()
238-
string(REPLACE "." ";" module_directories "${module}")
239-
list(LENGTH module_directories i)
240-
while(${i} GREATER 2)
241-
set(module_install_rpath "${module_install_rpath}/..")
242-
math(EXPR i "${i} - 1" )
243-
endwhile(${i} GREATER 2)
244-
# set(module_install_rpath "/opt/anaconda/envs/_test/lib/python2.7/site-packages/dynd/")
245-
set_target_properties(${module} PROPERTIES INSTALL_RPATH ${module_install_rpath})
191+
cython_add_module(dynd.config dynd.config_pyx True
192+
dynd/include/exception_translation.hpp
193+
dynd/src/conversions.cpp
194+
${CMAKE_CURRENT_BINARY_DIR}/dynd/src/git_version.cpp
195+
)
246196

247-
target_link_libraries(${module} pydynd)
197+
foreach(module dynd.ndt.type dynd.ndt.json dynd.nd.callable dynd.nd.functional dynd.nd.registry)
198+
cython_add_module(${module} ${module}_pyx True dynd/src/conversions.cpp)
248199
endforeach(module)
249200

250-
add_dependencies(pydynd dynd.nd.array_pyx dynd.nd.callable_pyx dynd.ndt.type_pyx)
251-
252201
# Run a postprocess script to work around some Cython bugs
253202
# that haven't been fixed in the latest release.
254203
postprocess_cython( postprocess.py dynd.ndt.type_postprocess dynd.ndt.type_pyx dynd.ndt.type)
255204
postprocess_cython( postprocess.py dynd.nd.array_postprocess dynd.nd.array_pyx dynd.nd.array)
256205
postprocess_cython( postprocess.py dynd.nd.callable_postprocess dynd.nd.callable_pyx dynd.nd.callable)
257-
add_dependencies(pydynd dynd.ndt.type_postprocess dynd.nd.array_postprocess dynd.nd.callable_postprocess)
206+
207+
foreach(module dynd.config dynd.ndt.type dynd.ndt.json dynd.nd.array dynd.nd.callable dynd.nd.functional dynd.nd.registry)
208+
# Temporarily continue to define PYDYND_EXPORT to avoid inconsistent linkage warnings.
209+
# This should be removed once the macros have been refactored to hide all symbols
210+
# other than module initialization routines.
211+
set_property(
212+
TARGET ${module}
213+
PROPERTY COMPILE_DEFINITIONS PYDYND_EXPORT
214+
)
215+
# Make sure the api headers are all built and postprocessed
216+
# before anything tries to build conversions.cpp
217+
add_dependencies(${module} dynd.nd.array_postprocess dynd.nd.callable_postprocess dynd.ndt.type_postprocess)
218+
if(DYND_INSTALL_LIB)
219+
target_link_libraries(${module} "${LIBDYND_LIBRARIES}")
220+
else()
221+
target_link_libraries(${module} libdynd)
222+
if(UNIX)
223+
# Make sure libdynd is on the rpath.
224+
# On Windows, the dll is loaded dynamically via the logic in
225+
# dynd/__init__.py
226+
if(APPLE)
227+
set(module_install_rpath "@loader_path")
228+
else()
229+
set(module_install_rpath "$ORIGIN")
230+
endif()
231+
string(REPLACE "." ";" module_directories "${module}")
232+
list(LENGTH module_directories i)
233+
while(${i} GREATER 2)
234+
set(module_install_rpath "${module_install_rpath}/..")
235+
math(EXPR i "${i} - 1" )
236+
endwhile(${i} GREATER 2)
237+
set_target_properties(${module} PROPERTIES INSTALL_RPATH ${module_install_rpath})
238+
endif()
239+
endif()
240+
endforeach(module)

dynd/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
if os.name == 'nt':
33
# Manually load dlls before loading the extension modules.
4+
# This is handled via rpaths on Unix based systems.
45
from ctypes import cdll
56
import os.path
67
# If libdynd.dll is already on the path, use it.
@@ -46,10 +47,6 @@
4647
'libdynd.dll')
4748
if os.path.isfile(libdynd_path):
4849
cdll.LoadLibrary(libdynd_path)
49-
# Load libpydynd from current directory now that libdynd
50-
# has been loaded.
51-
pydynd_dir = os.path.dirname(os.path.realpath(__file__))
52-
cdll.LoadLibrary(os.path.join(pydynd_dir, 'pydynd.dll'))
5350

5451
from .config import _dynd_version_string as __libdynd_version__, \
5552
_dynd_python_version_string as __version__, \

setup.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ def run(self):
8484
extra_cmake_args = shlex.split(self.extra_cmake_args)
8585
cmake_command = ['cmake'] + extra_cmake_args + [pyexe_option,
8686
install_lib_option, build_tests_option,
87-
static_lib_option, source]
87+
static_lib_option]
8888
if sys.platform != 'win32':
89+
cmake_command.append(source)
8990
self.spawn(cmake_command)
9091
self.spawn(['make'])
9192
else:
@@ -94,26 +95,19 @@ def run(self):
9495
if is_64_bit:
9596
cmake_generator += ' Win64'
9697
cmake_command += ['-G', cmake_generator]
98+
cmake_command.append(source)
9799
self.spawn(cmake_command)
98100
# Do the build
99101
self.spawn(['cmake', '--build', '.', '--config', build_type])
100102

101103
import glob, shutil
102104

103-
# Move the built libpydynd library to the place expected by the Python build
104105
if sys.platform != 'win32':
105-
name, = glob.glob('libpydynd.*')
106-
try:
107-
os.makedirs(os.path.join(build_lib, 'dynd'))
108-
except OSError:
109-
pass
110-
shutil.move(name, os.path.join(build_lib, 'dynd', name))
111106
if install_lib_option.split('=')[1] == 'OFF':
112107
name, = glob.glob('libraries/libdynd/libdynd.*')
113108
short_name = split(name)[1]
114109
shutil.move(name, os.path.join(build_lib, 'dynd', short_name))
115110
else:
116-
shutil.move(os.path.join(build_type, 'pydynd.dll'), os.path.join(build_lib, 'dynd', 'pydynd.dll'))
117111
if install_lib_option.split('=')[1] == 'OFF':
118112
names = glob.glob('libraries/libdynd/%s/libdynd.*' % build_type)
119113
for name in names:

0 commit comments

Comments
 (0)