OpenModelica / OMSimulator

The OpenModelica FMI & SSP-based co-simulation environment.
Other
67 stars 49 forks source link

Recover changes to build PyPI package #1276

Open lochel opened 7 months ago

lochel commented 7 months ago

This recoveres some changes to create a PyPI package for OMSimulator, but I'm uncertain about the current state of the changes. I would appreciate insights from @mahge on the best approach before proceeding further.

To generate the PyPI package, follow these steps:

  1. Build the project using the OM_OMS_ENABLE_PIP option in CMake:

    cmake -S . -B build/ -DCMAKE_INSTALL_PREFIX=install/ -DOM_OMS_ENABLE_PIP=ON
    cmake --build build/ --target install
  2. Run the Makefile:

    make pip
  3. Upload the package using twine:

    twine upload src/pip/install/dist/OMSimulator-2.1.1.post248.tar.gz
lochel commented 7 months ago

Please be aware that the nightly builds are currently broken, preventing us from uploading new packages.

Exception: Downloading artifact failed for https://build.openmodelica.org/omsimulator/nightly/linux-amd64/OMSimulator-linux-amd64-v2.1.1.post248-gf7c50c9.tar.gz

lochel commented 7 months ago

@mahge We can even remove the Makefile - it doesn't do much except for executing a python script.

mahge commented 7 months ago

@mahge We can even remove the Makefile - it doesn't do much except for executing a python script.

Then we can probably do it in the existing src/pip/CMakeLists.txt.

lochel commented 7 months ago

Sounds good 😊 any suggestions on how to do it?

mahge commented 7 months ago

Sounds good 😊 any suggestions on how to do it?

Of course 🙂. Something like this in the src/pip/CMakeLists.txt should be enough to create the packages. We can test it and adjust it as needed.

add_custom_target(omsimulator-pip-package
                  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/setup.py
                  COMMAND python3 setup.py sdist
                  COMMENT "Creating OMSimulator pip package."
                  )

This will create a target named omsimulator-pip-package. One can then, for example, run make omsimulator-pip-package in the build directory to create the packages.