summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2023-01-25 20:10:12 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2023-02-21 20:28:50 +0530
commit3a5859823fbdb44f82a83dc2968da073e12d06e3 (patch)
tree792238eba297253f5d7773e811408c858ea12425
parent3ace9b0129f298952b928e8ab65cfe97572db1bf (diff)
cerbero: Fix setuptools site.py breakage in Python 3.11
We can use a proper Python virtual env, and it'll work out of the box. There might be some weirdness with the fact that we use two prefixes: build-tools and the target prefix, but that might just mean adding a second site-packages prefix somehow. In any case, python bindings are disabled right now, so not a blocker. Fixes https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/406 Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1097>
-rw-r--r--cerbero/bootstrap/build_tools.py20
-rw-r--r--cerbero/config.py5
2 files changed, 23 insertions, 2 deletions
diff --git a/cerbero/bootstrap/build_tools.py b/cerbero/bootstrap/build_tools.py
index b8762256..864b2dad 100644
--- a/cerbero/bootstrap/build_tools.py
+++ b/cerbero/bootstrap/build_tools.py
@@ -17,6 +17,9 @@
# Boston, MA 02111-1307, USA.
import os
+import sys
+import venv
+import glob
import sysconfig
import shutil
@@ -121,8 +124,23 @@ class BuildTools (BootstrapperBase, Fetch):
src_file = os.path.join(os.path.dirname(__file__), 'site-patch.py')
shutil.copy(src_file, py_prefix / 'site.py')
+ def setup_venv(self):
+ venv.create(self.config.build_tools_prefix, with_pip=True)
+ if self.config.platform == Platform.WINDOWS:
+ # Python insists on using Scripts instead of bin on Windows for
+ # scripts. Insist back, and use bin again.
+ scriptsdir = os.path.join(self.config.build_tools_prefix, 'Scripts')
+ bindir = os.path.join(self.config.build_tools_prefix, 'bin')
+ os.mkdir(bindir)
+ for f in glob.glob('*', root_dir=scriptsdir):
+ shutil.move(os.path.join(scriptsdir, f), bindir)
+ os.rmdir(scriptsdir)
+
def start(self, jobs=0):
- self.insert_python_site()
+ if sys.version_info >= (3, 11, 0):
+ self.setup_venv()
+ else:
+ self.insert_python_site()
# Check and these at the last minute because we may have installed them
# in system bootstrap
self.recipes += self.check_build_tools()
diff --git a/cerbero/config.py b/cerbero/config.py
index 363da88a..b967d0bc 100644
--- a/cerbero/config.py
+++ b/cerbero/config.py
@@ -181,7 +181,6 @@ class Config (object):
def __init__(self, is_build_tools_config=False):
self._check_uninstalled()
- self.python_exe = Path(sys.executable).as_posix()
self.build_tools_config = None
self._is_build_tools_config = is_build_tools_config
@@ -793,6 +792,10 @@ class Config (object):
self.set_property('cache_file', platform_arch + ".cache")
self.set_property('install_dir', self.prefix)
self.set_property('local_sources', self._default_local_sources_dir())
+ if sys.version_info >= (3, 11, 0):
+ self.python_exe = Path(self.build_tools_prefix, 'bin', 'python').as_posix()
+ else:
+ self.python_exe = Path(sys.executable).as_posix()
def _find_data_dir(self):
if self.uninstalled: