Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
[submodule "pybind11"]
path = pybind11
url = https://github.com/pybind/pybind11.git
[submodule "hipo"]
path = hipo
url = https://github.com/mfmceneaney/hipo.git
41 changes: 0 additions & 41 deletions CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion hipo
Submodule hipo deleted from f6a88e
139 changes: 139 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
project(
'hipopybind',
'cpp',
version: '2.0.0',
license: 'MIT',
meson_version: '>= 1.2.0',
default_options: [
'cpp_std=c++17',
'buildtype=release',
],
)

# meson modules
pkg = import('pkgconfig')

#---------- Find python ----------#
py = import('python').find_installation(pure: false)

#---------- Add PyBind11 as a CMake subproject ----------#
# Setup a CMake dependency
cmake = import('cmake')
opt_var = cmake.subproject_options()

# Call CMake with `-DSOME_OTHER_VAR=ON`
opt_var.add_cmake_defines({'DOWNLOAD_CATCH': true})
opt_var.add_cmake_defines({'PYBIND11_INSTALL': false})
opt_var.add_cmake_defines({'PYBIND11_TEST': false})
opt_var.set_install(false)

# Configure the CMake project
pybind11_sub = cmake.subproject('pybind11', options : opt_var)

# Fetch the dependency object
pybind11_dep = pybind11_sub.dependency('pybind11_headers')

#---------- Add hipo4 from pkg-config OR from subproject ----------#
hipo_dep = dependency(
'hipo4',
version: '>=4.2.0',
method: 'pkg-config',
)
if not hipo_dep.found()
hipo_dep = subproject('hipo4',
default_options : {
'build_examples' : false,
'dataframes' : false,
'prefix' : get_option('prefix'),
})
endif

#---------- Declare package dependencies ----------#

# list of dependencies
# FIXME: for users which use LD_LIBRARY_PATH, we should try to keep this list
# ordered such that the ones users are *least likely* to try to build
# themselves are listed last (see FIXME in meson/this_iguana.sh.in)
# NOTE: omit ROOT (handled differently, and most ROOT users already have it in their environment)
dep_list = []
foreach dep : [ hipo_dep ]
if dep.found()
dep_list += dep
endif
endforeach

# pkgconfig configuration: make a list of dependency library and include directories
dep_lib_dirs = []
dep_include_dirs = []
dep_pkgconfig_dirs = []
foreach dep : dep_list

# get library and include dirs
if dep.type_name() == 'pkgconfig'
libdirs = [ dep.get_variable(pkgconfig: 'libdir') ]
incdirs = [ dep.get_variable(pkgconfig: 'includedir') ]
elif dep.type_name() == 'cmake'
libdirs = []
foreach lib : dep.get_variable(cmake: 'PACKAGE_LIBRARIES').split(';')
libdirs += run_command('dirname', lib, check: true).stdout().strip()
endforeach
incdirs = ROOT_dep.get_variable(cmake: 'PACKAGE_INCLUDE_DIRS').split(';')
else
name = dep.get_variable(internal: 'name', default_value: dep.name())
warning(f'Unknown dependency "@name@"')
continue
endif

# append to `dep_*_dirs` arrays, uniquely
foreach libdir : libdirs
if not dep_lib_dirs.contains(libdir)
dep_lib_dirs += libdir
endif
if dep.type_name() == 'pkgconfig'
pkgconfigdir = libdir / 'pkgconfig'
if not dep_pkgconfig_dirs.contains(pkgconfigdir)
dep_pkgconfig_dirs += pkgconfigdir
endif
endif
endforeach
foreach incdir : incdirs
if not dep_include_dirs.contains(incdir)
dep_include_dirs += incdir
endif
endforeach
endforeach

# general project vars
project_inc = include_directories('src')
project_libs = []
project_deps = declare_dependency(dependencies: dep_list) # do NOT include ROOT here
project_etc = get_option('sysconfdir') / meson.project_name()
project_test_env = environment()
project_pkg_vars = [
'bindir=' + '${prefix}' / get_option('bindir'),
'dep_pkgconfigdirs=' + ':'.join(dep_pkgconfig_dirs),
'dep_libdirs=' + ':'.join(dep_lib_dirs),
'dep_includedirs=' + ':'.join(dep_include_dirs),
]

#---------- Compile Pybind11 Module ----------#
py.extension_module('hipopybind',
'src/main.cpp',
install: true,
dependencies : [pybind11_dep,hipo_dep],
)

# generate pkg-config file
project_pkg_vars_nonempty = []
foreach var : project_pkg_vars
if not var.endswith('=') # remove empty variable values
project_pkg_vars_nonempty += var
endif
endforeach
pkg.generate(
name: meson.project_name(),
description: project_description,
libraries: project_libs,
requires: [ pybind11_dep, hipo_dep ], # pkg-config dependencies only
variables: project_pkg_vars_nonempty,
)
1 change: 0 additions & 1 deletion pybind11
Submodule pybind11 deleted from fac23b
36 changes: 14 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
[build-system]
requires = [
"setuptools>61.0",
"wheel",
"ninja",
"cmake>=3.12",
]
build-backend = "setuptools.build_meta"
[tool.poetry]
name = "hipopybind"
version = "2.0.0"
description = "Python bindings for CLAS12 HIPO C++ classes with PyBind11"
authors = ["Matthew McEneaney <matthew.mceneaney@duke.edu>"]
license = "MIT"
readme = "README.md"

[tool.isort]
profile = "black"
[tool.poetry.dependencies]
python = "^3.11"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = ["error"]
testpaths = ["tests"]
[tool.poetry.build]
script = "meson.build"

[tool.cibuildwheel]
test-command = "pytest {project}/tests"
test-extras = ["test"]
test-skip = ["*universal2:arm64"]
# Setuptools bug causes collision between pypy and cpython artifacts
before-build = "rm -rf {project}/build"
[build-system]
requires = ["poetry-core","meson-python","pybind11"]
build-backend = "mesonpy"
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
meson-python
cmake
148 changes: 0 additions & 148 deletions setup.py

This file was deleted.

9 changes: 9 additions & 0 deletions subprojects/hipo4.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = hipo-4.2.0
source_url = https://github.com/gavalian/hipo/archive/refs/tags/4.2.0.tar.gz
source_filename = hipo-4.2.0.tar.gz
source_hash = a5feb44af5ca77d5af0aaae66571241e2eb82abf95c45d563a4541718d1abc6a
method = meson

[provide]
hipo4_dep = hipo-4.2.0/hipo4
Loading