mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.65k stars 1.64k forks source link

Meson and PyPy(3) and incorrect libdir #4841

Closed infirit closed 5 years ago

infirit commented 5 years ago

I was trying to build pygobject for pypy3 on Gentoo and ran into a problem. The problem was that meson consistently failed to get the dependency for it. However it did not fail on python.find_installation(). I first opened a report on pygobject and after some discussion and me poking at meson I found what was causing the problem for me on Gentoo. For reference see pygobject issue on [1].

I tracked it down to self.clib_compiler.find_library(libname, environment, libdirs) returning None. I was wondering what libdirs was and it looked wrong as it appends bin. On Gentoo it meant is ended up looking in /usr/lib64/pypy3/bin which does not exist. Dropping the bin part makes it work, see diff below [2].

I am not familiar enough with this module so dropping the bin may break other targets. @lazka suggest to use distutils.sysconfig.get_config_var('LIBDIR').

[1] https://gitlab.gnome.org/GNOME/pygobject/issues/299 [2]

diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 1d41165b..03e98a7b 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -138,7 +138,7 @@ class PythonDependency(ExternalDependency):
                 libname = 'pypy3-c'
             else:
                 libname = 'pypy-c'
-            libdir = os.path.join(self.variables.get('base'), 'bin')
+            libdir = os.path.join(self.variables.get('base'))
             libdirs = [libdir]
         else:
             libname = 'python{}'.format(self.version)
infirit commented 5 years ago

Now that I got it to build I ran into another problem. It looks like meson tries to install the pypy files in the wrong directory, /usr/lib/python3.5/site-packages/ instead of /usr/lib64/pypy3/site-packages/. See below a few example lines from the build log. I am done for today, I may look into this later this week.

[0/1] /usr/lib64/python-exec/python3.7/meson install --no-rebuild
Installing gi/_gi.pypy3-60-x86_64-linux-gnu.so to /var/tmp/portage/dev-python/pygobject-3.30.4/image//usr/lib/python3.5/site-packages/gi
Installing gi/_gi_cairo.pypy3-60-x86_64-linux-gnu.so to /var/tmp/portage/dev-python/pygobject-3.30.4/image//usr/lib/python3.5/site-packages/gi
lazka commented 5 years ago

It looks like meson tries to install the pypy files in the wrong directory, /usr/lib/python3.5/site-packages/ instead of /usr/lib64/pypy3/site-packages/.

I think this was fixed by https://bitbucket.org/pypy/pypy/commits/5ca68e43950be83 and will be in pypy7

lazka commented 5 years ago

I am not familiar enough with this module so dropping the bin may break other targets. @lazka suggest to use distutils.sysconfig.get_config_var('LIBDIR').

Turns out this works with the system pypy but not the portable one, there is not path pointing to the lib afaics. I think we should get the lib dirs from the build_ext distutils command (none in the pypy case) and if we are not linking against libpython then we should just continue even if no lib has been found.

infirit commented 5 years ago

It looks like meson tries to install the pypy files in the wrong directory, /usr/lib/python3.5/site-packages/ instead of /usr/lib64/pypy3/site-packages/.

I think this was fixed by https://bitbucket.org/pypy/pypy/commits/5ca68e43950be83 and will be in pypy7

Yeah, that looks like what I am seeing, thanks!

edit: Better but still in the wrong dir, pypy3.5/site-packages instead of pypy3/site-packages

edit2: For some reason Gentoo chose to use pypy3/sitepackages and not follow convention of pypymajor.minor/site-packages. I'll open a bug on Gentoo for this.

lazka commented 5 years ago

I've created #4873

lazka commented 5 years ago

fyi, https://bitbucket.org/pypy/pypy/src/release-pypy3.5-v7.0.0/ just got tagged upstream

infirit commented 5 years ago

@lazka thanks! I have pygobject and pycairo building and installing properly (import gi and cairo works!) with pypy3 7.0.0 on Gentoo.