From a7681597b7588e8ca3b95c4a4b1145fdc0630e8f Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 13 May 2026 14:19:56 +0200 Subject: [PATCH 1/3] move build files into pycode/memilio-simulation and update actions --- .github/actions/build-py/action.yml | 37 +++++--------- .github/workflows/pypi.yml | 12 +++-- CMakeLists.txt | 10 ---- pycode/memilio-simulation/CMakeLists.txt | 9 ++++ pycode/memilio-simulation/pyproject.toml | 61 +++++++++++++++++++++++ pyproject.toml | 63 ------------------------ 6 files changed, 91 insertions(+), 101 deletions(-) delete mode 100644 CMakeLists.txt create mode 100644 pycode/memilio-simulation/pyproject.toml diff --git a/.github/actions/build-py/action.yml b/.github/actions/build-py/action.yml index 4900f92333..1f29bd3f85 100644 --- a/.github/actions/build-py/action.yml +++ b/.github/actions/build-py/action.yml @@ -16,29 +16,22 @@ runs: - name: Make artifact dir shell: bash run: | - if [ "${{ inputs.package }}" != "simulation" ]; then - cd pycode/memilio-${{ inputs.package }}/ - # else stay in root directory - fi + cd pycode/memilio-${{ inputs.package }}/ mkdir wheelhouse - name: Build Python Wheels shell: bash run: | - if [ "${{ inputs.package }}" != "simulation" ]; then - cd pycode/memilio-${{ inputs.package }}/ - # else stay in root directory - fi - /opt/python/cp39-cp39/bin/python -m pip install --upgrade pip setuptools wheel - /opt/python/cp313-cp313/bin/python -m pip install --upgrade pip setuptools wheel - /opt/python/cp39-cp39/bin/python -m pip install scikit-build scikit-build-core - /opt/python/cp313-cp313/bin/python -m pip install scikit-build scikit-build-core - # Install setuptools-scm only for memilio-simulation - if [ "${{ inputs.package }}" == "simulation" ]; then - /opt/python/cp39-cp39/bin/python -m pip install setuptools-scm - /opt/python/cp313-cp313/bin/python -m pip install setuptools-scm - fi - /opt/python/cp39-cp39/bin/python -m build --no-isolation --wheel - /opt/python/cp313-cp313/bin/python -m build --no-isolation --wheel + cd pycode/memilio-${{ inputs.package }}/ + # install dependencies and build wheels with specified python versions + for python_cmd in /opt/python/cp39-cp39/bin/python /opt/python/cp313-cp313/bin/python + do + $python_cmd -m pip install --upgrade pip setuptools wheel + $python_cmd -m pip install scikit-build scikit-build-core + if [ "${{ inputs.package }}" == "simulation" ] + then $python_cmd -m pip install setuptools-scm + fi + $python_cmd -m build --no-isolation --wheel + done # Exclude memilio-generation, because its a pure python package, cmake is only used in the build process to retrieve data from cpp if [[ -f "CMakeLists.txt" ]] && [ "${{ inputs.package }}" != "generation" ]; then # includes native dependencies in the wheel @@ -47,11 +40,7 @@ runs: # no auditwheel necessary for pure python packages, so only copy the wheels to the same output directory cp dist/*.whl wheelhouse fi - if [ "${{ inputs.package }}" != "simulation" ]; then - cp -r wheelhouse .. - else - cp -r wheelhouse pycode - fi + cp -r wheelhouse .. - name: Upload Python Wheels uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 81d32b0dba..08482e110e 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -19,11 +19,13 @@ jobs: fetch-depth: 0 - uses: pypa/cibuildwheel@v3.4.1 - + with: + package-dir: pycode/memilio-simulation + - uses: actions/upload-artifact@v7 with: name: cibw-wheels-${{ matrix.os }} - path: ./wheelhouse/*.whl + path: wheelhouse/*.whl build_sdist: runs-on: ubuntu-latest @@ -33,12 +35,14 @@ jobs: with: fetch-depth: 0 - - run: pipx run build --sdist + - run: | + cd pycode/memilio-simulation + pipx run build --sdist - uses: actions/upload-artifact@v7 with: name: cibw-sdist - path: dist/*.tar.gz + path: pycode/memilio-simulation/dist/*.tar.gz upload_pypi: needs: [build_wheels, build_sdist] diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 0a29cfcdba..0000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(memilio-simulation) - -set(CMAKE_CXX_STANDARD "20") -set(CMAKE_CXX_STANDARD_REQUIRED "20") - -# add in C++ library -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cpp ${CMAKE_CURRENT_BINARY_DIR}/cpp EXCLUDE_FROM_ALL) - -add_subdirectory(pycode/memilio-simulation) \ No newline at end of file diff --git a/pycode/memilio-simulation/CMakeLists.txt b/pycode/memilio-simulation/CMakeLists.txt index c2ec86222e..8fd0f1bb2d 100644 --- a/pycode/memilio-simulation/CMakeLists.txt +++ b/pycode/memilio-simulation/CMakeLists.txt @@ -1,3 +1,9 @@ +cmake_minimum_required(VERSION 3.14) +project(memilio-python) + +set(CMAKE_CXX_STANDARD "20") +set(CMAKE_CXX_STANDARD_REQUIRED "20") + option(MEMILIO_USE_BUNDLED_PYBIND11 "Use pybind11 bundled with this library." ON) mark_as_advanced(MEMILIO_USE_BUNDLED_PYBIND11) @@ -48,6 +54,9 @@ else() find_package(pybind11 REQUIRED) endif() +# add in C++ library +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../cpp ${CMAKE_CURRENT_BINARY_DIR}/cpp EXCLUDE_FROM_ALL) + # a list of all "LINKED_LIBRARIES" that are given to add_pymio_module. will contain duplicates # used for wheel installation set(PYMIO_MEMILIO_LIBS_LIST) diff --git a/pycode/memilio-simulation/pyproject.toml b/pycode/memilio-simulation/pyproject.toml new file mode 100644 index 0000000000..1910e9efd6 --- /dev/null +++ b/pycode/memilio-simulation/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = [ + "scikit-build-core>=0.9.0", + "setuptools>=68", + "setuptools-scm>=8", + "wheel" +] +build-backend = "scikit_build_core.build" + +[project] +name = "memilio-simulation" +dynamic = ["version"] +description = "Part of MEmilio project, Python bindings to the C++ libraries that contain the models and simulations." +readme = "README.md" +requires-python = ">=3.8" +license = "Apache-2.0" +authors = [{ name = "MEmilio Team" }] +maintainers = [ + { email = "martin.kuehn@dlr.de" } +] +dependencies = [ + # smaller numpy versions cause a security issue, 1.25 does not work together with pyfakefs + "numpy>=1.22,!=1.25.*", + # smaller pandas versions contain a bug that sometimes prevents reading + "pandas>=2.0.0" +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows" +] + +[project.optional-dependencies] +dev = [] + +[project.urls] +Homepage = "https://github.com/SciCompMod/memilio" +Team = "https://memilio.readthedocs.io/en/latest/team.html" + +[tool.scikit-build] +cmake.version = ">=3.13" +cmake.args = ["-DMEMILIO_BUILD_SHARED_LIBS:BOOL=ON"] +wheel.packages = ["memilio"] +wheel.install-dir = "memilio/simulation" +build-dir = "../build/memilio-simulation" +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" + +[tool.setuptools_scm] +local_scheme = "no-local-version" + +[tool.cibuildwheel] +# Disable some wheels +skip = ["pp*", "*musllinux*", "*-win32", "cp314*"] diff --git a/pyproject.toml b/pyproject.toml index 700e294c30..f8f0684268 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,66 +1,3 @@ -[project] -# Note that this file is only installing the memilio-simulation package. For installing the other Python packages, -# please go to the respective folder pycode/memilio-* and install from there. -name = "memilio-simulation" -dynamic = ["version"] -description = "Part of MEmilio project, Python bindings to the C++ libraries that contain the models and simulations." -readme = "README.md" -requires-python = ">=3.9" -license = "Apache-2.0" -authors = [{ name = "MEmilio Team" }] -maintainers = [ - { email = "martin.kuehn@dlr.de" } -] -dependencies = [ - # smaller numpy versions cause a security issue, 1.25 does not work together with pyfakefs - "numpy>=1.22,!=1.25.*", - # smaller pandas versions contain a bug that sometimes prevents reading - "pandas>=2.0.0" -] -classifiers = [ - "Development Status :: 5 - Production/Stable", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows" -] - -[project.optional-dependencies] -dev = [] - -[project.urls] -Homepage = "https://github.com/SciCompMod/memilio" -Team = "https://memilio.readthedocs.io/en/latest/team.html" - -[build-system] -requires = [ - "scikit-build-core>=0.9.0", - "setuptools>=68", - "setuptools-scm>=8", - "wheel" -] -build-backend = "scikit_build_core.build" - -[tool.scikit-build] -cmake.version = ">=3.13" -cmake.args = ["-DMEMILIO_BUILD_SHARED_LIBS:BOOL=ON"] -wheel.packages = ["pycode/memilio-simulation/memilio"] -wheel.install-dir = "memilio/simulation" -build-dir = "pycode/build/memilio-simulation" -metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" - -[tool.setuptools_scm] -local_scheme = "no-local-version" - -[tool.cibuildwheel] -# Disable some wheels -skip = ["pp*", "*musllinux*", "*-win32", "cp314*"] - [tool.autopep8] max-line-length = 79 From 2e58f8362db92141e6cef900c061962812fcfda6 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 13 May 2026 14:39:13 +0200 Subject: [PATCH 2/3] try pointing scm to the git project root --- pycode/memilio-simulation/pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pycode/memilio-simulation/pyproject.toml b/pycode/memilio-simulation/pyproject.toml index 1910e9efd6..29179f8839 100644 --- a/pycode/memilio-simulation/pyproject.toml +++ b/pycode/memilio-simulation/pyproject.toml @@ -55,6 +55,8 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" [tool.setuptools_scm] local_scheme = "no-local-version" +# point scm to the git project root, if no other version info (like releases) is found +fallback_root = "../.." [tool.cibuildwheel] # Disable some wheels From babdf9e787c420bfee534bb81e5020eeae96e295 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 13 May 2026 14:59:18 +0200 Subject: [PATCH 3/3] try setting root in general --- pycode/memilio-simulation/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pycode/memilio-simulation/pyproject.toml b/pycode/memilio-simulation/pyproject.toml index 29179f8839..d7ba6164f3 100644 --- a/pycode/memilio-simulation/pyproject.toml +++ b/pycode/memilio-simulation/pyproject.toml @@ -55,8 +55,8 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" [tool.setuptools_scm] local_scheme = "no-local-version" -# point scm to the git project root, if no other version info (like releases) is found -fallback_root = "../.." +# point scm to the git project root +root = "../.." [tool.cibuildwheel] # Disable some wheels