@@ -135,49 +135,15 @@ def get_model_dir(model_id: str | None = None, jax: bool = False) -> Path:
135135amiciSrcPath = os .path .join (amici_path , "src" )
136136#: absolute root path of the amici module
137137amiciModulePath = os .path .dirname (__file__ )
138- #: boolean indicating if this is the full package with swig interface or
139- # the raw package without extension
140- has_clibs : bool = any (
141- os .path .isfile (os .path .join (amici_path , wrapper ))
142- for wrapper in ["amici.py" , "amici_without_hdf5.py" ]
143- )
144- #: boolean indicating if amici was compiled with hdf5 support
145- hdf5_enabled : bool = False
138+
146139
147140# Get version number from file
148- with open (os .path .join (amici_path , "version.txt" )) as f :
141+ with open (os .path .join (amici_path , "_installation" , " version.txt" )) as f :
149142 __version__ = f .read ().strip ()
150143
151144__commit__ = _get_commit_hash ()
152145
153- # Import SWIG module and swig-dependent submodules if required and available
154146if not _imported_from_setup ():
155- if has_clibs :
156- # prevent segfaults under pytest
157- # see also:
158- # https://github.com/swig/swig/issues/2881
159- # https://github.com/AMICI-dev/AMICI/issues/2565
160- with warnings .catch_warnings ():
161- warnings .filterwarnings (
162- "ignore" ,
163- category = DeprecationWarning ,
164- message = "builtin type .* has no __module__ attribute" ,
165- )
166- from . import amici
167-
168- from .amici import *
169-
170- # has to be done before importing readSolverSettingsFromHDF5
171- # from .swig_wrappers
172- hdf5_enabled = "readSolverSettingsFromHDF5" in dir ()
173- # These modules require the swig interface and other dependencies
174- from .numpy import ExpDataView , ReturnDataView # noqa: F401
175- from .pandas import *
176- from .swig_wrappers import *
177-
178- # These modules don't require the swig interface
179- from typing import Protocol , runtime_checkable
180-
181147 from .importers .sbml import ( # noqa: F401
182148 SbmlImporter ,
183149 assignment_rules_to_observables ,
@@ -189,20 +155,6 @@ def get_model_dir(model_id: str | None = None, jax: bool = False) -> Path:
189155 except (ImportError , ModuleNotFoundError ):
190156 JAXModel = object
191157
192- @runtime_checkable
193- class ModelModule (Protocol ): # noqa: F811
194- """Type of AMICI-generated model modules.
195-
196- To enable static type checking."""
197-
198- def get_model (self ) -> amici .Model :
199- """Create a model instance."""
200- ...
201-
202- AmiciModel = amici .Model | amici .ModelPtr
203- else :
204- ModelModule = ModuleType
205-
206158
207159class add_path :
208160 """Context manager for temporarily changing PYTHONPATH.
@@ -262,6 +214,9 @@ def _module_from_path(module_name: str, module_path: Path | str) -> ModuleType:
262214 return module
263215
264216
217+ ModelModule = ModuleType
218+
219+
265220def import_model_module (
266221 module_name : str , module_path : Path | str
267222) -> ModelModule :
0 commit comments