mirror of
https://github.com/python/cpython.git
synced 2025-12-07 13:50:06 +00:00
Fix disk space issues in Android CI (#142289)
This commit is contained in:
parent
4238a975d7
commit
cac4b04973
2 changed files with 29 additions and 14 deletions
|
|
@ -29,6 +29,7 @@
|
||||||
ANDROID_DIR.name == "Android" and (PYTHON_DIR / "pyconfig.h.in").exists()
|
ANDROID_DIR.name == "Android" and (PYTHON_DIR / "pyconfig.h.in").exists()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ENV_SCRIPT = ANDROID_DIR / "android-env.sh"
|
||||||
TESTBED_DIR = ANDROID_DIR / "testbed"
|
TESTBED_DIR = ANDROID_DIR / "testbed"
|
||||||
CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
|
CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
|
||||||
|
|
||||||
|
|
@ -129,12 +130,11 @@ def android_env(host):
|
||||||
sysconfig_filename = next(sysconfig_files).name
|
sysconfig_filename = next(sysconfig_files).name
|
||||||
host = re.fullmatch(r"_sysconfigdata__android_(.+).py", sysconfig_filename)[1]
|
host = re.fullmatch(r"_sysconfigdata__android_(.+).py", sysconfig_filename)[1]
|
||||||
|
|
||||||
env_script = ANDROID_DIR / "android-env.sh"
|
|
||||||
env_output = subprocess.run(
|
env_output = subprocess.run(
|
||||||
f"set -eu; "
|
f"set -eu; "
|
||||||
f"HOST={host}; "
|
f"HOST={host}; "
|
||||||
f"PREFIX={prefix}; "
|
f"PREFIX={prefix}; "
|
||||||
f". {env_script}; "
|
f". {ENV_SCRIPT}; "
|
||||||
f"export",
|
f"export",
|
||||||
check=True, shell=True, capture_output=True, encoding='utf-8',
|
check=True, shell=True, capture_output=True, encoding='utf-8',
|
||||||
).stdout
|
).stdout
|
||||||
|
|
@ -151,7 +151,7 @@ def android_env(host):
|
||||||
env[key] = value
|
env[key] = value
|
||||||
|
|
||||||
if not env:
|
if not env:
|
||||||
raise ValueError(f"Found no variables in {env_script.name} output:\n"
|
raise ValueError(f"Found no variables in {ENV_SCRIPT.name} output:\n"
|
||||||
+ env_output)
|
+ env_output)
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
@ -281,15 +281,30 @@ def clean_all(context):
|
||||||
|
|
||||||
|
|
||||||
def setup_ci():
|
def setup_ci():
|
||||||
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
|
if "GITHUB_ACTIONS" in os.environ:
|
||||||
if "GITHUB_ACTIONS" in os.environ and platform.system() == "Linux":
|
# Enable emulator hardware acceleration
|
||||||
run(
|
# (https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/).
|
||||||
["sudo", "tee", "/etc/udev/rules.d/99-kvm4all.rules"],
|
if platform.system() == "Linux":
|
||||||
input='KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"\n',
|
run(
|
||||||
text=True,
|
["sudo", "tee", "/etc/udev/rules.d/99-kvm4all.rules"],
|
||||||
)
|
input='KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"\n',
|
||||||
run(["sudo", "udevadm", "control", "--reload-rules"])
|
text=True,
|
||||||
run(["sudo", "udevadm", "trigger", "--name-match=kvm"])
|
)
|
||||||
|
run(["sudo", "udevadm", "control", "--reload-rules"])
|
||||||
|
run(["sudo", "udevadm", "trigger", "--name-match=kvm"])
|
||||||
|
|
||||||
|
# Free up disk space by deleting unused versions of the NDK
|
||||||
|
# (https://github.com/freakboy3742/pyspamsum/pull/108).
|
||||||
|
for line in ENV_SCRIPT.read_text().splitlines():
|
||||||
|
if match := re.fullmatch(r"ndk_version=(.+)", line):
|
||||||
|
ndk_version = match[1]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Failed to find NDK version in {ENV_SCRIPT.name}")
|
||||||
|
|
||||||
|
for item in (android_home / "ndk").iterdir():
|
||||||
|
if item.name[0].isdigit() and item.name != ndk_version:
|
||||||
|
delete_glob(item)
|
||||||
|
|
||||||
|
|
||||||
def setup_sdk():
|
def setup_sdk():
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ android {
|
||||||
val androidEnvFile = file("../../android-env.sh").absoluteFile
|
val androidEnvFile = file("../../android-env.sh").absoluteFile
|
||||||
|
|
||||||
namespace = "org.python.testbed"
|
namespace = "org.python.testbed"
|
||||||
compileSdk = 34
|
compileSdk = 35
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "org.python.testbed"
|
applicationId = "org.python.testbed"
|
||||||
|
|
@ -92,7 +92,7 @@ android {
|
||||||
}
|
}
|
||||||
throw GradleException("Failed to find API level in $androidEnvFile")
|
throw GradleException("Failed to find API level in $androidEnvFile")
|
||||||
}
|
}
|
||||||
targetSdk = 34
|
targetSdk = 35
|
||||||
|
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "1.0"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue