8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 72c8ecd commit 92022e4Copy full SHA for 92022e4
pylock_to_requirements.py
@@ -1,13 +1,22 @@
1
-import tomli # or import tomllib for Python 3.11+
2
-import hashlib
3
import sys
4
from pathlib import Path
5
from collections import defaultdict
6
+# Use tomllib if available (Python 3.11+), otherwise fall back to tomli
+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
16
17
def parse_pylock_toml(path):
18
with open(path, "rb") as f:
- data = tomli.load(f)
19
+ data = tomllib.load(f)
20
21
# This dictionary maps package names to (version, [hashes])
22
package_hashes = defaultdict(lambda: {"version": "", "hashes": []})
0 commit comments