Skip to content

simplify tools.ini tricky plumbery for just 4 tools #1557

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 1 commit into from
Apr 17, 2025
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
28 changes: 12 additions & 16 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,22 @@ def package_index_markdown(self) -> str:

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

def get_tool_path(relative_path):
path = self.winpython_directory / relative_path if self.winpython_directory else None
return path if path and path.exists() else None
tool_lines = []

if nodejs_path := get_tool_path(NODEJS_RELATIVE_PATH):
installed_tools.append(("Nodejs", utils.get_nodejs_version(nodejs_path)))
installed_tools.append(("npmjs", utils.get_npmjs_version(nodejs_path)))
if (nodejs_path := self.winpython_directory / NODEJS_RELATIVE_PATH).exists():
version = utils.get_nodejs_version(nodejs_path)
tool_lines.append(f"[Nodejs](https://nodejs.org) | {version} | a JavaScript runtime built on Chrome's V8 JavaScript engine")
version = utils.get_npmjs_version(nodejs_path)
tool_lines.append(f"[npmjs](https://www.npmjs.com) | {version} | a package manager for JavaScript")

if pandoc_exe := get_tool_path("t/pandoc.exe"):
installed_tools.append(("Pandoc", utils.get_pandoc_version(str(pandoc_exe.parent))))
if (pandoc_exe := self.winpython_directory / "t" / "pandoc.exe").exists():
version = utils.get_pandoc_version(str(pandoc_exe.parent))
tool_lines.append(f"[Pandoc](https://pandoc.org) | {version} | an universal document converter")

if vscode_exe := get_tool_path("t/VSCode/Code.exe"):
installed_tools.append(("VSCode", utils.getFileProperties(str(vscode_exe))["FileVersion"]))
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")

tool_lines = []
for name, version in installed_tools:
metadata = utils.get_package_metadata("tools.ini", name)
tool_lines.append(f"[{name}]({metadata['url']}) | {version} | {metadata['description']}")
return "\n".join(tool_lines)

def _get_installed_packages_markdown(self) -> str:
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.2.20250412'
__version__ = '15.3.20250417'
__license__ = __doc__
__project_url__ = 'http://winpython.github.io/'
47 changes: 0 additions & 47 deletions winpython/data/tools.ini

This file was deleted.

21 changes: 0 additions & 21 deletions winpython/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,27 +379,6 @@ def normalize(this):
"""Apply PEP 503 normalization to the string."""
return re.sub(r"[-_.]+", "-", this).lower()

def get_package_metadata(database, name):
"""Extract infos (description, url) from the local database."""
DATA_PATH = Path(sys.modules['winpython'].__file__).parent / 'data'
db = cp.ConfigParser()
filepath = Path(database) if Path(database).is_absolute() else DATA_PATH / database
db.read_file(open(str(filepath), encoding=guess_encoding(filepath)[0]))

my_metadata = {
"description": "",
"url": f"https://pypi.org/project/{name}",
}
for key in my_metadata:
for name2 in (name, normalize(name)):
try:
my_metadata[key] = db.get(name2, key)
break
except (cp.NoSectionError, cp.NoOptionError):
pass

return my_metadata

if __name__ == '__main__':
print_box("Test")
dname = sys.prefix
Expand Down