From 664072eca25abb2acff9f1b43886fb4415c50ecc Mon Sep 17 00:00:00 2001 From: Adib Kabir Date: Tue, 1 Dec 2026 04:29:41 -0800 Subject: [PATCH] fix: point diffpy-diffchooser command to diffchooser_app (IN-1.1) --- news/in-1-1-entry-point.rst | 23 +++++++++++++++++++++++ pyproject.toml | 2 +- src/diffpy/diffchooser/__init__.py | 2 +- src/diffpy/diffchooser/diffchooser_app.py | 15 ++++++++++++--- tests/test_diffchooser_app.py | 11 +++++++++++ 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 news/in-1-1-entry-point.rst create mode 100644 tests/test_diffchooser_app.py diff --git a/news/in-1-1-entry-point.rst b/news/in-1-1-entry-point.rst new file mode 100644 index 0000000..e55b7b4 --- /dev/null +++ b/news/in-1-1-entry-point.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* The ``diffpy-diffchooser`` command now starts instead of failing with ``ModuleNotFoundError``. + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 9ee9d13..ffb6861 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) [project.scripts] -diffpy-diffchooser = "diffpy.diffchooser.app:main" +diffpy-diffchooser = "diffpy.diffchooser.diffchooser_app:main" [tool.setuptools.dynamic] dependencies = {file = ["requirements/pip.txt"]} diff --git a/src/diffpy/diffchooser/__init__.py b/src/diffpy/diffchooser/__init__.py index 09eaed7..209ec7a 100644 --- a/src/diffpy/diffchooser/__init__.py +++ b/src/diffpy/diffchooser/__init__.py @@ -12,7 +12,7 @@ # See LICENSE.rst for license information. # ############################################################################## -"""Screen protein diffraction images for well diffracting samples""" +"""Screen protein diffraction images for well diffracting samples.""" # package version from diffpy.diffchooser.version import __version__ # noqa diff --git a/src/diffpy/diffchooser/diffchooser_app.py b/src/diffpy/diffchooser/diffchooser_app.py index 7987c08..0d3a2e6 100644 --- a/src/diffpy/diffchooser/diffchooser_app.py +++ b/src/diffpy/diffchooser/diffchooser_app.py @@ -3,11 +3,20 @@ from diffpy.diffchooser.version import __version__ # noqa -def main(): +def main(argv=None): + """Run the diffpy-diffchooser command line interface. + + Parameters + ---------- + argv : list of str, optional + The command line arguments. If None, the arguments are read from + the terminal. Default is None. + """ parser = argparse.ArgumentParser( prog="diffpy.diffchooser", description=( - "Screen protein diffraction images for well diffracting samples\n\n" + "Screen protein diffraction images for well diffracting " + "samples\n\n" "For more information, visit: " "https://github.com/diffpy/diffpy.diffchooser/" ), @@ -20,7 +29,7 @@ def main(): help="Show the program's version number and exit", ) - args = parser.parse_args() + args = parser.parse_args(argv) if args.version: print(f"diffpy.diffchooser {__version__}") diff --git a/tests/test_diffchooser_app.py b/tests/test_diffchooser_app.py new file mode 100644 index 0000000..89be12f --- /dev/null +++ b/tests/test_diffchooser_app.py @@ -0,0 +1,11 @@ +"""Unit tests for diffchooser_app.py.""" + +from diffpy.diffchooser import __version__ +from diffpy.diffchooser.diffchooser_app import main + + +def test_main_version(capsys): + main(["--version"]) + actual = capsys.readouterr().out.strip() + expected = f"diffpy.diffchooser {__version__}" + assert actual == expected