Skip to content

Commit 7a9ae9e

Browse files
committed
Merge branch 'development'
2 parents eafc1be + 15a064d commit 7a9ae9e

3 files changed

Lines changed: 354 additions & 158 deletions

File tree

omnipkg/__init__.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
try:
4444
import tomllib
4545
except ModuleNotFoundError:
46-
# The `as tomllib` makes the rest of the code work seamlessly.
47-
import tomli as tomllib
46+
try:
47+
import tomli as tomllib
48+
except ImportError:
49+
# If neither is available, create a dummy that will fail gracefully
50+
tomllib = None
4851
# --- END OF FIX ---
4952

5053
__version__ = "0.0.0" # fallback default
@@ -59,15 +62,15 @@
5962
__dependencies__ = {dep.split()[0]: dep for dep in requires}
6063
except PackageNotFoundError:
6164
# Likely running from source → try pyproject.toml
62-
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
63-
if pyproject_path.exists():
64-
with pyproject_path.open("rb") as f:
65-
# Use the aliased `tomllib` which works on all versions
66-
pyproject_data = tomllib.load(f)
67-
__version__ = pyproject_data["project"]["version"]
68-
__dependencies__ = {
69-
dep.split()[0]: dep for dep in pyproject_data["project"].get("dependencies", [])
70-
}
65+
if tomllib is not None: # Only try if we have a TOML parser
66+
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
67+
if pyproject_path.exists():
68+
with pyproject_path.open("rb") as f:
69+
pyproject_data = tomllib.load(f)
70+
__version__ = pyproject_data["project"]["version"]
71+
__dependencies__ = {
72+
dep.split()[0]: dep for dep in pyproject_data["project"].get("dependencies", [])
73+
}
7174

7275
__all__ = [
7376
"core",

0 commit comments

Comments
 (0)