File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343try :
4444 import tomllib
4545except 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
5962 __dependencies__ = {dep .split ()[0 ]: dep for dep in requires }
6063except 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" ,
You can’t perform that action at this time.
0 commit comments