mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
uninstalled: build and set PYTHONPATH
This commit is contained in:
parent
c42ec82de6
commit
72c43ce73f
1 changed files with 24 additions and 0 deletions
|
@ -11,6 +11,7 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import pathlib
|
||||||
|
|
||||||
from distutils.sysconfig import get_python_lib
|
from distutils.sysconfig import get_python_lib
|
||||||
|
|
||||||
|
@ -112,9 +113,29 @@ def get_subprocess_env(options, gst_version):
|
||||||
presets = set()
|
presets = set()
|
||||||
encoding_targets = set()
|
encoding_targets = set()
|
||||||
pkg_dirs = set()
|
pkg_dirs = set()
|
||||||
|
python_dirs = set()
|
||||||
if '--installed' in subprocess.check_output(meson + ['introspect', '-h']).decode():
|
if '--installed' in subprocess.check_output(meson + ['introspect', '-h']).decode():
|
||||||
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
|
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
|
||||||
for path, installpath in json.loads(installed_s.decode()).items():
|
for path, installpath in json.loads(installed_s.decode()).items():
|
||||||
|
installpath_parts = pathlib.Path(installpath).parts
|
||||||
|
path_parts = pathlib.Path(path).parts
|
||||||
|
|
||||||
|
# We want to add all python modules to the PYTHONPATH
|
||||||
|
# in a manner consistent with the way they would be imported:
|
||||||
|
# For example if the source path /home/meh/foo/bar.py
|
||||||
|
# is to be installed in /usr/lib/python/site-packages/foo/bar.py,
|
||||||
|
# we want to add /home/meh to the PYTHONPATH.
|
||||||
|
# This will only work for projects where the paths to be installed
|
||||||
|
# mirror the installed directory layout, for example if the path
|
||||||
|
# is /home/meh/baz/bar.py and the install path is
|
||||||
|
# /usr/lib/site-packages/foo/bar.py , we will not add anything
|
||||||
|
# to PYTHONPATH, but the current approach works with pygobject
|
||||||
|
# and gst-python at least.
|
||||||
|
if 'site-packages' in installpath_parts:
|
||||||
|
install_subpath = os.path.join(*installpath_parts[installpath_parts.index('site-packages') + 1:])
|
||||||
|
if path.endswith(install_subpath):
|
||||||
|
python_dirs.add(path[:len (install_subpath) * -1])
|
||||||
|
|
||||||
if path.endswith('.prs'):
|
if path.endswith('.prs'):
|
||||||
presets.add(os.path.dirname(path))
|
presets.add(os.path.dirname(path))
|
||||||
elif path.endswith('.gep'):
|
elif path.endswith('.gep'):
|
||||||
|
@ -139,6 +160,9 @@ def get_subprocess_env(options, gst_version):
|
||||||
'gst-plugins-good',
|
'gst-plugins-good',
|
||||||
'pkgconfig'))
|
'pkgconfig'))
|
||||||
|
|
||||||
|
for python_dir in python_dirs:
|
||||||
|
prepend_env_var(env, 'PYTHONPATH', python_dir)
|
||||||
|
|
||||||
mesonpath = os.path.join(SCRIPTDIR, "meson")
|
mesonpath = os.path.join(SCRIPTDIR, "meson")
|
||||||
if os.path.join(mesonpath):
|
if os.path.join(mesonpath):
|
||||||
# Add meson/ into PYTHONPATH if we are using a local meson
|
# Add meson/ into PYTHONPATH if we are using a local meson
|
||||||
|
|
Loading…
Reference in a new issue