ci: extract pip bootstrapping into compilation/ensure_pip.py to fix yaml scalar parsing
CI Test Suite / Run Component Tests & Pipeline Verification (push) Failing after 1m29s
CI Test Suite / Run Component Tests & Pipeline Verification (push) Failing after 1m29s
This commit is contained in:
+1
-22
@@ -22,28 +22,7 @@ jobs:
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
# 1. Ensure Python3 is present; try apt-get only if missing
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends python3 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Bootstrap pip via ensurepip or version-appropriate get-pip.py
|
||||
if ! python3 -m pip --version >/dev/null 2>&1; then
|
||||
python3 -m ensurepip --default-pip 2>/dev/null || python3 -c "
|
||||
import sys, urllib.request, subprocess
|
||||
ver = f'{sys.version_info.major}.{sys.version_info.minor}'
|
||||
url = f'https://bootstrap.pypa.io/pip/{ver}/get-pip.py' if sys.version_info < (3, 10) else 'https://bootstrap.pypa.io/get-pip.py'
|
||||
print(f'[*] Downloading get-pip.py from {url} for Python {ver}...')
|
||||
urllib.request.urlretrieve(url, '/tmp/get-pip.py')
|
||||
subprocess.run([sys.executable, '/tmp/get-pip.py', '--break-system-packages'])
|
||||
" || true
|
||||
fi
|
||||
|
||||
# 3. Upgrade pip and install project dependencies
|
||||
python3 compilation/ensure_pip.py
|
||||
python3 -m pip install --upgrade pip --break-system-packages 2>/dev/null || python3 -m pip install --upgrade pip 2>/dev/null || true
|
||||
python3 -m pip install -r compilation/requirements.txt --break-system-packages 2>/dev/null || python3 -m pip install -r compilation/requirements.txt
|
||||
|
||||
|
||||
@@ -21,28 +21,7 @@ jobs:
|
||||
|
||||
- name: Install Python and Build Dependencies
|
||||
run: |
|
||||
# 1. Ensure Python3 is present; try apt-get only if missing
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends python3 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Bootstrap pip via ensurepip or version-appropriate get-pip.py
|
||||
if ! python3 -m pip --version >/dev/null 2>&1; then
|
||||
python3 -m ensurepip --default-pip 2>/dev/null || python3 -c "
|
||||
import sys, urllib.request, subprocess
|
||||
ver = f'{sys.version_info.major}.{sys.version_info.minor}'
|
||||
url = f'https://bootstrap.pypa.io/pip/{ver}/get-pip.py' if sys.version_info < (3, 10) else 'https://bootstrap.pypa.io/get-pip.py'
|
||||
print(f'[*] Downloading get-pip.py from {url} for Python {ver}...')
|
||||
urllib.request.urlretrieve(url, '/tmp/get-pip.py')
|
||||
subprocess.run([sys.executable, '/tmp/get-pip.py', '--break-system-packages'])
|
||||
" || true
|
||||
fi
|
||||
|
||||
# 3. Upgrade pip and install pyinstaller + dependencies
|
||||
python3 compilation/ensure_pip.py
|
||||
python3 -m pip install --upgrade pip --break-system-packages 2>/dev/null || python3 -m pip install --upgrade pip 2>/dev/null || true
|
||||
python3 -m pip install pyinstaller -r compilation/requirements.txt --break-system-packages 2>/dev/null || python3 -m pip install pyinstaller -r compilation/requirements.txt
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import sys
|
||||
import subprocess
|
||||
import urllib.request
|
||||
|
||||
def main():
|
||||
try:
|
||||
import pip # noqa: F401
|
||||
print("[+] pip is already installed.")
|
||||
return
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
import ensurepip
|
||||
ensurepip.bootstrap()
|
||||
print("[+] Successfully bootstrapped pip via ensurepip.")
|
||||
return
|
||||
except Exception as e:
|
||||
print(f"[*] ensurepip bootstrap skipped ({e}), downloading get-pip.py...")
|
||||
|
||||
ver = f"{sys.version_info.major}.{sys.version_info.minor}"
|
||||
url = f"https://bootstrap.pypa.io/pip/{ver}/get-pip.py" if sys.version_info < (3, 10) else "https://bootstrap.pypa.io/get-pip.py"
|
||||
dest = "/tmp/get-pip.py" if sys.platform != "win32" else "get-pip.py"
|
||||
|
||||
print(f"[*] Downloading get-pip.py from {url} for Python {ver}...")
|
||||
try:
|
||||
urllib.request.urlretrieve(url, dest)
|
||||
cmd = [sys.executable, dest]
|
||||
if sys.version_info >= (3, 11):
|
||||
cmd.append("--break-system-packages")
|
||||
res = subprocess.run(cmd)
|
||||
if res.returncode == 0:
|
||||
print("[+] Successfully installed pip via get-pip.py")
|
||||
else:
|
||||
# Retry without break-system-packages in case old pip version rejected it
|
||||
subprocess.run([sys.executable, dest])
|
||||
except Exception as ex:
|
||||
print(f"[!] Warning during pip bootstrap: {ex}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user