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

Appearance settings

Commit 2258f71

Browse filesBrowse files
authored
Merge pull request #1626 from stonebig/master
move diff in winpython for BUILD simplification
2 parents ceecd5e + d65b8e2 commit 2258f71
Copy full SHA for 2258f71

File tree

Expand file treeCollapse file tree

2 files changed

+29
-29
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+29
-29
lines changed

‎make.py

Copy file name to clipboardExpand all lines: make.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
import subprocess
1313
import sys
1414
from pathlib import Path
15-
from winpython import wppm, utils
16-
# Local import
17-
import diff
15+
from winpython import wppm, utils, diff
1816

1917
# Define constant paths for clarity
2018
CHANGELOGS_DIRECTORY = Path(__file__).parent / "changelogs"
@@ -265,7 +263,7 @@ def build(self, rebuild: bool = True, requirements_files_list=None, winpy_dirnam
265263

266264
self._print_action("Writing changelog")
267265
shutil.copyfile(output_markdown_filename, str(Path(CHANGELOGS_DIRECTORY) / Path(output_markdown_filename).name))
268-
diff.write_changelog(self.winpyver2, None, self.base_directory, self.flavor, self.distribution.architecture)
266+
diff.write_changelog(self.winpyver2, None, CHANGELOGS_DIRECTORY, self.flavor, self.distribution.architecture, basedir=self.winpython_directory.parent)
269267

270268
def rebuild_winpython_package(source_directory: Path, target_directory: Path, architecture: int = 64, verbose: bool = False):
271269
"""Rebuilds the winpython package from source using flit."""

‎diff.py renamed to ‎winpython/diff.py

Copy file name to clipboardExpand all lines: winpython/diff.py
+27-25Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import re
1212
import shutil
1313
from packaging import version
14-
from winpython import utils
14+
from . import utils
1515

16-
CHANGELOGS_DIR = Path(__file__).parent / "changelogs"
16+
CHANGELOGS_DIR = Path(__file__).parent.parent / "changelogs"
1717
assert CHANGELOGS_DIR.is_dir()
1818

1919
class Package:
@@ -45,16 +45,16 @@ class PackageIndex:
4545
HEADERS = {"tools": "### Tools", "python": "### Python packages", "wheelhouse": "### WheelHouse packages"}
4646
BLANKS = ["Name | Version | Description", "-----|---------|------------", "", "<details>", "</details>"]
4747

48-
def __init__(self, version, basedir=None, flavor="", architecture=64):
48+
def __init__(self, version, searchdir=None, flavor="", architecture=64):
4949
self.version = version
5050
self.flavor = flavor
51-
self.basedir = basedir
51+
self.searchdir = searchdir
5252
self.architecture = architecture
5353
self.packages = {"tools": {}, "python": {}, "wheelhouse": {}}
5454
self._load_index()
5555

5656
def _load_index(self):
57-
filename = CHANGELOGS_DIR / f"WinPython{self.flavor}-{self.architecture}bit-{self.version}.md"
57+
filename = self.searchdir / f"WinPython{self.flavor}-{self.architecture}bit-{self.version}.md"
5858
if not filename.exists():
5959
raise FileNotFoundError(f"Changelog not found: {filename}")
6060

@@ -93,20 +93,20 @@ def normalize(d): return {k.replace("-", "_").lower(): v for k, v in d.items()}
9393
output += "Removed packages:\r\n\r\n" + "".join(removed) + "\r\n"
9494
return output
9595

96-
def find_previous_version(target_version, basedir=None, flavor="", architecture=64):
96+
def find_previous_version(target_version, searchdir=None, flavor="", architecture=64):
9797
"""Find version which is the closest to `version`"""
98-
build_dir = Path(basedir) / f"bu{flavor}"
98+
search_dir = Path(searchdir) if searchdir else CHANGELOGS_DIR
9999
pattern = re.compile(rf"WinPython{flavor}-{architecture}bit-([0-9\.]+)\.(txt|md)")
100-
versions = [pattern.match(f).group(1) for f in os.listdir(build_dir) if pattern.match(f)]
100+
versions = [pattern.match(f).group(1) for f in os.listdir(search_dir) if pattern.match(f)]
101101
versions = [v for v in versions if version.parse(v) < version.parse(target_version)]
102102
return max(versions, key=version.parse, default=target_version)
103103

104-
def compare_package_indexes(version2, version1=None, basedir=None, flavor="", flavor1=None, architecture=64):
105-
version1 = version1 or find_previous_version(version2, basedir, flavor, architecture)
104+
def compare_package_indexes(version2, version1=None, searchdir=None, flavor="", flavor1=None, architecture=64):
105+
version1 = version1 or find_previous_version(version2, searchdir, flavor, architecture)
106106
flavor1 = flavor1 or flavor
107107

108-
pi1 = PackageIndex(version1, basedir, flavor1, architecture)
109-
pi2 = PackageIndex(version2, basedir, flavor, architecture)
108+
pi1 = PackageIndex(version1, searchdir, flavor1, architecture)
109+
pi2 = PackageIndex(version2, searchdir, flavor, architecture)
110110

111111
text = (
112112
f"## History of changes for WinPython-{architecture}bit {version2 + flavor}\r\n\r\n"
@@ -121,25 +121,27 @@ def compare_package_indexes(version2, version1=None, basedir=None, flavor="", fl
121121

122122
return text + "\r\n</details>\r\n* * *\r\n"
123123

124-
def copy_changelogs(version, basedir, flavor="", architecture=64):
124+
def copy_changelogs(version, searchdir, flavor="", architecture=64, basedir=None):
125125
basever = ".".join(version.split(".")[:2])
126126
pattern = re.compile(rf"WinPython{flavor}-{architecture}bit-{basever}[0-9\.]*\.(txt|md)")
127-
dest = Path(basedir) / f"bu{flavor}"
128-
for fname in os.listdir(CHANGELOGS_DIR):
127+
dest = Path(basedir)
128+
for fname in os.listdir(searchdir):
129129
if pattern.match(fname):
130-
shutil.copyfile(CHANGELOGS_DIR / fname, dest / fname)
130+
shutil.copyfile(searchdir / fname, dest / fname)
131131

132-
def write_changelog(version2, version1=None, basedir=None, flavor="", architecture=64):
132+
def write_changelog(version2, version1=None, searchdir=None, flavor="", architecture=64, basedir=None):
133133
"""Write changelog between version1 and version2 of WinPython"""
134-
copy_changelogs(version2, basedir, flavor, architecture)
135-
print("comparing_package_indexes", version2, basedir, flavor, architecture)
136-
changelog = compare_package_indexes(version2, version1, basedir, flavor, architecture=architecture)
137-
output_file = Path(basedir) / f"bu{flavor}" / f"WinPython{flavor}-{architecture}bit-{version2}_History.md"
134+
if basedir:
135+
copy_changelogs(version2, searchdir, flavor, architecture, basedir)
136+
print("comparing_package_indexes", version2, searchdir, flavor, architecture)
137+
changelog = compare_package_indexes(version2, version1, searchdir, flavor, architecture=architecture)
138+
output_file = searchdir / f"WinPython{flavor}-{architecture}bit-{version2}_History.md"
138139
with open(output_file, "w", encoding="utf-8") as f:
139140
f.write(changelog)
140-
# Copy to winpython/changelogs
141-
shutil.copyfile(output_file, CHANGELOGS_DIR / output_file.name)
141+
# Copy to winpython/changelogs back to basedir
142+
if basedir:
143+
shutil.copyfile(output_file, basedir / output_file.name)
142144

143145
if __name__ == "__main__":
144-
print(compare_package_indexes("3.7.4.0", "3.7.2.0", r"C:\WinP\bd37", "Zero", architecture=32))
145-
write_changelog("3.7.4.0", "3.7.2.0", r"C:\WinP\bd37", "Ps2", architecture=64)
146+
print(compare_package_indexes("3.7.4.0", "3.7.2.0", r"C:\WinP\bd37\budot", "Zero", architecture=32))
147+
write_changelog("3.7.4.0", "3.7.2.0", r"C:\WinP\bd37\budot", "Ps2", architecture=64)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.