10000 move tools and packages markdown off make.py , preparing launchers improvements by stonebig · Pull Request #1585 · winpython/winpython · GitHub
[go: up one dir, main page]

Skip to content

move tools and packages markdown off make.py , preparing launchers improvements #1585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
move tools and packages markdown off make.py
  • Loading branch information
stonebig committed May 7, 2025
commit 48fcd2eed4063f92e6f25ec659d3ba250d4b9f22
39 changes: 2 additions & 37 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ def _get_python_zip_file(self) -> Path:
@property
def package_index_markdown(self) -> str:
"""Generates a Markdown formatted package index page."""
installed_tools_markdown = self._get_installed_tools_markdown()
installed_packages_markdown = self._get_installed_packages_markdown()

return f"""## WinPython {self.winpyver2 + self.flavor}

The following packages are included in WinPython-{self.architecture_bits}bit v{self.winpyver2 + self.flavor} {self.release_level}.
Expand All @@ -115,49 +112,17 @@ def package_index_markdown(self) -> str:

Name | Version | Description
-----|---------|------------
{installed_tools_markdown}
{utils.get_installed_tools_markdown(utils.get_python_executable(self.python_executable_directory))}

### Python packages

Name | Version | Description
-----|---------|------------
[Python](http://www.python.org/) | {self.python_full_version} | Python programming language with standard library
{installed_packages_markdown}
{self.distribution.get_installed_packages_markdown()}

</details>
"""

def _get_installed_tools_markdown(self) -> str:
"""Generates Markdown for installed tools section in package index."""
tool_lines = []

if (nodejs_path := self.winpython_directory / NODEJS_RELATIVE_PATH).exists():
version = utils.exec_shell_cmd("node -v", nodejs_path).splitlines()[0]
tool_lines.append(f"[Nodejs](https://nodejs.org) | {version} | xa JavaScript runtime built on Chrome's V8 JavaScript engine")
version = utils.exec_shell_cmd("npm -v", nodejs_path).splitlines()[0]
tool_lines.append(f"[npmjs](https://www.npmjs.com) | {version} | a package manager for JavaScript")

if (pandoc_exe := self.winpython_directory / "t" / "pandoc.exe").exists():
version = utils.exec_shell_cmd("pandoc -v", pandoc_exe.parent).splitlines()[0].split(" ")[-1]
tool_lines.append(f"[Pandoc](https://pandoc.org) | {version} | an universal document converter")

if vscode_exe := (self.winpython_directory / "t" / "VSCode" / "Code.exe").exists():
version = utils.getFileProperties(str(vscode_exe))["FileVersion"]
tool_lines.append(f"[VSCode](https://code.visualstudio.com) | {version} | a source-code editor developed by Microsoft")

return "\n".join(tool_lines)

def _get_installed_packages_markdown(self) -> str:
"""Generates Markdown for installed packages section in package index."""
if not self.distribution:
return "" # Distribution not initialized yet.
self.installed_packages = self.distribution.get_installed_packages(update=True)
package_lines = [
f"[{pkg.name}]({pkg.url}) | {pkg.version} | {pkg.description}"
for pkg in sorted(self.installed_packages, key=lambda p: p.name.lower())
]
return "\n".join(package_lines)

@property
def winpython_version_name(self) -> str:
"""Returns the full WinPython version string."""
Expand Down
2 changes: 1 addition & 1 deletion winpython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

__version__ = '15.3.20250425'
__version__ = '15.4.20250507'
__license__ = __doc__
__project_url__ = 'http://winpython.github.io/'
20 changes: 20 additions & 0 deletions winpython/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ def get_site_packages_path(path=None):
pypy_site_packages = base_dir / 'site-packages' # For PyPy
return str(pypy_site_packages if pypy_site_packages.is_dir() else site_packages)

def get_installed_tools_markdown(path=None)-> str:
"""Generates Markdown for installed tools section in package index."""
tool_lines = []
python_exe = Path(get_python_executable(path))
version = exec_shell_cmd(f'powershell (Get-Item {python_exe}).VersionInfo.FileVersion', python_exe.parent).splitlines()[0]
tool_lines.append(f"[Python](http://www.python.org/) | {version} | Python programming language with standard library")
if (node_exe := python_exe.parent.parent / "n" / "node.exe").exists():
version = exec_shell_cmd(f'powershell (Get-Item {node_exe}).VersionInfo.FileVersion', node_exe.parent).splitlines()[0]
tool_lines.append(f"[Nodejs](https://nodejs.org) | {version} | a JavaScript runtime built on Chrome's V8 JavaScript engine")

if (pandoc_exe := python_exe.parent.parent / "t" / "pandoc.exe").exists():
version = exec_shell_cmd("pandoc -v", pandoc_exe.parent).splitlines()[0].split(" ")[-1]
tool_lines.append(f"[Pandoc](https://pandoc.org) | {version} | an universal document converter")

if (vscode_exe := python_exe.parent.parent / "t" / "VSCode" / "Code.exe").exists():
version = exec_shell_cmd(f'powershell (Get-Item {vscode_exe}).VersionInfo.FileVersion', vscode_exe.parent).splitlines()[0]
tool_lines.append(f"[VSCode](https://code.visualstudio.com) | {version} | a source-code editor developed by Microsoft")
return "\n".join(tool_lines)


def onerror(function, path, excinfo):
"""Error handler for `shutil.rmtree`."""
if not os.access(path, os.W_OK):
Expand Down
12 changes: 8 additions & 4 deletions winpython/wppm.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ def create_file(self, package, name, dstdir, contents):

def get_installed_packages(self, update: bool = False) -> list[Package]:
"""Return installed packages."""

# Include package installed via pip (not via WPPM)
if str(Path(sys.executable).parent) == self.target:
self.pip = piptree.PipData()
else:
self.pip = piptree.PipData(utils.get_python_executable(self.target))
pip_list = self.pip.pip_list(full=True)

# return a list of package objects
return [Package(f"{i[0].replace('-', '_').lower()}-{i[1]}-py3-none-any.whl", suggested_summary=i[2]) for i in pip_list]

def get_installed_packages_markdown(self) -> str:
"""Generates Markdown for installed packages section in package index."""
package_lines = [
f"[{pkg.name}]({pkg.url}) | {pkg.version} | {pkg.description}"
for pkg in sorted(self.get_installed_packages(), key=lambda p: p.name.lower())
]
return "\n".join(package_lines)

def find_package(self, name: str) -> Package | None:
"""Find installed package by name."""
for pack in self.get_installed_packages():
Expand Down
0