@@ -36,6 +36,12 @@ BeforeAll {
3636
3737 return 0
3838 }
39+
40+ function moveAssets ([string ] $source , [string ] $destination ) {
41+ $parentDestDir = Split-Path - Path $destination - Parent
42+ New-Item - Path $parentDestDir - ItemType Directory - Force
43+ Move-Item - Path $source - Destination $parentDestDir - Force
44+ }
3945}
4046
4147Describe " Tests" {
@@ -88,6 +94,30 @@ Describe "Tests" {
8894 It " Check if shared libraries are linked correctly" {
8995 " bash ./sources/psutil-install-test.sh" | Should - ReturnZeroExitCode
9096 }
97+
98+ It " Relocatable Python" {
99+ $semversion = [semver ] $Version
100+ $pyfilename = " python$ ( $semversion.Major ) .$ ( $semversion.Minor ) "
101+ $artifactPath = Join-Path " Python" $Version | Join-Path - ChildPath $Architecture
102+
103+ $relocatedPython = Join-Path $HOME " relocated_python"
104+ $relocatedPythonTool = Join-Path - Path $relocatedPython - ChildPath $artifactPath
105+ $relocatedFullPath = Join-Path $relocatedPythonTool " bin" | Join-Path - ChildPath $pyfilename
106+
107+ # copy the current build to relocated_python
108+ $toolCacheArtifact = Join-Path $env: RUNNER_TOOL_CACHE $artifactPath
109+ moveAssets - source $toolCacheArtifact - destination $relocatedPythonTool
110+ try {
111+ # Verify that relocated Python works
112+ $relocatedFullPath | Should - Exist
113+ " $relocatedFullPath --version" | Should - ReturnZeroExitCode
114+ " sudo $relocatedFullPath --version" | Should - ReturnZeroExitCode
115+ }
116+ finally {
117+ # Revert the changes for other tests
118+ moveAssets - source $relocatedPythonTool - destination $toolCacheArtifact
119+ }
120+ }
91121 }
92122
93123 # Pyinstaller 3.5 does not support Python 3.8.0. Check issue https://github.com/pyinstaller/pyinstaller/issues/4311
0 commit comments