Skip to content

Commit f93013e

Browse files
authored
Merge pull request #39 from microBioRust/main
fixing top-level imports, adding __init__.py for that
2 parents 42cb684 + 8746265 commit f93013e

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# microbiorust/__init__.py
2+
from .microbiorust import *
3+
4+
__all__ = list(globals().keys())
5+
6+
try:
7+
from . import microbiorust as _base
8+
9+
#list of submodules importable
10+
submodules = ["gbk", "embl", "align", "seqmetrics"]
11+
12+
for sub_name in submodules:
13+
#get the submodule from the base binary
14+
sub_module = getattr(_base, sub_name, None)
15+
16+
if sub_module:
17+
#making the submodule available: microbiorust.gbk
18+
globals()[sub_name] = sub_module
19+
__all__.append(sub_name)
20+
21+
#make functions available at top level: microbiorust.gbk_to_faa()
22+
for func_name in dir(sub_module):
23+
if not func_name.startswith('_'):
24+
globals()[func_name] = getattr(sub_module, func_name)
25+
if func_name not in __all__:
26+
__all__.append(func_name)
27+
28+
except (ImportError, AttributeError):
29+
# This ensures the package still "exists" even if the binary
30+
# hasn't been compiled yet (useful during certain build steps)
31+
pass

microbiorust-py/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ Repository = "https://github.com/microBioRust/microBioRust"
3232
manifest-path = "Cargo.toml"
3333
bindings = "pyo3"
3434
module-name = "microbiorust"
35-
features = ["pyo3/extension-module","pyo3/abi3-py310"]
35+
python-source = "."
36+
features = ["pyo3/extension-module", "pyo3/abi3-py310"]

0 commit comments

Comments
 (0)