Automatically download the correct Python embed version

This commit is contained in:
Veronica K. B. Olsen
2021-01-23 14:43:54 +01:00
parent 5f86ab27bb
commit a698cb6ef7
2 changed files with 17 additions and 14 deletions
+16 -13
View File
@@ -246,21 +246,23 @@ def makeSimplePackage(embedPython):
if embedPython: if embedPython:
print("") print("")
print("# Downloading Python Embeddable") print("# Adding Python Embeddable")
print("# =============================") print("# ========================")
print("") print("")
pyUrl = "https://www.python.org/ftp/python/3.8.7/python-3.8.7-embed-amd64.zip" pyVers = "%d.%d.%d" % (sys.version_info[:3])
pyZip = os.path.join(outDir, "python_embed.zip") zipFile = "python-%s-embed-amd64.zip" % pyVers
print("URL: %s" % pyUrl) pyZip = os.path.join("dist", zipFile)
if not os.path.isfile(pyZip):
urllib.request.urlretrieve(pyUrl, pyZip) pyUrl = f"https://www.python.org/ftp/python/{pyVers}/{zipFile}"
print("Downloading: %s" % pyUrl)
urllib.request.urlretrieve(pyUrl, pyZip)
print("Extracting ...") print("Extracting ...")
with zipfile.ZipFile(pyZip, "r") as inFile: with zipfile.ZipFile(pyZip, "r") as inFile:
inFile.extractall(outDir) inFile.extractall(outDir)
os.unlink(pyZip) print("Done")
print("") print("")
# Make sample.zip # Make sample.zip
@@ -294,7 +296,8 @@ def makeSimplePackage(embedPython):
print("Copying: %s" % iconFile) print("Copying: %s" % iconFile)
shutil.copy2(os.path.join("setup", "icons", iconFile), os.path.join(outDir, iconFile)) shutil.copy2(os.path.join("setup", "icons", iconFile), os.path.join(outDir, iconFile))
nwDir = os.path.join(outDir, "nw") # Move assets to outDir as it should not be packed with the rest
print("Copying: assets")
os.rename(os.path.join(zipDir, "nw", "assets"), os.path.join(outDir, "assets")) os.rename(os.path.join(zipDir, "nw", "assets"), os.path.join(outDir, "assets"))
print("Writing: __main__.py") print("Writing: __main__.py")
@@ -736,8 +739,8 @@ if __name__ == "__main__":
"Python Packaging:\n" "Python Packaging:\n"
"\n" "\n"
" pack-pyz Creates a pyz package in a folder with all dependencies using the\n" " pack-pyz Creates a pyz package in a folder with all dependencies using the\n"
" zipapp tool. This option is intended for Windows deployment.\n" " zipapp tool. On Windows, python embeddable is added to the folder.\n"
" pack-exe Freeze the package and produces a folder with all dependencies using\n" " freeze Freeze the package and produces a folder with all dependencies using\n"
" the pyinstaller tool. This option is not designed for a specific OS.\n" " the pyinstaller tool. This option is not designed for a specific OS.\n"
" onefile Build a standalone executable with all dependencies bundled using the\n" " onefile Build a standalone executable with all dependencies bundled using the\n"
" pyinstaller tool. Implies 'freeze', cannot be used with 'setup-exe'.\n" " pyinstaller tool. Implies 'freeze', cannot be used with 'setup-exe'.\n"
@@ -803,8 +806,8 @@ if __name__ == "__main__":
if hostOS == OS_WIN: if hostOS == OS_WIN:
embedPython = True embedPython = True
if "pack-exe" in sys.argv: if "freeze" in sys.argv:
sys.argv.remove("pack-exe") sys.argv.remove("freeze")
doFreeze = True doFreeze = True
if "onefile" in sys.argv: if "onefile" in sys.argv:
+1 -1
View File
@@ -26,7 +26,7 @@ creating sample projects in the in-app New Project Wizard.
### Python Packaging ### Python Packaging
`winpack` Creates a pyz package in a folder with all dependencies using the `pack-pyz` Creates a pyz package in a folder with all dependencies using the
zipapp tool. This option is intended for Windows deployment. zipapp tool. This option is intended for Windows deployment.
`freeze` Freeze the package and produces a folder with all dependencies using `freeze` Freeze the package and produces a folder with all dependencies using