Skip to content

Commit

Permalink
Setting up RPATHs
Browse files Browse the repository at this point in the history
  • Loading branch information
scopatz committed Sep 6, 2017
1 parent ce6d1c1 commit 87f0750
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ build-*
*egg-info/
build_nuc_data/
pyne/include/
src/atomic_data.cpp
src/atomic_data.h

# Ignore temp files
*.pyc
Expand Down
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ endif(${MOAB_FOUND})
# Find Python
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
"import site; print(site.getsitepackages(['${CMAKE_INSTALL_PREFIX}'])[0])"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LIBS ${LIBS} ${PYTHON_LIBRARIES})
message("-- PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
message("-- PYTHON_SITE_PACKAGES: ${PYTHON_SITE_PACKAGES}")


# Find NumPy
Expand All @@ -97,7 +102,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_IS_AMALGAMATION")


#
#
# Build and install!
#

# With CMake, a clean separation can be made between the source tree and the
Expand All @@ -110,6 +115,12 @@ add_custom_target(ReplicatePythonSourceTree ALL "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

# add sub dirs
add_subdirectory(src)
add_subdirectory(pyne)
add_subdirectory(pyne/xs)

# install python package
set(pyinstallscript "${CMAKE_CURRENT_BINARY_DIR}/cmake/SetupSubPyInstall.cmake")
configure_file(cmake/SetupSubPyInstall.cmake.in ${pyinstallscript} @ONLY)
install(SCRIPT ${pyinstallscript})
18 changes: 18 additions & 0 deletions cmake/SetupSubPyInstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Runs setup.py install
#
set(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@)
message("############### Begin Python Install ###############")
message("-- Python installer:")
message(" PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
message(" CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(" CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
execute_process(COMMAND ${PYTHON_EXECUTABLE} setup_sub.py install
"--prefix=${CMAKE_INSTALL_PREFIX}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE res_var)
if(NOT "${res_var}" STREQUAL "0")
message(FATAL_ERROR "Process setup_sub.py install failed, "
"res_var = '${res_var}'")
endif()
message("############### End Python Install ###############")
37 changes: 27 additions & 10 deletions pyne/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,115 +9,132 @@ message("-- Include paths for ${CMAKE_CURRENT_SOURCE_DIR}: ${inc_dirs}")
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/extra_types.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(extra_types extra_types.pyx)
install(TARGETS extra_types LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# dtypes
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/dtypes.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(dtypes dtypes.pyx)
install(TARGETS dtypes LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# STL containers
# If the pyx file is a C++ file, we should specify that here.
# then, add the module
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/stlcontainers.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(stlcontainers stlcontainers.pyx)
install(TARGETS stlcontainers LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# jsoncpp
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/jsoncpp.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(jsoncpp jsoncpp.pyx)
target_link_libraries(jsoncpp pyne)
install(TARGETS jsoncpp LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# pyne_config
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/pyne_config.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(pyne_config pyne_config.pyx)
target_link_libraries(pyne_config pyne)
install(TARGETS pyne_config LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# _utils
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/_utils.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(_utils _utils.pyx)
target_link_libraries(_utils pyne)
install(TARGETS _utils LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# dagmc
if (MOAB_FOUND)
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/dagmc.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(_dagmc dagmc.pyx "${PROJECT_SOURCE_DIR}/src/dagmc_bridge.cpp")
target_link_libraries(_dagmc dagmc MOAB pyne)
set_target_properties(_dagmc PROPERTIES OUTPUT_NAME dagmc)
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/dagmc.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(_dagmc dagmc.pyx "${PROJECT_SOURCE_DIR}/src/dagmc_bridge.cpp")
target_link_libraries(_dagmc dagmc MOAB pyne)
set_target_properties(_dagmc PROPERTIES OUTPUT_NAME dagmc)
install(TARGETS _dagmc LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")
endif (MOAB_FOUND)

# endf
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/endf.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(endf endf.pyx)
target_link_libraries(endf pyne)
install(TARGETS endf LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# nucname
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/nucname.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(nucname nucname.pyx)
target_link_libraries(nucname pyne)
install(TARGETS nucname LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# rxname
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/rxname.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(rxname rxname.pyx)
target_link_libraries(rxname pyne)
install(TARGETS rxname LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# particle
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/particle.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(particle particle.pyx)
target_link_libraries(particle pyne)
install(TARGETS particle LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")


# data
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/data.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(data data.pyx)
target_link_libraries(data pyne)
install(TARGETS data LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# material
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/material.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(material material.pyx)
target_link_libraries(material pyne hdf5)
install(TARGETS material LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# ace
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/ace.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(ace ace.pyx)
target_link_libraries(ace pyne)
install(TARGETS ace LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# enrichment
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/enrichment.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(enrichment enrichment.pyx)
target_link_libraries(enrichment pyne)
install(TARGETS enrichment LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# tally
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/tally.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(tally tally.pyx)
target_link_libraries(tally pyne)

install(TARGETS tally LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

# source_sampling
if (MOAB_FOUND)
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/source_sampling.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(source_sampling source_sampling.pyx)
target_link_libraries(source_sampling pyne)
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/source_sampling.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(source_sampling source_sampling.pyx)
target_link_libraries(source_sampling pyne)
install(TARGETS source_sampling LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")
endif (MOAB_FOUND)

# bins
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/bins.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(bins bins.pyx)
target_link_libraries(bins pyne)
install(TARGETS bins LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne")

message("-- F2PY F90 FLAGS: ${F2PY_F90FLAGS}")

Expand Down
8 changes: 3 additions & 5 deletions pyne/xs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Python extension modules
include_directories(${PYNE_INCLUDE_DIRS})
get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
message("-- Include paths for ${CMAKE_CURRENT_SOURCE_DIR}: ${inc_dirs}")

# xs
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/xs/models.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(models models.pyx)
target_link_libraries(models pyne)


# Print include dir
get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
message("-- Include paths for ${CMAKE_CURRENT_SOURCE_DIR}: ${inc_dirs}")
install(TARGETS models LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/pyne/xs")
77 changes: 77 additions & 0 deletions setup_sub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python
"""Welcome to PyNE's setup.py sub script."""
from __future__ import print_function

import io
import os
import re
import sys
import imp
import shutil
import tarfile
import argparse
import platform
import warnings
import subprocess
from glob import glob
from distutils import core, dir_util, sysconfig
from contextlib import contextmanager
if sys.version_info[0] < 3:
from urllib import urlopen
else:
from urllib.request import urlopen
from distutils.core import setup


VERSION = '0.5.3'
IS_NT = os.name == 'nt'


def main():
scripts = [os.path.join('scripts', f) for f in os.listdir('scripts')]
scripts = [s for s in scripts if (os.name == 'nt' and s.endswith('.bat'))
or (os.name != 'nt' and
not s.endswith('.bat'))]
packages = ['pyne', 'pyne.dbgen', 'pyne.apigen', 'pyne.xs',
'pyne.transmute', 'pyne.gui', 'pyne.cli', 'pyne.fortranformat']
pack_dir = {
'pyne': 'pyne',
'pyne.xs': 'pyne/xs',
'pyne.gui': 'pyne/gui',
'pyne.cli': 'pyne/cli',
'pyne.dbgen': 'pyne/dbgen',
'pyne.apigen': 'pyne/apigen',
'pyne.transmute': 'pyne/transmute',
'pyne.fortranformat': 'pyne/fortranformat',
}
extpttn = ['*.dll', '*.so', '*.dylib', '*.pyd', '*.pyo']
pack_data = {
'lib': extpttn,
'pyne': ['*.pxd',
#'include/*.h', 'include/*.pxi', 'include/*/*.h',
#'include/*/*/*.h', 'include/*/*/*/*.h',
'*.json', '*.inp',
#'_includes/*.txt', '_includes/*.pxd', '_includes/*/*',
#'_includes/*/*/*'
] + extpttn,
'pyne.xs': ['*.pxd'] + extpttn,
'pyne.gui': ['*.pyw'],
'pyne.dbgen': ['*.html', '*.csv', 'abundances.txt', 'mass.mas12'],
}
setup_kwargs = {
"name": "pyne",
"version": VERSION,
"description": 'The Nuclear Engineering Toolkit',
"author": 'PyNE Development Team',
"author_email": '[email protected]',
"url": 'http:https://pyne.github.com/',
"packages": packages,
"package_dir": pack_dir,
"package_data": pack_data,
"scripts": scripts,
}
rtn = setup(**setup_kwargs)


if __name__ == "__main__":
main()

0 comments on commit 87f0750

Please sign in to comment.