Editable installs and PKG_CONFIG_PATH on OSX #604
Replies: 6 comments 21 replies
-
This is not true. On Linux the $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install .
$ python -m flint.test -tq
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 112, in _get_module_details
File "/home/oscar/.pyenv/versions/tmp-python-flint/lib/python3.12/site-packages/flint/__init__.py", line 1, in <module>
from .pyflint import *
File "pyflint.pyx", line 1, in init flint.pyflint
File "flint_base.pyx", line 1, in init flint.flint_base.flint_base
ImportError: libflint.so.19: cannot open shared object file: No such file or directory
$ LD_LIBRARY_PATH=$(pwd)/.local/lib python -m flint.test -tq
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine! However if I build wheels with $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig python -m build
$ pip install dist/python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
$ python -m flint.test -tq # no need to set LD_LIBRARY_PATH
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine! Somehow on Linux the wheels generated by |
Beta Was this translation helpful? Give feedback.
-
Oh, no wait. I was forgetting $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install --editable . --no-build-isolation
$ python -m flint.test -tq
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine! Now that I try to reproduce everything in fully fresh environments it seems that many of the errors I previously found are not applicable or are coming up different. I need to test this more... |
Beta Was this translation helpful? Give feedback.
-
Okay, here is the original problem that I was investigating: $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install --no-build-isolation --editable . --no-clean
...
../../meson.build:8:10: ERROR: Dependency "gmp" not found, tried pkgconfig and framework In the log I find:
So somehow the |
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll take a look at spin. I remember looking at it a year ago but I think I was just a bit overwhelmed trying to learn about all the different parts needed for a complete setup (meson, ninja, meson-python, mesonpy, pip, build, spin, ...). One more question about storing environment variables. On OSX if I make wheels with
However when I do an editable install on Linux I can import and run the tests etc without setting Is the meson-python editable import hook adding the Is that stored in the build directory or in the editable install itself (maybe it doesn't matter since the two are tied together anyway)? |
Beta Was this translation helpful? Give feedback.
-
It links to some common system libraries and also to the GMP and MPFR that I build along with Flint: $ ldd .local/lib/libflint.so
linux-vdso.so.1 (0x00007ffeb845c000)
libmpfr.so.6 => /home/oscar/current/active/python-flint/.local/lib/libmpfr.so.6 (0x00007f7a8d000000)
libgmp.so.10 => /home/oscar/current/active/python-flint/.local/lib/libgmp.so.10 (0x00007f7a8e04b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7a8d319000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7a8cc00000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7a8e0f2000) After testing more carefully to remove all build directories and wheels, uninstall, purge the pip cache I find that This works: PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig python -m build
pip install dist/python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
python -m flint.test -tq However PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip wheel .
pip install python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
python -m flint.test -tq Likewise PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install .
python -m flint.test -tq On the other hand pip's editable install works: PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install --no-build-isolation --editable .
python -m flint.test -tq Here is $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip wheel .
Processing /home/oscar/current/active/python-flint
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: python-flint
Building wheel for python-flint (pyproject.toml) ... done
Created wheel for python-flint: filename=python_flint-0.6.0-cp312-cp312-linux_x86_64.whl size=2245204 sha256=8063c5e01e204acb2ac05c5613e716cc09304a63040596e9b92844e338ab5871
Stored in directory: /home/oscar/.cache/pip/wheels/43/a9/f3/a40987b38ff4b4f29c92a95fea492d058f662d2a310271e407
Successfully built python-flint
$ pip install python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
Processing ./python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
Installing collected packages: python-flint
Successfully installed python-flint-0.6.0
$ python -m flint.test -tq
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 112, in _get_module_details
File "/home/oscar/.pyenv/versions/python-flint-3.12/lib/python3.12/site-packages/flint/__init__.py", line 1, in <module>
from .pyflint import *
File "pyflint.pyx", line 1, in init flint.pyflint
File "flint_base.pyx", line 1, in init flint.flint_base.flint_base
ImportError: libflint.so.19: cannot open shared object file: No such file or directory
$ LD_LIBRARY_PATH=$(pwd)/.local/lib python -m flint.test -tq
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine!
---------------------------------------- Here is $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install .
Processing /home/oscar/current/active/python-flint
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: python-flint
Building wheel for python-flint (pyproject.toml) ... done
Created wheel for python-flint: filename=python_flint-0.6.0-cp312-cp312-linux_x86_64.whl size=2245204 sha256=ccafa952b6b9c275f3d02c1425c4191aa2bbc40e34fd3c517013938a7bb38fb0
Stored in directory: /home/oscar/.cache/pip/wheels/43/a9/f3/a40987b38ff4b4f29c92a95fea492d058f662d2a310271e407
Successfully built python-flint
Installing collected packages: python-flint
Successfully installed python-flint-0.6.0
$ python -m flint.test -tq
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 112, in _get_module_details
File "/home/oscar/.pyenv/versions/python-flint-3.12/lib/python3.12/site-packages/flint/__init__.py", line 1, in <module>
from .pyflint import *
File "pyflint.pyx", line 1, in init flint.pyflint
File "flint_base.pyx", line 1, in init flint.flint_base.flint_base
ImportError: libflint.so.19: cannot open shared object file: No such file or directory
$ LD_LIBRARY_PATH=$(pwd)/.local/lib python -m flint.test -tq
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine!
---------------------------------------- This is $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig python -m build
<snip longer output>
$ pip install dist/python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
Processing ./dist/python_flint-0.6.0-cp312-cp312-linux_x86_64.whl
Installing collected packages: python-flint
Successfully installed python-flint-0.6.0
$ python -m flint.test -tq
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine!
---------------------------------------- This is an editable build: $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pip install --no-build-isolation --editable .
Obtaining file:///home/oscar/current/active/python-flint
Checking if build backend supports build_editable ... done
Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: python-flint
Building editable for python-flint (pyproject.toml) ... done
Created wheel for python-flint: filename=python_flint-0.6.0-cp312-cp312-linux_x86_64.whl size=7451 sha256=fc90c9b87434a0a73d1c4085d30b32ce75ddd72c51e53c394a2c3a5d458eacc5
Stored in directory: /tmp/pip-ephem-wheel-cache-vwd9jqkj/wheels/43/a9/f3/a40987b38ff4b4f29c92a95fea492d058f662d2a310271e407
Successfully built python-flint
Installing collected packages: python-flint
Successfully installed python-flint-0.6.0
$ python -m flint.test -tq
Running tests...
flint.test: all 49 tests passed!
----------------------------------------
OK: Your installation of python-flint seems to be working just fine!
---------------------------------------- |
Beta Was this translation helpful? Give feedback.
-
Does this consideration not apply equally to Linux and OSX? This is what I get after extracting a wheel generate by $ otool -L dist/flint/types/fmpz.cpython-312-darwin.so
dist/flint/types/fmpz.cpython-312-darwin.so:
/Users/enojb/work/dev/python-flint/.local/lib/libflint.19.0.dylib (compatibility version 19.0.0, current version 19.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2) I can install this wheel and I can use it without needing to set |
Beta Was this translation helpful? Give feedback.
-
I am having trouble with editable installs of python-flint on OSX when using PKG_CONFIG_PATH. This follows #602 but it seemed better to break this out into a separate discussion. This is still related to the python-flint pull request flintlib/python-flint#129.
I am converting python-flint from setuptools to meson-python and as part of that I am using pkgconfig to locate its dependencies. Specifically python-flint depends on GMP, MPFR and Flint which are all C libraries. The current setuptools build uses environment variables like
LD_LIBRARY_PATH
to make everything work but usingpkgconfig
seems a lot better so I am trying to make that work for python-flint.To reproduce what I show below you first need to do:
The commit hash is the current tip of the
pr_meson_python
branch that I am using for flintlib/python-flint#129. Thebin/build_dependencies_unix.sh
script takes 5-10 minutes depending on how fast the computer is. It downloads and builds GMP, MPFR and Flint, builds them with--prefix=$(pwd)/.local
and installs all of them in the.local
directory inside thepython-flint
directory.At this point we are ready to build the
python-flint
extension modules and we can do e.g.:The fails because we need to tell
pkgconfig
to find the dependencies in the.local
directory. Instead we can do:However the above does not work for an editable install on OSX:
The above steps all work fine on Linux and there I can have an editable install and I can run
python -m flint.test
without needing to set any environment variables. Previously I think that the steps above were all working on OSX as well with meson-python. This problem has emerged since I switched to using pkgconfig andPKG_CONFIG_PATH
as advised in #602.Am I doing something wrong here?
Beta Was this translation helpful? Give feedback.
All reactions