You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A standalone/frozen meson distribution proved a convenient solution for reproducible environments and worked great for the grand majority of projects that I tested.
However, for advanced use cases, I foresee a possible issue caused by meson using a Python version different (usually newer) than the Python installed in the system.
One such example that I encountered is the glib/qemu build scripts. I noticed that meson may complain about the packaging module missing, thus I added it to the standalone meson distribution. This allowed the meson setup step to complete.
However, during the actual build, there are a lot of Python scripts, and one of them uses the packaging module, which meson confirmed to be present. However the system Python did not include it, and the build failed. Possible issue may arise if the system Python is very old, meson may assume one behaviour and the system Python may exhibit a different one.
From a simplistic point of view, some may argue that in such use cases a standalone meson is not a good fit.
However, the convenience of not having to worry about Python versions during scripted builds, like in CI environments, made me look for a solution.
I did some experimentation with my build scripts, and it proved relatively easy to expose the embedded Python environment packed with meson for running other generic scripts.
For this I added alongside the meson binary, a meson-python3 binary. I know that meson runpython can be used to run generic Python scripts, but generally injecting export PYTHON=$(which meson-python3) into the environment is safer than using commands with arguments. Not to mention that I could not find a way to use meson runpython to install additional modules.
If both the meson binary, and the meson-python3 binary refer to the libpython shared/dynamic library, the extra space taken by the meson-python3 binary is negligible (just a few tens of KB in a 24 MB archive).
Installing new packages is possible via meson-python3 -m pip install ...; if really needed, a meson-pip3 can also be added, but in my opinion it is redundant.
My build scripts are able now to generate cross-platform binaries (macOS/Linux/Windows) that include the meson-python3 binary, and I'm ready to make a new release, but I wanted to know your opinion about this solution.
What do you think? Is this a useful feature for standalone/frozen distributions?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
A standalone/frozen meson distribution proved a convenient solution for reproducible environments and worked great for the grand majority of projects that I tested.
However, for advanced use cases, I foresee a possible issue caused by meson using a Python version different (usually newer) than the Python installed in the system.
One such example that I encountered is the glib/qemu build scripts. I noticed that meson may complain about the
packaging
module missing, thus I added it to the standalone meson distribution. This allowed themeson setup
step to complete.However, during the actual build, there are a lot of Python scripts, and one of them uses the
packaging
module, which meson confirmed to be present. However the system Python did not include it, and the build failed. Possible issue may arise if the system Python is very old, meson may assume one behaviour and the system Python may exhibit a different one.From a simplistic point of view, some may argue that in such use cases a standalone meson is not a good fit.
However, the convenience of not having to worry about Python versions during scripted builds, like in CI environments, made me look for a solution.
I did some experimentation with my build scripts, and it proved relatively easy to expose the embedded Python environment packed with meson for running other generic scripts.
For this I added alongside the
meson
binary, ameson-python3
binary. I know thatmeson runpython
can be used to run generic Python scripts, but generally injectingexport PYTHON=$(which meson-python3)
into the environment is safer than using commands with arguments. Not to mention that I could not find a way to usemeson runpython
to install additional modules.If both the
meson
binary, and themeson-python3
binary refer to thelibpython
shared/dynamic library, the extra space taken by themeson-python3
binary is negligible (just a few tens of KB in a 24 MB archive).Installing new packages is possible via
meson-python3 -m pip install ...
; if really needed, ameson-pip3
can also be added, but in my opinion it is redundant.My build scripts are able now to generate cross-platform binaries (macOS/Linux/Windows) that include the
meson-python3
binary, and I'm ready to make a new release, but I wanted to know your opinion about this solution.What do you think? Is this a useful feature for standalone/frozen distributions?
Beta Was this translation helpful? Give feedback.
All reactions