forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Add PyManager support to PC/layout
- Loading branch information
Showing
3 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
from .constants import * | ||
|
||
FULL_VERSION = f"{VER_MAJOR}.{VER_MINOR}.{VER_MICRO}.{VER_FIELD4}" | ||
XYZ_VERSION = f"{VER_MAJOR}.{VER_MINOR}.{VER_MICRO}" | ||
FILE_VERSION = f"{VER_MAJOR}.{VER_MINOR}.{VER_MICRO}{VER_SUFFIX}" | ||
|
||
def calculate_install_json(ns, *, for_embed=False): | ||
TARGET = "python.exe" | ||
TARGETW = "pythonw.exe" | ||
|
||
SYS_ARCH = { | ||
"win32": "32bit", | ||
"amd64": "64bit", | ||
"arm64": "64bit", | ||
}[ns.arch] | ||
TAG_ARCH = { | ||
"win32": "-32", | ||
"amd64": "", | ||
"arm64": "-arm64", | ||
}[ns.arch] | ||
|
||
if not for_embed: | ||
if not ns.include_freethreaded: | ||
ID_PREFIX = "pythoncore-" | ||
COMPANY = "PythonCore" | ||
TAG_SUFFIX = "" | ||
TAG_ARCH_SUFFIX = TAG_ARCH | ||
FILE_SUFFIX = f"-{ns.arch}" | ||
FRIENDLY_ARCH = { | ||
"win32": " (32-bit)", | ||
"amd64": "", | ||
"arm64": " (ARM64)", | ||
}[ns.arch] | ||
else: | ||
ID_PREFIX = "pythoncore-" | ||
COMPANY = "PythonCore" | ||
TAG_SUFFIX = "t" | ||
TAG_ARCH_SUFFIX = f"t{TAG_ARCH}" | ||
FILE_SUFFIX = f"t-{ns.arch}" | ||
TARGET = f"python{VER_MAJOR}.{VER_MINOR}t.exe" | ||
TARGETW = f"pythonw{VER_MAJOR}.{VER_MINOR}t.exe" | ||
FRIENDLY_ARCH = { | ||
"win32": " (32-bit, freethreaded)", | ||
"amd64": " (freethreaded)", | ||
"arm64": " (ARM64, freethreaded)", | ||
}[ns.arch] | ||
else: | ||
ID_PREFIX = "pythonembed-" | ||
COMPANY = "PythonCore" | ||
TAG_SUFFIX = "-embed" | ||
TAG_ARCH_SUFFIX = f"{TAG_ARCH}-embed" | ||
FILE_SUFFIX = f"-embed-{ns.arch}" | ||
TARGETW = None | ||
FRIENDLY_ARCH = { | ||
"win32": " (32-bit, embeddable)", | ||
"amd64": " (embeddable)", | ||
"arm64": " (ARM64, embeddable)", | ||
}[ns.arch] | ||
|
||
|
||
FULL_TAG = f"{VER_MAJOR}.{VER_MINOR}.{VER_MICRO}{TAG_SUFFIX}" | ||
XY_TAG = f"{VER_MAJOR}.{VER_MINOR}{TAG_SUFFIX}" | ||
X_TAG = f"{VER_MAJOR}{TAG_SUFFIX}" | ||
DISPLAY_VERSION = f"{XYZ_VERSION}{VER_SUFFIX}{FRIENDLY_ARCH}" | ||
|
||
STD_RUN_FOR = [] | ||
STD_ALIAS = [] | ||
STD_PEP514 = [] | ||
STD_START = [] | ||
|
||
if TARGET: | ||
STD_RUN_FOR.extend([ | ||
{"tag": XY_TAG, "target": TARGET}, | ||
{"tag": X_TAG, "target": TARGET}, | ||
]) | ||
STD_ALIAS.extend([ | ||
{"name": f"python{XY_TAG}.exe", "target": TARGET}, | ||
{"name": f"python{X_TAG}.exe", "target": TARGET}, | ||
]) | ||
|
||
if TARGETW: | ||
STD_RUN_FOR.extend([ | ||
{"tag": XY_TAG, "target": TARGETW, "windowed": 1}, | ||
{"tag": X_TAG, "target": TARGETW, "windowed": 1}, | ||
]) | ||
STD_ALIAS.extend([ | ||
{"name": f"pythonw{XY_TAG}.exe", "target": TARGETW, "windowed": 1}, | ||
{"name": f"pythonw{X_TAG}.exe", "target": TARGETW, "windowed": 1} | ||
]) | ||
|
||
data = { | ||
"schema": 1, | ||
"id": f"{ID_PREFIX}{XY_TAG}", | ||
"sort-version": FULL_VERSION, | ||
"company": COMPANY, | ||
"tag": FULL_TAG, | ||
"install-for": [FULL_TAG, XY_TAG, X_TAG], | ||
"run-for": STD_RUN_FOR, | ||
"alias": STD_ALIAS, | ||
"shortcuts": [], | ||
"displayName": f"Python {DISPLAY_VERSION}", | ||
"executable": f"./{TARGET}", | ||
"url": f"https://www.python.org/ftp/python/{XYZ_VERSION}/python-{FILE_VERSION}{FILE_SUFFIX}.zip" | ||
} | ||
|
||
STD_PEP514.append({ | ||
"kind": "pep514", | ||
"Key": rf"{COMPANY}\{XY_TAG}", | ||
"DisplayName": f"Python {DISPLAY_VERSION}", | ||
"SupportUrl": "https://www.python.org/", | ||
"SysArchitecture": SYS_ARCH, | ||
"SysVersion": VER_DOT, | ||
"Version": FULL_VERSION, | ||
"InstallPath": { | ||
"": "%PREFIX%", | ||
"ExecutablePath": f"%PREFIX%{TARGET}", | ||
}, | ||
"Help": { | ||
"Online Python Documentation": { | ||
"": f"https://docs.python.org/{VER_DOT}/" | ||
}, | ||
}, | ||
}) | ||
|
||
STD_START.append({ | ||
"kind": "start", | ||
"Name": f"Python {VER_DOT}{FRIENDLY_ARCH}", | ||
"Items": [ | ||
{ | ||
"Name": f"Python {VER_DOT}{FRIENDLY_ARCH}", | ||
"Target": f"%PREFIX%{TARGET}", | ||
"Icon": f"%PREFIX%{TARGET}", | ||
}, | ||
{ | ||
"Name": f"Python {VER_DOT} Online Documentation", | ||
"Icon": r"%SystemRoot%\System32\SHELL32.dll", | ||
"IconIndex": 13, | ||
"Target": f"https://docs.python.org/{VER_DOT}/", | ||
}, | ||
], | ||
}) | ||
|
||
if STD_PEP514: | ||
if TARGETW: | ||
STD_PEP514[0]["InstallPath"]["WindowedExecutablePath"] = f"%PREFIX%{TARGETW}" | ||
if ns.include_html_doc: | ||
STD_PEP514[0]["Help"]["Main Python Documentation"] = { | ||
"": rf"%PREFIX%Doc\index.html", | ||
} | ||
STD_START[0]["Items"].append({ | ||
"Name": f"Python {VER_DOT} Manuals{FRIENDLY_ARCH}", | ||
"Target": r"%PREFIX%Doc\index.html", | ||
}) | ||
elif ns.include_chm: | ||
STD_PEP514[0]["Help"]["Main Python Documentation"] = { | ||
"": rf"%PREFIX%Doc\{PYTHON_CHM_NAME}", | ||
} | ||
STD_START[0]["Items"].append({ | ||
"Name": f"Python {VER_DOT} Manuals{FRIENDLY_ARCH}", | ||
"Target": "%WINDIR%hhc.exe", | ||
"Arguments": rf"%PREFIX%Doc\{PYTHON_CHM_NAME}", | ||
}) | ||
|
||
data["shortcuts"] = [*STD_PEP514, *STD_START] | ||
|
||
return data | ||
|
||
|
||
def calculate_install_embed_json(ns): | ||
return calculate_install_json(ns, for_embed=True) | ||
|