10000 Merge pull request #1331 from stonebig/master · winpython/winpython@082e214 · GitHub
[go: up one dir, main page]

Skip to content

Commit 082e214

Browse files
authored
Merge pull request #1331 from stonebig/master
use packages.ini directly in piptree
2 parents 0e70f06 + dfcdcfe commit 082e214

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

winpython/data/packages.ini

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3805,3 +3805,27 @@ description = A hyperparameter optimization framework
38053805
[overrides]
38063806
description = A decorator to automatically detect mismatch when overriding a method.
38073807

3808+
[adbc-driver-manager]
3809+
description = A generic entrypoint for ADBC drivers.
3810+
3811+
[dask-expr]
3812+
description = High Level Expressions for Dask
3813+
3814+
[langchain-community]
3815+
description = Community contributed LangChain integrations.
3816+
3817+
[langchain-core]
3818+
description = Building applications with LLMs through composability
3819+
3820+
[langchain-text-splitters]
3821+
description = LangChain text splitting utilities
3822+
3823+
[optree]
3824+
description = Optimized PyTree Utilities.
3825+
3826+
[ml-dtypes]
3827+
description = stand-alone implementation of several NumPy dtype extensions used in machine learning libraries
3828+
3829+
[pydantic-core]
3830+
description = Core functionality for Pydantic validation and serialization
3831+

winpython/piptree.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,37 @@
77
from importlib.metadata import Distribution , distributions
88
from pathlib import Path
99

10+
# for package.ini safety belt
11+
from winpython.config import DATA_PATH
12+
import configparser as cp
13+
1014
def normalize(this):
1115
"""apply https://peps.python.org/pep-0503/#normalized-names"""
1216
return re.sub(r"[-_.]+", "-", this).lower()
1317

18+
def get_packages_ini_metadata(name):
19+
"""Extract infos (description, url) from the local database"""
20+
# we store only normalized names now (PEP 503)
21+
database= "packages.ini"
22+
db = cp.ConfigParser()
23+
try:
24+
db.read_file(open(str(Path(DATA_PATH) / database), encoding = 'utf-8'))
25+
except:
26+
db.read_file(open(str(Path(DATA_PATH) / database)))
27+
my_metadata = dict(
28+
description="",
29+
url="https://pypi.org/project/" + name,
30+
)
31+
for key in my_metadata:
32+
# wheel replace '-' per '_' in key
33+
for name2 in (name, normalize(name)):
34+
try:
35+
my_metadata[key] = db.get(name2, key)
36+
break
37+
except (cp.NoSectionError, cp.NoOptionError):
38+
pass
39+
db_desc = my_metadata["description"]
40+
return my_metadata
1441

1542
class pipdata:
1643
"""Wrapper around Distribution.discover() or pip inspect"""
@@ -91,7 +118,7 @@ def __init__(self, Target=None):
91118
self.distro[key] = {
92119
"name": name,
93120
"version": p.version,
94-
"summary": meta["Summary"] if "Summary" in meta else "",
121+
"summary": meta["Summary"] if "Summary" in meta else get_packages_ini_metadata(key)["description"],
95122
"requires_dist": requires,
96123
"wanted_per": [],
97124
"description": meta["Description"] if "Description" in meta else "",

0 commit comments

Comments
 (0)
0