Skip to content

Commit

Permalink
Create dxtbx.any2nexus dispatcher through setuptools (#739)
Browse files Browse the repository at this point in the history
Previously, this was only created through libtbx build mechanisms, because
the build script looked for defined run functions, not imported ones.
  • Loading branch information
ndevenish committed Jun 23, 2024
1 parent d3fbb7f commit e8c2c92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def get_entry_point(filename: Path, prefix: str, import_path: str) -> List[str]:
tree = ast.parse(contents)
# Find root functions named "run"
has_run = any(
x for x in tree.body if isinstance(x, ast.FunctionDef) and x.name == "run"
x
for x in tree.body
if (isinstance(x, ast.FunctionDef) and x.name == "run")
or (isinstance(x, ast.ImportFrom) and "run" in [a.name for a in x.names])
)
if not has_run:
return []
Expand Down
1 change: 1 addition & 0 deletions newsfragments/739.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add any2nexus to formal dispatcher mechanisms.
2 changes: 1 addition & 1 deletion src/dxtbx/format/nxmx_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ def add_crystal(self, multi_crystal_group_name, crystal):
)


def run(args):
def run(args: list[str] | None = None):
usage = "dials.python nxmx_writer.py <experiments OR image files>"
parser = ArgumentParser(
usage=usage,
Expand Down

0 comments on commit e8c2c92

Please sign in to comment.