diff options
-rw-r--r-- | cerbero/bootstrap/build_tools.py | 20 | ||||
-rw-r--r-- | cerbero/config.py | 5 |
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: |