diff --git a/.github/workflows/readme_listings.yml b/.github/workflows/readme_listings.yml index 11be2ee4..341fd713 100644 --- a/.github/workflows/readme_listings.yml +++ b/.github/workflows/readme_listings.yml @@ -130,11 +130,6 @@ jobs: - run: python -c "import pytest_codeblocks; code=pytest_codeblocks.extract_from_file('README.md'); f=open('readme.m', 'w'); f.writelines(block.code for block in code if block.syntax=='Matlab'); f.close()" - run: cat -n readme.m - # see https://github.com/pybind/cmake_example/pull/164 - - run: | - echo "pybind11_type=type" > pybind11_builtins.py - echo "PYTHONPATH=." >> $GITHUB_ENV - - uses: matlab-actions/setup-matlab@v0 with: release: R2022a diff --git a/README.md b/README.md index 55e4cacd..5ccd83ae 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,6 @@ print(aero_state.masses()'aero_state.num_concs, "# kg/m3") notes (see the [PyPartMC Matlab CI workflow](https://github.com/open-atmos/PyPartMC/blob/main/.github/workflows/readme_listings.yml) for an example on how to achieve it on Ubuntu 20): - Matlab ships with convenience copies of C, C++ and Fortran runtime libraries which are `dlopened()` by default; one way to make PyPartMC OK with it is to [pip-]install by compiling from source using the very same version of GCC that Matlab borrowed these libraries from (e.g., [GCC 9 for Matlab R2022a, etc](https://www.mathworks.com/support/requirements/supported-compilers-linux.html)); - Matlab needs to [use the same Python interpretter/venv](https://www.mathworks.com/support/requirements/python-compatibility.html) as the pip invocation used to install PyPartMC; -- a single-line `pybind11_builtins.py` file with just `pybind11_type=type` inside needs to be placed within Matlab's `PYTHONPATH` to sort out a [Matlab-pybind11 incompatibility](https://github.com/pybind/pybind11/issues/3945). ````Matlab ppmc = py.importlib.import_module('PyPartMC'); diff --git a/src/pypartmc.cpp b/src/pypartmc.cpp index 5ddd1bf3..e5e0c765 100644 --- a/src/pypartmc.cpp +++ b/src/pypartmc.cpp @@ -60,7 +60,7 @@ PYBIND11_MODULE(_PyPartMC, m) { //m.def("run_sect", &run_sect, "Do a 1D sectional simulation (Bott 1998 scheme)."); //m.def("run_exact", &run_exact, "Do an exact solution simulation."); - py::class_>(m, "AeroData", + py::class_>(m, "AeroData", py::metaclass((PyObject *) &PyType_Type), R"pbdoc( Aerosol material properties and associated data. @@ -110,7 +110,7 @@ PYBIND11_MODULE(_PyPartMC, m) { "returns list of aerosol species names") ; - py::class_(m, "AeroParticle", + py::class_(m, "AeroParticle", py::metaclass((PyObject *) &PyType_Type), R"pbdoc( Single aerosol particle data structure. @@ -188,7 +188,7 @@ PYBIND11_MODULE(_PyPartMC, m) { "Sets the aerosol particle volumes.") ; - py::class_(m, "AeroState", + py::class_(m, "AeroState", py::metaclass((PyObject *) &PyType_Type), R"pbdoc( The current collection of aerosol particles. @@ -246,7 +246,7 @@ PYBIND11_MODULE(_PyPartMC, m) { .def("zero", AeroState::zero, "remove all particles from an AeroState") ; - py::class_>(m, "GasData", + py::class_>(m, "GasData", py::metaclass((PyObject *) &PyType_Type), R"pbdoc( Constant gas data. @@ -270,6 +270,7 @@ PYBIND11_MODULE(_PyPartMC, m) { py::class_(m, "EnvState", + py::metaclass((PyObject *) &PyType_Type), R"pbdoc( Current environment state. @@ -298,6 +299,7 @@ PYBIND11_MODULE(_PyPartMC, m) { py::class_(m, "Photolysis", + py::metaclass((PyObject *) &PyType_Type), R"pbdoc( PartMC interface to a photolysis module )pbdoc" @@ -307,6 +309,7 @@ PYBIND11_MODULE(_PyPartMC, m) { py::class_(m, "CampCore", + py::metaclass((PyObject *) &PyType_Type), R"pbdoc( An interface between PartMC and the CAMP )pbdoc" @@ -316,6 +319,7 @@ PYBIND11_MODULE(_PyPartMC, m) { py::class_(m, "Scenario", + py::metaclass((PyObject *) &PyType_Type), R"pbdoc( This is everything needed to drive the scenario being simulated. @@ -360,6 +364,7 @@ PYBIND11_MODULE(_PyPartMC, m) { py::class_(m, "GasState", + py::metaclass((PyObject *) &PyType_Type), R"pbdoc( Current state of the gas mixing ratios in the system. @@ -393,6 +398,7 @@ PYBIND11_MODULE(_PyPartMC, m) { py::class_(m, "RunPartOpt", + py::metaclass((PyObject *) &PyType_Type), "Options controlling the execution of run_part()." ) .def(py::init()) @@ -400,14 +406,14 @@ PYBIND11_MODULE(_PyPartMC, m) { .def_property_readonly("del_t", RunPartOpt::del_t, "time step") ; - py::class_(m,"BinGrid") + py::class_(m, "BinGrid", py::metaclass((PyObject *) &PyType_Type)) .def(py::init()) .def("__len__", BinGrid::__len__, "returns number of bins") .def_property_readonly("edges", BinGrid::edges, "Bin edges") .def_property_readonly("centers", BinGrid::centers, "Bin centers") ; - py::class_(m,"AeroMode") + py::class_(m, "AeroMode", py::metaclass((PyObject *) &PyType_Type)) .def(py::init()) .def_property("num_conc", &AeroMode::get_num_conc, &AeroMode::set_num_conc, "provides access (read or write) to the total number concentration of a mode") @@ -429,7 +435,7 @@ PYBIND11_MODULE(_PyPartMC, m) { "Mode name, used to track particle sources") ; - py::class_(m,"AeroDist") + py::class_(m, "AeroDist", py::metaclass((PyObject *) &PyType_Type)) .def(py::init, const nlohmann::json&>()) .def_property_readonly("n_mode", &AeroDist::get_n_mode, "Number of aerosol modes")