Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _msbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def mainw_exe(name):
# Default index feed, mainly for testing right now
Package(
'bundled',
File('src/index*.json'),
File('src/index*.json', allow_none=True),
),

# Directory for template files
Expand Down
4 changes: 1 addition & 3 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@
cwd=DIRS["root"],
env={**os.environ, "BUILD_SOURCEBRANCH": ref})

# Overwrite bundled feed. This will be removed eventually
run([sys.executable, "scripts/generate-nuget-index.py", LAYOUT / "bundled" / "index.json"])

# Bundle current latest release
run([LAYOUT / "py-manager.exe", "install", "-v", "-f", "--download", TEMP / "bundle", "default"])
(LAYOUT / "bundled").mkdir(parents=True, exist_ok=True)
(TEMP / "bundle" / "index.json").rename(LAYOUT / "bundled" / "fallback-index.json")
for f in (TEMP / "bundle").iterdir():
f.rename(LAYOUT / "bundled" / f.name)
40 changes: 29 additions & 11 deletions scripts/generate-nuget-index.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ def irm(url, method="GET", headers={}):

NUGET_SOURCE = "https://api.nuget.org/v3/index.json"

# Earlier versions than this go into "legacy.json"
CURRENT_VERSION = Version("3.10")

SKIP_OLD_PRERELEASE = True

# Indentation for output files
INDENT = None


SCHEMA = {
"python": {
"schema": 1,
Expand All @@ -35,6 +44,7 @@ def irm(url, method="GET", headers={}):
"$XYVERSIONNOPRE$-64",
"$XVERSIONNOPRE$-64",
"$XYVERSIONDEV$-64",
"$XVERSIONDEV$-64",
],
"run-for": [
{"tag": "$FULLVERSION$-64", "target": "python.exe"},
Expand Down Expand Up @@ -80,7 +90,7 @@ def irm(url, method="GET", headers={}):
"Icon": "%PREFIX%python.exe",
},
{
"Name": "Python $XYVERSION$ Documentation",
"Name": "Python $XYVERSION$ Online Documentation",
"Icon": r"%SystemRoot%\System32\SHELL32.dll",
"IconIndex": 13,
"Target": "https://docs.python.org/$XYVERSION$/",
Expand Down Expand Up @@ -108,6 +118,7 @@ def irm(url, method="GET", headers={}):
"$XYVERSIONNOPRE$-32",
"$XVERSIONNOPRE$-32",
"$XYVERSIONDEV$-32",
"$XVERSIONDEV$-32",
],
"run-for": [
{"tag": "$FULLVERSION$-32", "target": "python.exe"},
Expand Down Expand Up @@ -153,7 +164,7 @@ def irm(url, method="GET", headers={}):
"Icon": "%PREFIX%python.exe",
},
{
"Name": "Python $XYVERSION$ Documentation",
"Name": "Python $XYVERSION$ Online Documentation",
"Icon": r"%SystemRoot%\System32\SHELL32.dll",
"IconIndex": 13,
"Target": "https://docs.python.org/$XYVERSION$/",
Expand Down Expand Up @@ -181,6 +192,7 @@ def irm(url, method="GET", headers={}):
"$XYVERSIONNOPRE$-arm64",
"$XVERSIONNOPRE$-arm64",
"$XYVERSIONDEV$-arm64",
"$XVERSIONDEV$-arm64",
],
"run-for": [
{"tag": "$FULLVERSION$-arm64", "target": "python.exe"},
Expand Down Expand Up @@ -226,7 +238,7 @@ def irm(url, method="GET", headers={}):
"Icon": "%PREFIX%python.exe",
},
{
"Name": "Python $XYVERSION$ Documentation",
"Name": "Python $XYVERSION$ Online Documentation",
"Icon": r"%SystemRoot%\System32\SHELL32.dll",
"IconIndex": 13,
"Target": "https://docs.python.org/$XYVERSION$/",
Expand Down Expand Up @@ -254,6 +266,7 @@ def irm(url, method="GET", headers={}):
"$XYVERSIONNOPRE$t-64",
"$XVERSIONNOPRE$t-64",
"$XYVERSIONDEV$t-64",
"$XVERSIONDEV$t-64",
],
"run-for": [
{"tag": "$FULLVERSION$t-64", "target": "python$XYVERSION$t.exe"},
Expand Down Expand Up @@ -299,7 +312,7 @@ def irm(url, method="GET", headers={}):
"Icon": "%PREFIX%python.exe",
},
{
"Name": "Python $XYVERSION$ Documentation",
"Name": "Python $XYVERSION$ Online Documentation",
"Icon": r"%SystemRoot%\System32\SHELL32.dll",
"IconIndex": 13,
"Target": "https://docs.python.org/$XYVERSION$/",
Expand Down Expand Up @@ -327,6 +340,7 @@ def irm(url, method="GET", headers={}):
"$XYVERSIONNOPRE$t-32",
"$XVERSIONNOPRE$t-32",
"$XYVERSIONDEV$t-32",
"$XVERSIONDEV$t-32",
],
"run-for": [
{"tag": "$FULLVERSION$t-32", "target": "python$XYVERSION$t.exe"},
Expand Down Expand Up @@ -372,7 +386,7 @@ def irm(url, method="GET", headers={}):
"Icon": "%PREFIX%python.exe",
},
{
"Name": "Python $XYVERSION$ Documentation",
"Name": "Python $XYVERSION$ Online Documentation",
"Icon": r"%SystemRoot%\System32\SHELL32.dll",
"IconIndex": 13,
"Target": "https://docs.python.org/$XYVERSION$/",
Expand Down Expand Up @@ -400,6 +414,7 @@ def irm(url, method="GET", headers={}):
"$XYVERSIONNOPRE$t-arm64",
"$XVERSIONNOPRE$t-arm64",
"$XYVERSIONDEV$t-arm64",
"$XVERSIONDEV$t-arm64",
],
"run-for": [
{"tag": "$FULLVERSION$t-arm64", "target": "python$XYVERSION$t.exe"},
Expand Down Expand Up @@ -445,7 +460,7 @@ def irm(url, method="GET", headers={}):
"Icon": "%PREFIX%python.exe",
},
{
"Name": "Python $XYVERSION$ Documentation",
"Name": "Python $XYVERSION$ Online Documentation",
"Icon": r"%SystemRoot%\System32\SHELL32.dll",
"IconIndex": 13,
"Target": "https://docs.python.org/$XYVERSION$/",
Expand Down Expand Up @@ -499,16 +514,15 @@ def dict_sub(d, subs):
INDEX_OLD = {"versions": []}
INDEX_CURRENT = {"versions": [], "next": ""}

# Earlier versions than this go into "legacy.json"
CURRENT_VERSION = Version("3.12")

for name, schema in SCHEMA.items():
data = irm(f"{BASE_URL}/{name}/index.json")

all_versions = sorted((Version(ver) for ver in data["versions"]), reverse=True)

last_v = None
for v in all_versions:
if v.is_prerelease and v < CURRENT_VERSION and SKIP_OLD_PRERELEASE:
continue
if v.is_prerelease and last_v and v.to_python_style(3, False) == last_v:
continue
subs = {
Expand All @@ -518,21 +532,25 @@ def dict_sub(d, subs):
"XYVERSIONDEV": (v.to_python_style(2, False) + "-dev") if v.is_prerelease else None,
"XVERSION": v.to_python_style(1, False),
"XVERSIONNOPRE": None if v.is_prerelease else v.to_python_style(1, False),
"XVERSIONDEV": (v.to_python_style(1, False) + "-dev") if v.is_prerelease else None,
"PACKAGEURL": f"{BASE_URL}/{name}/{v}/{name}.{v}.nupkg",
}
index = INDEX_CURRENT if v >= CURRENT_VERSION else INDEX_OLD
index["versions"].append(dict_sub(schema, subs))
last_v = subs["FULLVERSION"]


INDEX_CURRENT["versions"].sort(key=lambda i: (Version(i["sort-version"]), i["id"]), reverse=True)
INDEX_OLD["versions"].sort(key=lambda i: (Version(i["sort-version"]), i["id"]), reverse=True)

for file in map(Path, sys.argv[1:]):
legacy_name = f"{file.stem}-legacy.json"
INDEX_CURRENT["next"] = legacy_name
file.parent.mkdir(exist_ok=True, parents=True)
with open(file, "w", encoding="utf-8") as f:
json.dump(INDEX_CURRENT, f, indent=2)
json.dump(INDEX_CURRENT, f, indent=INDENT)
with open(file.with_name(legacy_name), "w", encoding="utf-8") as f:
json.dump(INDEX_OLD, f, indent=2)
json.dump(INDEX_OLD, f, indent=INDENT)


if not sys.argv[1:]:
Expand Down
Loading