Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meson #57

Closed
wants to merge 30 commits into from
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
10 changes: 6 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Coverage

on:
pull_request:
push:
branch: [main]
paths-ignore:
- 'docs/**'
- '*.rst'
Expand All @@ -30,13 +28,17 @@ jobs:
with:
python-version: 3.11
- run: python -m pip install --upgrade pip
- run: python -m pip install --prefer-binary coveralls
- run: python -m pip install --prefer-binary -e .[test]
# we need the unreleased meson-python version for editable build support
- run: python -m pip install --upgrade ninja pybind11 git+https://github.com/mesonbuild/meson-python.git
- run: python -m pip install --prefer-binary --no-build-isolation -v -e .[test]
- if: failure()
run: cat .mesonpy/editable/build/meson-logs/meson-log.txt
- run: coverage run -m pytest
- uses: ts-graphviz/setup-graphviz@v1
- run: coverage run --append -m pytest
- run: python -m pip uninstall --yes particle
- run: coverage run --append -m pytest
- run: python -m pip install --prefer-binary coveralls
- run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ docs/examples/modified_event.dat
tests/fig/*
tests/data/*_pdf.png
tests/data/*_svg.png
subprojects/*
!subprojects/*.wrap
!subprojects/packagefiles
.mesonpy*
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[submodule "extern/pybind11"]
path = extern/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "extern/HepMC3"]
path = extern/HepMC3
url = https://gitlab.cern.ch/hepmc/HepMC3.git
[submodule "extern/mp11"]
path = extern/mp11
url = https://github.com/boostorg/mp11.git
[submodule "extern/cpp-member-accessor"]
path = extern/cpp-member-accessor
url = https://github.com/hliberacki/cpp-member-accessor.git
78 changes: 0 additions & 78 deletions CMakeLists.txt

This file was deleted.

84 changes: 0 additions & 84 deletions cmake_ext.py

This file was deleted.

2 changes: 1 addition & 1 deletion extern/HepMC3
Submodule HepMC3 updated from 591bcc to c524bf
1 change: 0 additions & 1 deletion extern/cpp-member-accessor
Submodule cpp-member-accessor deleted from e72109
1 change: 0 additions & 1 deletion extern/mp11
Submodule mp11 deleted from f6133a
1 change: 0 additions & 1 deletion extern/pybind11
Submodule pybind11 deleted from 914c06
11 changes: 11 additions & 0 deletions get_pybind11_include.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pybind11
import os
from pathlib import Path

p = Path(pybind11.get_include())
try:
p = p.relative_to(os.environ.get("MESON_SOURCE_ROOT", os.getcwd()))
except ValueError:
pass

print(p)
File renamed without changes.
107 changes: 107 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
project(
'pyhepmc', 'cpp',
license: 'BSD-3',
default_options: [
'cpp_std=c++14',
# for release mode
# 'b_lto=true',
# 'b_lto_mode=thin',
]
)

accessor = dependency('cpp-member-accessor')
mp11 = dependency('boost-mp11')
# hepmc3 = dependency('hepmc3', static:true).as_link_whole()

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

# pybind11 include directory - needed in several submodules.
# We have to use get_pybind11_include to work around a stupid
# Meson restriction when installing from a venv created inside
# the project directory.
incdir_pybind11 = run_command(py,
['get_pybind11_include.py'],
check: true
).stdout().strip()

inc_pybind11 = include_directories(incdir_pybind11)

cpp = meson.get_compiler('cpp')

inc_hepmc3 = include_directories('extern/HepMC3/include')

src_hepmc3 = files([
'extern/HepMC3/src/GenCrossSection.cc',
'extern/HepMC3/src/GenEvent.cc',
'extern/HepMC3/src/GenHeavyIon.cc',
'extern/HepMC3/src/GenParticle.cc',
'extern/HepMC3/src/GenPdfInfo.cc',
'extern/HepMC3/src/GenRunInfo.cc',
'extern/HepMC3/src/GenVertex.cc',
'extern/HepMC3/src/HEPEVT_Wrapper.cc',
'extern/HepMC3/src/LHEFAttributes.cc',
'extern/HepMC3/src/Print.cc',
'extern/HepMC3/src/ReaderAscii.cc',
'extern/HepMC3/src/ReaderAsciiHepMC2.cc',
'extern/HepMC3/src/ReaderHEPEVT.cc',
'extern/HepMC3/src/ReaderLHEF.cc',
'extern/HepMC3/src/ReaderPlugin.cc',
'extern/HepMC3/src/Setup.cc',
'extern/HepMC3/src/WriterAscii.cc',
'extern/HepMC3/src/WriterAsciiHepMC2.cc',
'extern/HepMC3/src/WriterHEPEVT.cc',
'extern/HepMC3/src/WriterPlugin.cc',
])

# Installing shared library along with Python extension is currently not
# supported by meson-python for all platforms (currently only Linux)
# hepmc3 = library('hepmc3', src_hepmc3,
# include_directories: inc_hepmc3,
# cpp_args: ['-DHepMC3_EXPORTS=1'] + cpp.get_supported_arguments(
# '-Wno-deprecated-declarations',
# '-Wno-strict-aliasing',
# ),
# install=true
# )

src_core = files([
'src/attribute_conversion.cpp',
'src/attributes_view.cpp',
'src/core.cpp',
'src/crosssection_patches.cpp',
'src/equal.cpp',
'src/from_hepevt.cpp',
'src/io.cpp',
'src/pyiostream.cpp',
'src/repr.cpp',
'src/runinfo_attributes_view.cpp',
])

py.extension_module(
'_core', src_core + src_hepmc3,
include_directories: [inc_pybind11, inc_hepmc3],
dependencies: [
mp11,
accessor,
],
cpp_args: ['-DHepMC3_EXPORTS=1'] + cpp.get_supported_arguments(
'-Wno-self-assign-overloaded',
'-Wno-deprecated-declarations',
'-Wno-strict-aliasing'),
subdir: 'pyhepmc',
install: true
)

py.install_sources(
'src/pyhepmc/__init__.py',
'src/pyhepmc/_attributes.py',
'src/pyhepmc/_autodoc.py',
'src/pyhepmc/_deprecated.py',
'src/pyhepmc/_doc.py',
'src/pyhepmc/_graphviz.py',
'src/pyhepmc/_prettify.py',
'src/pyhepmc/_setup.py',
'src/pyhepmc/io.py',
'src/pyhepmc/view.py',
subdir: 'pyhepmc'
)
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[build-system]
requires = [
"setuptools>=46.4",
"setuptools_scm[toml]>=6.2",
"cmake>=3.13",
"wheel"
"meson-python",
"ninja",
"pybind11",
]
build-backend = "setuptools.build_meta"
build-backend = "mesonpy"

[project]
name = "pyhepmc"
version = "2.10.0.dev"
description = "Pythonic interface to the HepMC3 C++ library licensed under LGPL-v3."
maintainers = [
{ name = "Hans Dembinski" },
Expand All @@ -28,7 +28,6 @@ classifiers = [
"Intended Audience :: Developers"
]
dependencies = ["numpy"]
dynamic = ["version"]

[project.urls]
repository = "https://github.com/scikit-hep/pyhepmc"
Expand All @@ -37,6 +36,7 @@ documentation = "https://scikit-hep.org/pyhepmc"
[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"particle",
"matplotlib"
]
Expand Down
6 changes: 6 additions & 0 deletions quote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!python3
import sys


for line in sorted(sys.stdin.readlines()):
print(f"'{line.strip()}',")
Loading