Skip to content
Snippets Groups Projects
Commit f6e0ff15 authored by Samuel Burbulla's avatar Samuel Burbulla Committed by Andreas Dedner
Browse files

Initial version.

Build shared libraries with .so suffix on Mac.

Install pybind11 modules.

Generate dependencies of dune-py on-demand.

fixed a few issues with generating dune-py on a linux machine
parent f5c2c296
No related branches found
No related tags found
No related merge requests found
...@@ -1022,6 +1022,12 @@ macro(dune_add_library basename) ...@@ -1022,6 +1022,12 @@ macro(dune_add_library basename)
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
if (APPLE)
set_target_properties(${basename} PROPERTIES SUFFIX ".so")
target_link_options(${basename} PRIVATE "-undefined")
target_link_options(${basename} PRIVATE "dynamic_lookup")
endif()
if(NOT DUNE_LIB_NO_EXPORT) if(NOT DUNE_LIB_NO_EXPORT)
# The following allows for adding multiple libs in the same # The following allows for adding multiple libs in the same
# directory or below with passing the APPEND keyword. # directory or below with passing the APPEND keyword.
......
[build-system]
requires = ["setuptools", "wheel", "scikit-build", "cmake"]
build-backend = "setuptools.build_meta"
...@@ -11,3 +11,4 @@ add_python_targets(common ...@@ -11,3 +11,4 @@ add_python_targets(common
) )
dune_add_pybind11_module(NAME _common) dune_add_pybind11_module(NAME _common)
set_property(TARGET _common PROPERTY LINK_LIBRARIES dunecommon APPEND) set_property(TARGET _common PROPERTY LINK_LIBRARIES dunecommon APPEND)
install(TARGETS _common LIBRARY DESTINATION python/dune/common)
...@@ -301,7 +301,7 @@ def pkg_config(pkg, var=None): ...@@ -301,7 +301,7 @@ def pkg_config(pkg, var=None):
pkgconfig.wait() pkgconfig.wait()
if pkgconfig.returncode != 0: if pkgconfig.returncode != 0:
raise KeyError('package ' + pkg + 'not found.') raise KeyError('package ' + pkg + 'not found.')
return buffer_to_str(pkgconfig.stdout.read()) return buffer_to_str(pkgconfig.stdout.read()).strip()
def get_prefix(module): def get_prefix(module):
...@@ -334,6 +334,16 @@ def get_cmake_command(): ...@@ -334,6 +334,16 @@ def get_cmake_command():
except KeyError: except KeyError:
return 'cmake' return 'cmake'
def get_local():
if inVEnv():
return sys.prefix
try:
home = expanduser("~")
return os.path.join(home, '.local')
except KeyError:
pass
return ''
def get_module_path(): def get_module_path():
try: try:
path = [p for p in os.environ['DUNE_CONTROL_PATH'].split(':') if p and os.path.isdir(p)] path = [p for p in os.environ['DUNE_CONTROL_PATH'].split(':') if p and os.path.isdir(p)]
...@@ -352,7 +362,11 @@ def get_module_path(): ...@@ -352,7 +362,11 @@ def get_module_path():
pass pass
# try to guess modules path for unix systems # try to guess modules path for unix systems
path = [p for p in ['.', '/usr/local/lib/dunecontrol', '/usr/lib/dunecontrol'] if os.path.isdir(p)] path = [p for p in ['.',
'/usr/local/lib/dunecontrol',
'/usr/lib/dunecontrol',
os.path.join(get_local(),'lib','dunecontrol') ]
if os.path.isdir(p)]
try: try:
pkg_config_path = [p for p in os.environ['PKG_CONFIG_PATH'].split(':') if p and os.path.isdir(p)] pkg_config_path = [p for p in os.environ['PKG_CONFIG_PATH'].split(':') if p and os.path.isdir(p)]
pkg_config_path = [os.path.join(p, '..', 'dunecontrol') for p in pkg_config_path] pkg_config_path = [os.path.join(p, '..', 'dunecontrol') for p in pkg_config_path]
...@@ -381,13 +395,14 @@ def select_modules(modules=None): ...@@ -381,13 +395,14 @@ def select_modules(modules=None):
for d, p in modules: for d, p in modules:
n = d.name n = d.name
if n in dir: if n in dir:
if p == dir[n]: continue
if is_installed(dir[n], n): if is_installed(dir[n], n):
if is_installed(p, n): if is_installed(p, n):
raise KeyError('Multiple installed versions for module \'' + n + '\' found.') raise KeyError('Multiple installed versions for module \'' + n + '\' found.')
else: else:
desc[n], dir[n] = d, p desc[n], dir[n] = d, p
else: else:
if not is_installed(d, n): if not is_installed(p, n):
raise KeyError('Multiple source versions for module \'' + n + '\' found.') raise KeyError('Multiple source versions for module \'' + n + '\' found.')
else: else:
desc[n], dir[n] = d, p desc[n], dir[n] = d, p
...@@ -519,6 +534,17 @@ def get_cmake_definitions(): ...@@ -519,6 +534,17 @@ def get_cmake_definitions():
except ValueError: except ValueError:
key, value = arg, None key, value = arg, None
definitions[key] = value definitions[key] = value
else: # some defaults
definitions['BUILD_SHARED_LIBS']='TRUE'
definitions['DUNE_ENABLE_PYTHONBINDINGS']='TRUE'
definitions['DUNE_PYTHON_INSTALL_LOCATION']='none'
definitions['DUNE_GRID_GRIDTYPE_SELECTOR']='ON'
definitions['ALLOW_CXXFLAGS_OVERWRITE']='ON'
definitions['USE_PTHREADS']='ON'
definitions['CMAKE_BUILD_TYPE']='Release'
definitions['CMAKE_DISABLE_FIND_PACKAGE_LATEX']='TRUE'
definitions['CMAKE_DISABLE_DOCUMENTATION']='TRUE'
return definitions return definitions
...@@ -574,10 +600,13 @@ def build_dune_py_module(dune_py_dir=None, definitions=None, build_args=None, bu ...@@ -574,10 +600,13 @@ def build_dune_py_module(dune_py_dir=None, definitions=None, build_args=None, bu
if definitions is None: if definitions is None:
definitions = get_cmake_definitions() definitions = get_cmake_definitions()
desc = Description(os.path.join(dune_py_dir, 'dune.module'))
modules, dirs = select_modules() modules, dirs = select_modules()
deps = resolve_dependencies(modules, desc) deps = resolve_dependencies(modules, None)
desc = Description(module='dune-py', version=get_dune_py_version(), maintainer='dune@lists.dune-project.org', depends=list(modules.values()))
with open(os.path.join(dune_py_dir, 'dune.module'), 'w') as file:
file.write(repr(desc))
prefix = {} prefix = {}
for name, dir in dirs.items(): for name, dir in dirs.items():
......
...@@ -2,3 +2,4 @@ add_python_targets(typeregistry ...@@ -2,3 +2,4 @@ add_python_targets(typeregistry
__init__ __init__
) )
dune_add_pybind11_module(NAME _typeregistry) dune_add_pybind11_module(NAME _typeregistry)
install(TARGETS _typeregistry LIBRARY DESTINATION python/dune/typeregistry)
setup.py 0 → 100644
import sys, os
from setuptools import find_packages
try:
from skbuild import setup
except ImportError:
print('Please update pip, you need pip 10 or greater,\n'
' or you need to install the PEP 518 requirements in pyproject.toml yourself', file=sys.stderr)
raise
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="dune-common",
version="2.8.20201123",
author="The Dune Core developers",
author_email="dune@lists.dune-project.org",
description="""Basis infrastructure classes for all Dune modules""",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://gitlab.dune-project.org/core/dune-common",
packages=find_packages(where="python"),
package_dir={"": "python"},
install_requires=['numpy', 'mpi4py'],
cmake_args=['-DBUILD_SHARED_LIBS=TRUE',
'-DDUNE_ENABLE_PYTHONBINDINGS=TRUE',
'-DDUNE_PYTHON_INSTALL_LOCATION=none',
'-DDUNE_GRID_GRIDTYPE_SELECTOR=ON',
'-DALLOW_CXXFLAGS_OVERWRITE=ON',
'-DUSE_PTHREADS=ON',
'-DCMAKE_BUILD_TYPE=Release',
'-DCMAKE_DISABLE_FIND_PACKAGE_LATEX=TRUE',
'-DCMAKE_DISABLE_DOCUMENTATION=TRUE',
'-DCMAKE_INSTALL_RPATH='+sys.prefix+'/lib/']
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment