diff --git a/.github/actions/build-py/action.yml b/.github/actions/build-py/action.yml index 757f9f58a0..bd6f92e4ad 100644 --- a/.github/actions/build-py/action.yml +++ b/.github/actions/build-py/action.yml @@ -6,24 +6,35 @@ inputs: required: true runs: using: "composite" - steps: + steps: + - name: Configure Git safe directory + shell: bash + run: git config --global --add safe.directory /__w/memilio/memilio - name: Install dependencies shell: bash run: yum install ninja-build cmake git -qy - name: Make artifact dir shell: bash run: | - cd pycode/memilio-${{ inputs.package }}/ + if [ "${{ inputs.package }}" != "simulation" ]; then + cd pycode/memilio-${{ inputs.package }}/ + # else stay in root directory + fi mkdir wheelhouse - name: Build Python Wheels shell: bash run: | - cd pycode/memilio-${{ inputs.package }}/ + if [ "${{ inputs.package }}" != "simulation" ]; then + cd pycode/memilio-${{ inputs.package }}/ + # else stay in root directory + fi /opt/python/cp38-cp38/bin/python -m pip install --upgrade pip setuptools wheel /opt/python/cp38-cp38/bin/python -m pip install scikit-build scikit-build-core + /opt/python/cp38-cp38/bin/python -m pip install setuptools-scm /opt/python/cp38-cp38/bin/python -m build --no-isolation --wheel /opt/python/cp312-cp312/bin/python -m pip install --upgrade pip setuptools wheel /opt/python/cp312-cp312/bin/python -m pip install scikit-build scikit-build-core + /opt/python/cp312-cp312/bin/python -m pip install setuptools-scm /opt/python/cp312-cp312/bin/python -m build --no-isolation --wheel # 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 @@ -33,9 +44,14 @@ runs: # no auditwheel necessary for pure python packages, so only copy the wheels to the same output directory cp dist/*.whl wheelhouse fi - cp -r wheelhouse .. + if [ "${{ inputs.package }}" != "simulation" ]; then + cp -r wheelhouse .. + else + cp -r wheelhouse pycode + fi - name: Upload Python Wheels - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: python-wheels-${{ inputs.package }} path: pycode/wheelhouse + diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000000..528a3c8dc4 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,61 @@ +name: PyPI + +on: [release] +# remove following line before merge: +# on: [pull_request, release] + +jobs: + + build_wheels: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: pypa/cibuildwheel@v2.16 + + - uses: actions/upload-artifact@v6 + with: + name: cibw-wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl + + build_sdist: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - run: pipx run build --sdist + + - uses: actions/upload-artifact@v6 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v8 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true + # To test uploads to TestPyPI, uncomment the following: + # repository-url: https://test.pypi.org/legacy/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..15b092d12f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.13) +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/README.md b/README.md index 3e43d6499e..9105fa1c85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MEmilio - a high performance Modular EpideMIcs simuLatIOn software # -![memilio_logo](docs/memilio-small.png) +![memilio_logo](https://github.com/SciCompMod/memilio/blob/main/docs/memilio-small.png?raw=true) [![CI](https://github.com/SciCompMod/memilio/actions/workflows/main.yml/badge.svg)](https://github.com/SciCompMod/memilio/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/SciCompMod/memilio/branch/main/graph/badge.svg?token=DVQXIQJHBM)](https://codecov.io/gh/SciCompMod/memilio) diff --git a/pycode/memilio-simulation/CMakeLists.txt b/pycode/memilio-simulation/CMakeLists.txt index f54390d920..94ae9184b0 100644 --- a/pycode/memilio-simulation/CMakeLists.txt +++ b/pycode/memilio-simulation/CMakeLists.txt @@ -1,9 +1,3 @@ -cmake_minimum_required(VERSION 3.13) -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) @@ -52,9 +46,6 @@ 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/README.md b/pycode/memilio-simulation/README.md index 76f0ab82e7..8f23dc82a0 100644 --- a/pycode/memilio-simulation/README.md +++ b/pycode/memilio-simulation/README.md @@ -6,10 +6,10 @@ This package contains Python bindings for the MEmilio C++ library. It enables se This project is configured via ``pyproject.toml`` and is built with [scikit-build-core](https://scikit-build-core.readthedocs.io). CMake and Ninja must be available on the system. The package uses the [Pybind11 C++ library](https://pybind11.readthedocs.io) to create the bindings. -To install the package, use the command (from the directory containing ``pyproject.toml``) +To install the package, use the command ```bash -pip install . +pip install memilio-simulation ``` This builds the C++ library and C++ Python extension module and copies everything required to your site-packages. @@ -30,7 +30,7 @@ Alternatively, edit the `CMakeCache.txt` in the directory created by scikit-buil ## Development -For developement of the cpp bindings use +For developement of the cpp bindings use the following command from the root of this repository (i.e. the directory containing ``pyproject.toml``) ```bash pip install -e .[dev] diff --git a/pycode/memilio-simulation/pyproject.toml b/pycode/memilio-simulation/pyproject.toml deleted file mode 100644 index d7bc24b90f..0000000000 --- a/pycode/memilio-simulation/pyproject.toml +++ /dev/null @@ -1,39 +0,0 @@ -[build-system] -requires = [ - "scikit-build-core>=0.9.0", - "setuptools>=68", - "wheel" -] -build-backend = "scikit_build_core.build" - -[project] -name = "memilio-simulation" -version = "1.0.0" -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 = { text = "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" -] - -[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" diff --git a/pyproject.toml b/pyproject.toml index 2f12cc6b19..94eb44e596 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,54 @@ +[project] +name = "memilio-simulation" +dynamic = ["version"] +# remove following line before merge: +# version = "2.3.0" +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" +] + +[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"] + [tool.autopep8] max-line-length = 79