pkgmap-py 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/PKG-INFO +7 -7
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/README.md +6 -6
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/pyproject.toml +1 -1
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/pyproject.toml.orig +1 -1
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/cli.py +1 -7
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/consumer.py +6 -4
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/resolver.py +4 -5
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/schema.py +0 -8
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/__init__.py +0 -0
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/apps.py +0 -0
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/db.py +0 -0
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/downloader.py +0 -0
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/logger.py +0 -0
- {pkgmap_py-0.1.0 → pkgmap_py-0.1.1}/src/pkgmap/pipeline.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pkgmap-py
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Cross-distribution Linux package name resolution
|
|
5
5
|
Author: Levizor
|
|
6
6
|
Author-email: Levizor <levizor@disroot.org>
|
|
@@ -21,6 +21,8 @@ Different distributions often package the exact same software under different na
|
|
|
21
21
|
|
|
22
22
|
Data is updated daily from [Repology](https://repology.org) and indexed for instant local lookups. On first run, `pkgmap` automatically downloads and decompresses the latest daily database release (`~/.cache/pkgmap/pkgmap.db`).
|
|
23
23
|
|
|
24
|
+
The package is available on PyPI as [`pkgmap-py`](https://pypi.org/project/pkgmap-py/).
|
|
25
|
+
|
|
24
26
|
---
|
|
25
27
|
|
|
26
28
|
## CLI Usage
|
|
@@ -79,10 +81,8 @@ pkgmap resolve bat -f arch -t debian --json
|
|
|
79
81
|
{
|
|
80
82
|
"name": "rust-bat",
|
|
81
83
|
"version": "0.22.1",
|
|
82
|
-
"category": "misc",
|
|
83
84
|
"repo": "debian_12",
|
|
84
|
-
"repo_family": "debuntu"
|
|
85
|
-
"install_name": "rust-bat"
|
|
85
|
+
"repo_family": "debuntu"
|
|
86
86
|
}
|
|
87
87
|
]
|
|
88
88
|
```
|
|
@@ -109,13 +109,13 @@ from pkgmap import resolve, resolve_all, resolve_batch
|
|
|
109
109
|
# 1. Single package resolution
|
|
110
110
|
res = resolve("bat", from_repo="arch", to_repo="debian")
|
|
111
111
|
if res:
|
|
112
|
-
print(res.
|
|
112
|
+
print(res.name, res.version)
|
|
113
113
|
# Output: rust-bat 0.22.1
|
|
114
114
|
|
|
115
115
|
# 2. Query all repositories for equivalents
|
|
116
116
|
matches = resolve_all("bat", from_repo="arch")
|
|
117
117
|
for r in matches:
|
|
118
|
-
print(f"{r.repo}: {r.
|
|
118
|
+
print(f"{r.repo}: {r.name}")
|
|
119
119
|
|
|
120
120
|
# 3. High-performance batch resolution (executed in a single SQL query)
|
|
121
121
|
packages = ["bat", "fd", "ripgrep"]
|
|
@@ -123,7 +123,7 @@ results = resolve_batch(packages, from_repo="arch", to_repo="nixpkgs")
|
|
|
123
123
|
|
|
124
124
|
for pkg, match in results.items():
|
|
125
125
|
if match:
|
|
126
|
-
print(f"{pkg} -> {match.
|
|
126
|
+
print(f"{pkg} -> {match.name}")
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
### API Methods
|
|
@@ -6,6 +6,8 @@ Different distributions often package the exact same software under different na
|
|
|
6
6
|
|
|
7
7
|
Data is updated daily from [Repology](https://repology.org) and indexed for instant local lookups. On first run, `pkgmap` automatically downloads and decompresses the latest daily database release (`~/.cache/pkgmap/pkgmap.db`).
|
|
8
8
|
|
|
9
|
+
The package is available on PyPI as [`pkgmap-py`](https://pypi.org/project/pkgmap-py/).
|
|
10
|
+
|
|
9
11
|
---
|
|
10
12
|
|
|
11
13
|
## CLI Usage
|
|
@@ -64,10 +66,8 @@ pkgmap resolve bat -f arch -t debian --json
|
|
|
64
66
|
{
|
|
65
67
|
"name": "rust-bat",
|
|
66
68
|
"version": "0.22.1",
|
|
67
|
-
"category": "misc",
|
|
68
69
|
"repo": "debian_12",
|
|
69
|
-
"repo_family": "debuntu"
|
|
70
|
-
"install_name": "rust-bat"
|
|
70
|
+
"repo_family": "debuntu"
|
|
71
71
|
}
|
|
72
72
|
]
|
|
73
73
|
```
|
|
@@ -94,13 +94,13 @@ from pkgmap import resolve, resolve_all, resolve_batch
|
|
|
94
94
|
# 1. Single package resolution
|
|
95
95
|
res = resolve("bat", from_repo="arch", to_repo="debian")
|
|
96
96
|
if res:
|
|
97
|
-
print(res.
|
|
97
|
+
print(res.name, res.version)
|
|
98
98
|
# Output: rust-bat 0.22.1
|
|
99
99
|
|
|
100
100
|
# 2. Query all repositories for equivalents
|
|
101
101
|
matches = resolve_all("bat", from_repo="arch")
|
|
102
102
|
for r in matches:
|
|
103
|
-
print(f"{r.repo}: {r.
|
|
103
|
+
print(f"{r.repo}: {r.name}")
|
|
104
104
|
|
|
105
105
|
# 3. High-performance batch resolution (executed in a single SQL query)
|
|
106
106
|
packages = ["bat", "fd", "ripgrep"]
|
|
@@ -108,7 +108,7 @@ results = resolve_batch(packages, from_repo="arch", to_repo="nixpkgs")
|
|
|
108
108
|
|
|
109
109
|
for pkg, match in results.items():
|
|
110
110
|
if match:
|
|
111
|
-
print(f"{pkg} -> {match.
|
|
111
|
+
print(f"{pkg} -> {match.name}")
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
### API Methods
|
|
@@ -112,10 +112,8 @@ def resolve_cmd(
|
|
|
112
112
|
{
|
|
113
113
|
"name": r.name,
|
|
114
114
|
"version": r.version,
|
|
115
|
-
"category": r.category,
|
|
116
115
|
"repo": r.repo,
|
|
117
116
|
"repo_family": r.repo_family,
|
|
118
|
-
"install_name": r.install_name,
|
|
119
117
|
}
|
|
120
118
|
for r in items_to_show
|
|
121
119
|
]
|
|
@@ -124,12 +122,8 @@ def resolve_cmd(
|
|
|
124
122
|
|
|
125
123
|
for res in items_to_show:
|
|
126
124
|
version_str = f" ({res.version})" if res.version else ""
|
|
127
|
-
meta_parts = []
|
|
128
|
-
if res.category and res.repo_family != "nix":
|
|
129
|
-
meta_parts.append(f"category: {res.category}")
|
|
130
|
-
meta_str = f" [{', '.join(meta_parts)}]" if meta_parts else ""
|
|
131
125
|
repo_prefix = f"{res.repo}: " if to_repo is None else ""
|
|
132
|
-
typer.echo(f"{repo_prefix}{res.
|
|
126
|
+
typer.echo(f"{repo_prefix}{res.name}{version_str}")
|
|
133
127
|
|
|
134
128
|
|
|
135
129
|
@cli_app.command(name="update")
|
|
@@ -23,14 +23,13 @@ CREATE TABLE IF NOT EXISTS packages (
|
|
|
23
23
|
package_name TEXT NOT NULL,
|
|
24
24
|
effname TEXT NOT NULL,
|
|
25
25
|
version TEXT,
|
|
26
|
-
category TEXT,
|
|
27
26
|
PRIMARY KEY (repo_id, package_name)
|
|
28
27
|
) WITHOUT ROWID;
|
|
29
28
|
"""
|
|
30
29
|
|
|
31
30
|
INSERT_PACKAGES_QUERY = (
|
|
32
|
-
"INSERT OR IGNORE INTO packages (repo_id, package_name, effname, version
|
|
33
|
-
"VALUES (?, ?, ?,
|
|
31
|
+
"INSERT OR IGNORE INTO packages (repo_id, package_name, effname, version) "
|
|
32
|
+
"VALUES (?, ?, ?, ?)"
|
|
34
33
|
)
|
|
35
34
|
|
|
36
35
|
INSERT_REPOSITORIES_QUERY = "INSERT OR REPLACE INTO repositories (id, name, family, package_count) VALUES (?, ?, ?, ?)"
|
|
@@ -38,6 +37,9 @@ INSERT_REPOSITORIES_QUERY = "INSERT OR REPLACE INTO repositories (id, name, fami
|
|
|
38
37
|
SELECT_REPO_COUNTS_QUERY = "SELECT repo_id, COUNT(*) FROM packages GROUP BY repo_id"
|
|
39
38
|
|
|
40
39
|
CREATE_INDEX_QUERY = "CREATE INDEX IF NOT EXISTS idx_effname ON packages (effname);"
|
|
40
|
+
CREATE_INDEX_PKGNAME_QUERY = (
|
|
41
|
+
"CREATE INDEX IF NOT EXISTS idx_package_name ON packages (package_name);"
|
|
42
|
+
)
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
class SQLiteConsumer:
|
|
@@ -63,7 +65,6 @@ class SQLiteConsumer:
|
|
|
63
65
|
pkg.package_name,
|
|
64
66
|
pkg.effname,
|
|
65
67
|
pkg.version,
|
|
66
|
-
pkg.category,
|
|
67
68
|
)
|
|
68
69
|
for pkg in batch
|
|
69
70
|
]
|
|
@@ -130,6 +131,7 @@ class SQLiteConsumer:
|
|
|
130
131
|
self.populate_repositories(conn, repo_families)
|
|
131
132
|
|
|
132
133
|
conn.execute(CREATE_INDEX_QUERY)
|
|
134
|
+
conn.execute(CREATE_INDEX_PKGNAME_QUERY)
|
|
133
135
|
conn.commit()
|
|
134
136
|
|
|
135
137
|
# Checkpoint WAL: Merges all pages from the write-ahead log back into the main database
|
|
@@ -94,7 +94,7 @@ def resolve_batch_all(
|
|
|
94
94
|
|
|
95
95
|
if src_repo:
|
|
96
96
|
sql = f"""
|
|
97
|
-
SELECT src.package_name, dst.package_name, dst.version,
|
|
97
|
+
SELECT src.package_name, dst.package_name, dst.version, dst_repo.name, dst_repo.family
|
|
98
98
|
FROM packages src
|
|
99
99
|
JOIN repositories src_repo ON src.repo_id = src_repo.id
|
|
100
100
|
JOIN packages dst ON src.effname = dst.effname
|
|
@@ -104,7 +104,7 @@ def resolve_batch_all(
|
|
|
104
104
|
params: list[str] = [src_repo, *chunk]
|
|
105
105
|
else:
|
|
106
106
|
sql = f"""
|
|
107
|
-
SELECT dst.effname, dst.package_name, dst.version,
|
|
107
|
+
SELECT dst.effname, dst.package_name, dst.version, dst_repo.name, dst_repo.family
|
|
108
108
|
FROM packages dst
|
|
109
109
|
JOIN repositories dst_repo ON dst.repo_id = dst_repo.id
|
|
110
110
|
WHERE dst.effname IN ({placeholders})
|
|
@@ -125,9 +125,8 @@ def resolve_batch_all(
|
|
|
125
125
|
PackageResolution(
|
|
126
126
|
name=row[1],
|
|
127
127
|
version=row[2],
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
repo_family=row[5],
|
|
128
|
+
repo=row[3],
|
|
129
|
+
repo_family=row[4],
|
|
131
130
|
)
|
|
132
131
|
)
|
|
133
132
|
return results
|
|
@@ -21,21 +21,14 @@ class PackageRecord(NamedTuple):
|
|
|
21
21
|
package_name: str # native package name
|
|
22
22
|
effname: str # unique project name, same for all packages
|
|
23
23
|
version: str | None = None
|
|
24
|
-
category: str | None = None
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
class PackageResolution(NamedTuple):
|
|
28
27
|
name: str
|
|
29
28
|
version: str | None = None
|
|
30
|
-
category: str | None = None
|
|
31
29
|
repo: str = ""
|
|
32
30
|
repo_family: str = ""
|
|
33
31
|
|
|
34
|
-
@property
|
|
35
|
-
def install_name(self) -> str:
|
|
36
|
-
"""The canonical package identifier for package managers or declarative configs."""
|
|
37
|
-
return self.name
|
|
38
|
-
|
|
39
32
|
|
|
40
33
|
# Upstream Repology PostgreSQL schema definition:
|
|
41
34
|
# https://github.com/repology/repology-updater/blob/master/sql.d/schema/create_schema_tables.sql
|
|
@@ -74,5 +67,4 @@ class RepologyPackageRow(NamedTuple):
|
|
|
74
67
|
package_name=package_name,
|
|
75
68
|
effname=self.effname,
|
|
76
69
|
version=self.version,
|
|
77
|
-
category=self.category,
|
|
78
70
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|