Skip to content

Commit e6b7470

Browse files
authored
Merge pull request #60 from ader1990/python_remove_pycache_pyc
python: remove the pycs and pycaches
2 parents d5226dc + 92b447b commit e6b7470

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/build_test_cbsinit.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
max-parallel: 100
1010
matrix:
1111
os: ['windows-2022']
12-
download_official_python_msi: ["true", "false"]
12+
download_official_python_msi: ["true"]
13+
remove_python_pycs: ["true"]
1314
cbsinit_repo: ['https://github.com/cloudbase/cloudbase-init']
1415
cbsinit_branch: ['master']
1516
python_version: ['3.14_4']
@@ -32,10 +33,11 @@ jobs:
3233
-CloudbaseInitRepoUrl ${{ matrix.cbsinit_repo }} ^
3334
-CloudbaseInitRepoBranch ${{ matrix.cbsinit_branch }} ^
3435
-InstallOfficialPythonMsi:$${{ matrix.download_official_python_msi }} ^
35-
-OfficialPythonMsiChecksum "C10234D0D9BD89F6F6DD55BAE28EDE0F97EE0DF4"
36+
-OfficialPythonMsiChecksum "C10234D0D9BD89F6F6DD55BAE28EDE0F97EE0DF4" ^
37+
-RemovePythonPycs:$${{ matrix.remove_python_pycs }}
3638
- uses: actions/upload-artifact@v7
3739
with:
38-
name: "CloudbaseInit_${{ matrix.platform }}_${{ matrix.os }}_MSI_${{ matrix.cbsinit_branch }}"
40+
name: "CloudbaseInit_platform-${{ matrix.platform }}_build-env-os-${{ matrix.os }}_download-official-msi-${{ matrix.download_official_python_msi }}_remove-pycs-${{ matrix.remove_python_pycs }}_cbs-init-branch-${{ matrix.cbsinit_branch }}_MSI"
3941
path: 'CloudbaseInitSetup/bin/release/${{ matrix.platform }}/CloudbaseInitSetup.msi'
4042
- name: Download external dependencies
4143
shell: powershell

BuildAutomation/BuildCloudbaseInitSetup.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Param(
1212
[string]$SignTimestampUrl = "http://timestamp.digicert.com?alg=sha256",
1313
[string]$VCVars = "2019",
1414
[switch]$InstallOfficialPythonMsi = $false,
15-
[string]$OfficialPythonMsiChecksum = "C10234D0D9BD89F6F6DD55BAE28EDE0F97EE0DF4"
15+
[string]$OfficialPythonMsiChecksum = "C10234D0D9BD89F6F6DD55BAE28EDE0F97EE0DF4",
16+
[switch]$RemovePythonPycs = $false
1617
)
1718

1819
$ErrorActionPreference = "Stop"
@@ -128,6 +129,12 @@ try
128129
ExecRetry { PullInstall "cloudbase-init" $CloudbaseInitRepoUrl $CloudbaseInitRepoBranch }
129130
}
130131

132+
if ($RemovePythonPycs) {
133+
pushd $python_dir
134+
Get-ChildItem -Path .\ -Recurse -Include *__pycache__ | foreach ($_) { Remove-Item $_.FullName -Force -Recurse}
135+
Get-ChildItem -Path .\ -Recurse -Include *.pyc | foreach ($_) { Remove-Item $_.FullName -Force -Recurse}
136+
popd
137+
}
131138
$release_dir = join-path $cloudbaseInitInstallerDir "CloudbaseInitSetup\bin\Release\$platform"
132139
$bin_dir = join-path $cloudbaseInitInstallerDir "CloudbaseInitSetup\Binaries\$platform"
133140

0 commit comments

Comments
 (0)