From 99dfe82db150d344f68fdbe5868d64c364d56bb2 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Sun, 21 Aug 2022 14:25:15 +0200 Subject: [PATCH] Restore wheel generation (#22) --- .github/workflows/test.yml | 2 +- .github/workflows/wheels.yml | 4 +- pyproject.toml | 4 +- src/core.cpp | 109 ++++++++++++++++++++++------------- 4 files changed, 74 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9abccb7..5dae977 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,5 +30,5 @@ jobs: with: python-version: ${{ matrix.python-version }} - run: python -m pip install --upgrade pip wheel - - run: python -m pip install -v -e .[test] + - run: python -m pip install --prefer-binary -v -e .[test] - run: python -m pytest diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 33d5099..08ca4d7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -16,11 +16,11 @@ jobs: name: ${{ matrix.py }} ${{ matrix.os }} ${{ matrix.arch }} runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] arch: [auto] - py: [cp36, cp37, cp38, cp39, cp310] + py: [cp37, cp38, cp39, cp310] include: - os: macos-latest py: cp38 diff --git a/pyproject.toml b/pyproject.toml index 1e61be5..76c5973 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,9 @@ filterwarnings = [ ] [tool.cibuildwheel] -test-requires = "pytest" +# update skip when numpy wheels become available +skip = ["*-musllinux_*", "cp310-win32", "cp310-manylinux_i686"] +test-extras = ["test"] test-command = "python -m pytest {package}/tests" # to match numpy, we use manylinux2014 for cp310+ manylinux-x86_64-image = "manylinux2014" diff --git a/src/core.cpp b/src/core.cpp index 94c6693..a1d475d 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -20,7 +20,6 @@ #include #include -// #include "hepevt_wrapper.h" // #include "GzReaderAscii.h" void register_io(py::module& m); @@ -354,12 +353,7 @@ PYBIND11_MODULE(_core, m) { PyErr_SetString(PyExc_IndexError, "out of bounds"); throw py::error_already_set(); } - }) METH(length2, FourVector) METH(length, FourVector) METH(perp2, FourVector) - METH(perp, FourVector) METH(interval, FourVector) METH(pt, FourVector) - METH(m2, FourVector) METH(m, FourVector) METH(phi, FourVector) - METH(theta, FourVector) METH(eta, FourVector) METH(rap, FourVector) - METH(abs_eta, FourVector) METH(abs_rap, FourVector) - METH(is_zero, FourVector) + }) .def(py::self == py::self) .def(py::self != py::self) .def(py::self + py::self) @@ -370,11 +364,30 @@ PYBIND11_MODULE(_core, m) { .def(py::self -= py::self) .def(py::self *= double()) .def(py::self /= double()) - .def("__repr__", [](const FourVector& self) { - std::ostringstream os; - repr(os, self); - return os.str(); - }); + .def("__repr__", + [](const FourVector& self) { + std::ostringstream os; + repr(os, self); + return os.str(); + }) + // clang-format off + METH(length2, FourVector) + METH(length, FourVector) + METH(perp2, FourVector) + METH(perp, FourVector) + METH(interval, FourVector) + METH(pt, FourVector) + METH(m2, FourVector) + METH(m, FourVector) + METH(phi, FourVector) + METH(theta, FourVector) + METH(eta, FourVector) + METH(rap, FourVector) + METH(abs_eta, FourVector) + METH(abs_rap, FourVector) + METH(is_zero, FourVector) + // clang-format on + ; py::implicitly_convertible(); @@ -517,45 +530,59 @@ PYBIND11_MODULE(_core, m) { py::class_(m, "GenParticle") .def(py::init(), "momentum"_a = py::make_tuple(0, 0, 0, 0), "pid"_a = 0, "status"_a = 0) - PROP_RO_OL(parent_event, GenParticle, const GenEvent*) - PROP_RO(in_event, GenParticle) PROP_RO(id, GenParticle) + .def(py::self == py::self) + .def("__repr__", + [](const GenParticlePtr& self) { + std::ostringstream os; + repr(os, self); + return os.str(); + }) + // clang-format off + PROP_RO_OL(parent_event, GenParticle, const GenEvent*) + PROP_RO(in_event, GenParticle) + PROP_RO(id, GenParticle) // PROP_RO(data, GenParticle) PROP_RO_OL(production_vertex, GenParticle, ConstGenVertexPtr) - PROP_RO_OL(end_vertex, GenParticle, ConstGenVertexPtr) - PROP_RO_OL(parents, GenParticle, std::vector) - PROP_RO_OL(children, GenParticle, std::vector) + PROP_RO_OL(end_vertex, GenParticle, ConstGenVertexPtr) + PROP_RO_OL(parents, GenParticle, std::vector) + PROP_RO_OL(children, GenParticle, std::vector) // PROP_RO(ancestors, GenParticle) // PROP_RO(descendants, GenParticle) - PROP(pid, GenParticle) PROP(status, GenParticle) PROP(momentum, GenParticle) - PROP(generated_mass, GenParticle) METH(is_generated_mass_set, GenParticle) - METH(unset_generated_mass, GenParticle) - .def(py::self == py::self) - .def("__repr__", [](const GenParticlePtr& self) { - std::ostringstream os; - repr(os, self); - return os.str(); - }); + PROP(pid, GenParticle) + PROP(status, GenParticle) + PROP(momentum, GenParticle) + PROP(generated_mass, GenParticle) + METH(is_generated_mass_set, GenParticle) + METH(unset_generated_mass, GenParticle) + // clang-format on + ; py::class_(m, "GenVertex") .def(py::init(), "position"_a = py::make_tuple(0, 0, 0, 0)) - PROP_RO_OL(parent_event, GenVertex, const GenEvent*) - PROP_RO(in_event, GenVertex) PROP_RO(id, GenVertex) - PROP(status, GenVertex) + .def(py::self == py::self) + .def("__repr__", + [](const GenVertexPtr& self) { + std::ostringstream os; + repr(os, self); + return os.str(); + }) + // clang-format off + PROP_RO_OL(parent_event, GenVertex, const GenEvent*) + PROP_RO(in_event, GenVertex) + PROP_RO(id, GenVertex) + PROP(status, GenVertex) + PROP_RO_OL(particles_in, GenVertex, const std::vector&) + PROP_RO_OL(particles_out, GenVertex, const std::vector&) // PROP_RO(data, GenVertex) + PROP(position, GenVertex) METH_OL(add_particle_in, GenVertex, void, GenParticlePtr) - METH_OL(add_particle_out, GenVertex, void, GenParticlePtr) - METH_OL(remove_particle_in, GenVertex, void, GenParticlePtr) - METH_OL(remove_particle_out, GenVertex, void, GenParticlePtr) + METH_OL(add_particle_out, GenVertex, void, GenParticlePtr) + METH_OL(remove_particle_in, GenVertex, void, GenParticlePtr) + METH_OL(remove_particle_out, GenVertex, void, GenParticlePtr) // METH(particles, GenVertex) - PROP_RO_OL(particles_in, GenVertex, const std::vector&) - PROP_RO_OL(particles_out, GenVertex, const std::vector&) - PROP(position, GenVertex) METH(has_set_position, GenVertex) - .def(py::self == py::self) - .def("__repr__", [](const GenVertexPtr& self) { - std::ostringstream os; - repr(os, self); - return os.str(); - }); + METH(has_set_position, GenVertex) + // clang-format on + ; // py::class_(m, "GenParticleData"); // py::class_(m, "GenVertexData");