Skip to content

Commit 48fcd2e

Browse files
committed
move tools and packages markdown off make.py
1 parent b33aa7b commit 48fcd2e

File tree

4 files changed

+31
-42
lines changed

4 files changed

+31
-42
lines changed

make.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ def _get_python_zip_file(self) -> Path:
102102
@property
103103
def package_index_markdown(self) -> str:
104104
"""Generates a Markdown formatted package index page."""
105-
installed_tools_markdown = self._get_installed_tools_markdown()
106-
installed_packages_markdown = self._get_installed_packages_markdown()
107-
108105
return f"""## WinPython {self.winpyver2 + self.flavor}
109106
110107
The following packages are included in WinPython-{self.architecture_bits}bit v{self.winpyver2 + self.flavor} {self.release_level}.
@@ -115,49 +112,17 @@ def package_index_markdown(self) -> str:
115112
116113
Name | Version | Description
117114
-----|---------|------------
118-
{installed_tools_markdown}
115+
{utils.get_installed_tools_markdown(utils.get_python_executable(self.python_executable_directory))}
119116
120117
### Python packages
121118
122119
Name | Version | Description
123120
-----|---------|------------
124-
[Python](http://www.python.org/) | {self.python_full_version} | Python programming language with standard library
125-
{installed_packages_markdown}
121+
{self.distribution.get_installed_packages_markdown()}
126122
127123
</details>
128124
"""
129125

130-
def _get_installed_tools_markdown(self) -> str:
131-
"""Generates Markdown for installed tools section in package index."""
132-
tool_lines = []
133-
134-
if (nodejs_path := self.winpython_directory / NODEJS_RELATIVE_PATH).exists():
135-
version = utils.exec_shell_cmd("node -v", nodejs_path).splitlines()[0]
136-
tool_lines.append(f"[Nodejs](https://nodejs.org) | {version} | xa JavaScript runtime built on Chrome's V8 JavaScript engine")
137-
version = utils.exec_shell_cmd("npm -v", nodejs_path).splitlines()[0]
138-
tool_lines.append(f"[npmjs](https://www.npmjs.com) | {version} | a package manager for JavaScript")
139-
140-
if (pandoc_exe := self.winpython_directory / "t" / "pandoc.exe").exists():
141-
version = utils.exec_shell_cmd("pandoc -v", pandoc_exe.parent).splitlines()[0].split(" ")[-1]
142-
tool_lines.append(f"[Pandoc](https://pandoc.org) | {version} | an universal document converter")
143-
144-
if vscode_exe := (self.winpython_directory / "t" / "VSCode" / "Code.exe").exists():
145-
version = utils.getFileProperties(str(vscode_exe))["FileVersion"]
146-
tool_lines.append(f"[VSCode](https://code.visualstudio.com) | {version} | a source-code editor developed by Microsoft")
147-
148-
return "\n".join(tool_lines)
149-
150-
def _get_installed_packages_markdown(self) -> str:
151-
"""Generates Markdown for installed packages section in package index."""
152-
if not self.distribution:
153-
return "" # Distribution not initialized yet.
154-
self.installed_packages = self.distribution.get_installed_packages(update=True)
155-
package_lines = [
156-
f"[{pkg.name}]({pkg.url}) | {pkg.version} | {pkg.description}"
157-
for pkg in sorted(self.installed_packages, key=lambda p: p.name.lower())
158-
]
159-
return "\n".join(package_lines)
160-
161126
@property
162127
def winpython_version_name(self) -> str:
163128
"""Returns the full WinPython version string."""

winpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '15.3.20250425'
31+
__version__ = '15.4.20250507'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ def get_site_packages_path(path=None):
4343
pypy_site_packages = base_dir / 'site-packages' # For PyPy
4444
return str(pypy_site_packages if pypy_site_packages.is_dir() else site_packages)
4545

46+
def get_installed_tools_markdown(path=None)-> str:
47+
"""Generates Markdown for installed tools section in package index."""
48+
tool_lines = []
49+
python_exe = Path(get_python_executable(path))
50+
version = exec_shell_cmd(f'powershell (Get-Item {python_exe}).VersionInfo.FileVersion', python_exe.parent).splitlines()[0]
51+
tool_lines.append(f"[Python](http://www.python.org/) | {version} | Python programming language with standard library")
52+
if (node_exe := python_exe.parent.parent / "n" / "node.exe").exists():
53+
version = exec_shell_cmd(f'powershell (Get-Item {node_exe}).VersionInfo.FileVersion', node_exe.parent).splitlines()[0]
54+
tool_lines.append(f"[Nodejs](https://nodejs.org) | {version} | a JavaScript runtime built on Chrome's V8 JavaScript engine")
55+
56+
if (pandoc_exe := python_exe.parent.parent / "t" / "pandoc.exe").exists():
57+
version = exec_shell_cmd("pandoc -v", pandoc_exe.parent).splitlines()[0].split(" ")[-1]
58+
tool_lines.append(f"[Pandoc](https://pandoc.org) | {version} | an universal document converter")
59+
60+
if (vscode_exe := python_exe.parent.parent / "t" / "VSCode" / "Code.exe").exists():
61+
version = exec_shell_cmd(f'powershell (Get-Item {vscode_exe}).VersionInfo.FileVersion', vscode_exe.parent).splitlines()[0]
62+
tool_lines.append(f"[VSCode](https://code.visualstudio.com) | {version} | a source-code editor developed by Microsoft")
63+
return "\n".join(tool_lines)
64+
65+
4666
def onerror(function, path, excinfo):
4767
"""Error handler for `shutil.rmtree`."""
4868
if not os.access(path, os.W_OK):

winpython/wppm.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,21 @@ def create_file(self, package, name, dstdir, contents):
7474

7575
def get_installed_packages(self, update: bool = False) -> list[Package]:
7676
"""Return installed packages."""
77-
78-
# Include package installed via pip (not via WPPM)
7977
if str(Path(sys.executable).parent) == self.target:
8078
self.pip = piptree.PipData()
8179
else:
8280
self.pip = piptree.PipData(utils.get_python_executable(self.target))
8381
pip_list = self.pip.pip_list(full=True)
84-
85-
# return a list of package objects
8682
return [Package(f"{i[0].replace('-', '_').lower()}-{i[1]}-py3-none-any.whl", suggested_summary=i[2]) for i in pip_list]
8783

84+
def get_installed_packages_markdown(self) -> str:
85+
"""Generates Markdown for installed packages section in package index."""
86+
package_lines = [
87+
f"[{pkg.name}]({pkg.url}) | {pkg.version} | {pkg.description}"
88+
for pkg in sorted(self.get_installed_packages(), key=lambda p: p.name.lower())
89+
]
90+
return "\n".join(package_lines)
91+
8892
def find_package(self, name: str) -> Package | None:
8993
"""Find installed package by name."""
9094
for pack in self.get_installed_packages():

0 commit comments

Comments
 (0)