fpm
fpm copied to clipboard
FPM pip installation
Description
This is a follow up from this discussion: https://github.com/fortran-lang/fpm/discussions/696
The short summary is that if we wish to deploy fpm
through VS Code it would be easier to do so through pip
rather than conda
.
Possible Solution
We would have to build the binary for multiple distributions and package them in a bdist python wheel.
TODO:
- [ ] Claim via PEP 541 request the
fpm
from the name squatter. - [ ] Use an GitHub Actions CI to build the multiple wheels: CMake build can server as a good example and cibuildwheel
- [ ] A
setup.py
to package the wheels. A quick MWE for setup.py could look something like this (although I think thatdata_files
might be/becoming deprecated)
import os
import glob
import setuptools
name = "fpm"
FPM_ROOT = os.environ["FPM_ROOT"]
INSTALL_ROOT = os.environ["INSTALL_ROOT"]
VERSION = os.environ["VERSION"]
exes = glob.glob(os.path.join(INSTALL_ROOT, "bin/*"))
data_files = [("bin", exes)]
setuptools.setup(
name=name,
version=VERSION,
description="...",
long_description=open("README.md"), "r").read(),
long_description_content_type="text/markdown",
author="...",
author_email="...",
maintainer="...",
keywords="...",
url="...",
license="...",
platforms="...",
classifiers=[...],
package_dir={"": os.path.join(os.getcwd(), "build")},
data_files=data_files,
)
Additional Information
- I am still uncertain as to how to build wheels for M1/M2 computers.
- CMake uses
qemu
which AFAIK is not offered directly from a GitHub Action, so we would have to figure out how to set up a workflow.
A comment on building wheels for Apple Silicon - I've thought a lot about this and I think you have three options at the moment:
- Self-hosted CI runner
- Cross-compiling - this is what they do on conda-forge
- Manually building on your own machine
I had some success with using scikit-build which takes care of thinking about setup.py
. You can check out my setup for building wheels on GitHub Actions here (not for M1 as they don't have runners). I think I have read somewhere that you could in principle hi-jack the conda-forge CI to build wheels at the same time as you build fpm for Apple Silicon, but I'm not sure that they would look kindly on that 😄
I think I have read somewhere that you could in principle hi-jack the conda-forge CI to build wheels at the same time as you build fpm for Apple Silicon, but I'm not sure that they would look kindly on that smile
I have been using the conda-forge setup (the docker images and the (cross-)compiler toolchains) for building wheels. For Linux this works fine, but you have to be careful, since the GLIBC version in the comp7 image is too old to run GH actions, the cos7 image is fine.
For MacOS however there is a problem with delocate, which cannot pickup the libraries from the conda environment due to rpath linking correctly, the (cross-)compilation itself works fine. Not sure how easy this can be fixed.
We could also use the conda-forge CI setup, since the tooling is all available and open for exactly this reason.
Is this a problem with the rpaths of the conda libs being wrong, or that delocate will not pick them up? In principle we could copy the libs to a custom directory and modify the runpaths.
For a nice working example, you could have a look here (skbuild based): https://github.com/ssciwr/clang-format-wheel
They use scikitbuild which we can't because we don't make use of cmake. We would have to keep a cmake installation alongside the fpm one or have a dummy cmake installation that calls fpm build and fpm install. Then we have to repair the wheels because we use libc, which is not necessarily easy.