Mercurial > hg
comparison tests/run-tests.py @ 52204:f8d5001dd03e stable
run-tests: install wheel using --prefix instead of --user
--user does not work if a venv is enabled when calling run-tests.py
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 07 Nov 2024 23:13:32 +0100 |
parents | 1dbbb957bbe6 |
children | ba0a842e0907 |
comparison
equal
deleted
inserted
replaced
52203:5ea21e0c28aa | 52204:f8d5001dd03e |
---|---|
59 import random | 59 import random |
60 import re | 60 import re |
61 import shlex | 61 import shlex |
62 import shutil | 62 import shutil |
63 import signal | 63 import signal |
64 import site | |
65 import socket | 64 import socket |
66 import subprocess | 65 import subprocess |
67 import sys | 66 import sys |
68 import sysconfig | 67 import sysconfig |
69 import tempfile | 68 import tempfile |
3270 self._installdir = os.path.join(self._hgtmp, b"install") | 3269 self._installdir = os.path.join(self._hgtmp, b"install") |
3271 self._bindir = os.path.join(self._installdir, b"bin") | 3270 self._bindir = os.path.join(self._installdir, b"bin") |
3272 self._hgcommand = b'hg' | 3271 self._hgcommand = b'hg' |
3273 | 3272 |
3274 if self.options.wheel: | 3273 if self.options.wheel: |
3275 suffix = _sys2bytes(site.USER_SITE[len(site.USER_BASE) + 1 :]) | 3274 # pip installing a wheel does not have an --install-lib flag |
3275 # so we have to guess where the file will be installed. | |
3276 # | |
3277 # In addition, that location is not really stable, so we are | |
3278 # using awful symlink trrick later in `_installhg` | |
3279 v_info = sys.version_info | |
3280 suffix = os.path.join( | |
3281 b"lib", | |
3282 b"python%d.%d" % (v_info.major, v_info.minor), | |
3283 b"site-packages", | |
3284 ) | |
3276 else: | 3285 else: |
3277 suffix = os.path.join(b"lib", b"python") | 3286 suffix = os.path.join(b"lib", b"python") |
3278 self._pythondir = os.path.join(self._installdir, suffix) | 3287 self._pythondir = os.path.join(self._installdir, suffix) |
3279 | 3288 |
3280 # Force the use of hg.exe instead of relying on MSYS to recognize hg is | 3289 # Force the use of hg.exe instead of relying on MSYS to recognize hg is |
3824 b"pip", | 3833 b"pip", |
3825 b"install", | 3834 b"install", |
3826 wheel_path, | 3835 wheel_path, |
3827 b"--force", | 3836 b"--force", |
3828 b"--ignore-installed", | 3837 b"--ignore-installed", |
3829 b"--user", | 3838 b"--prefix", |
3839 self._installdir, | |
3830 b"--break-system-packages", | 3840 b"--break-system-packages", |
3831 ] | 3841 ] |
3832 if not WINDOWS: | 3842 if not WINDOWS: |
3833 # The --home="" trick works only on OS where os.sep == '/' | 3843 # The --home="" trick works only on OS where os.sep == '/' |
3834 # because of a distutils convert_path() fast-path. Avoid it at | 3844 # because of a distutils convert_path() fast-path. Avoid it at |
3915 except FileExistsError: | 3925 except FileExistsError: |
3916 pass | 3926 pass |
3917 | 3927 |
3918 makedirs(self._pythondir) | 3928 makedirs(self._pythondir) |
3919 makedirs(self._bindir) | 3929 makedirs(self._bindir) |
3930 if self.options.wheel is not None and not WINDOWS: | |
3931 # the wheel instalation location is not stable, so try to deal with | |
3932 # that to funnel it back where we need its. | |
3933 # | |
3934 # (mostly deals with Debian shenanigans) | |
3935 assert self._pythondir.endswith(b'site-packages') | |
3936 lib_dir = os.path.dirname(self._pythondir) | |
3937 dist_dir = os.path.join(lib_dir, b'dist-packages') | |
3938 os.symlink(b'./site-packages', dist_dir) | |
3939 os.symlink(b'.', os.path.join(self._installdir, b'local')) | |
3920 | 3940 |
3921 vlog("# Running", cmd) | 3941 vlog("# Running", cmd) |
3922 with open(installerrs, "wb") as logfile: | 3942 with open(installerrs, "wb") as logfile: |
3923 r = subprocess.call( | 3943 r = subprocess.call( |
3924 cmd, | 3944 cmd, |