Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite36e941

Browse files
Portable/Relocatable Python Linking
1 parent521be20 commite36e941

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

‎builders/ubuntu-python-builder.psm1‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class UbuntuPythonBuilder : NixPythonBuilder {
3030

3131
$pythonBinariesLocation=$this.GetFullPythonToolcacheLocation()
3232

33-
### To build Python with SO we must pass fullpathto lib folderto thelinker
34-
$env:LDFLAGS="-Wl,--rpath=${pythonBinariesLocation}/lib"
33+
### To build Python with SO, passing relativepathW.r.tto thebinary location.
34+
$env:LDFLAGS="-Wl,-rpath='`$`$ORIGIN/../lib'"
3535
$configureString="./configure"
3636
$configureString+=" --prefix=$pythonBinariesLocation"
3737
$configureString+=" --enable-shared"
@@ -43,6 +43,7 @@ class UbuntuPythonBuilder : NixPythonBuilder {
4343

4444
Write-Host"The passed configure options are:"
4545
Write-Host$configureString
46+
Write-Host"LDFLAGS:$env:LDFLAGS"
4647

4748
Execute-Command-Command$configureString
4849
}

‎tests/python-tests.ps1‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ BeforeAll {
3636

3737
return0
3838
}
39+
40+
functionmoveAssets([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

4147
Describe"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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp