8000 compatible with dot version and python-3.10 · winpython/winpython@92022e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 92022e4

Browse files
committed
compatible with dot version and python-3.10
1 parent 72c8ecd commit 92022e4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pylock_to_requirements.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
import tomli # or import tomllib for Python 3.11+
2-
import hashlib
31
import sys
42
from pathlib import Path
53
from collections import defaultdict
64

5+
# Use tomllib if available (Python 3.11+), otherwise fall back to tomli
6+
try:
7+
import tomllib # Python 3.11+
8+
except ImportError:
9+
try:
10+
import tomli as tomllib # For older Python versions
11+
except ImportError:
12+
print("Please install tomli for Python < 3.11: pip install tomli")
13+
sys.exit(1)
14+
15+
716

817
def parse_pylock_toml(path):
918
with open(path, "rb") as f:
10-
data = tomli.load(f)
19+
data = tomllib.load(f)
1120

1221
# This dictionary maps package names to (version, [hashes])
1322
package_hashes = defaultdict(lambda: {"version": "", "hashes": []})

0 commit comments

Comments
 (0)
0