From c0ad2a1c76f2075bb4775af1236ba05f0ec9a663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Mon, 30 Dec 2024 16:10:36 -0500 Subject: [PATCH] BUG: Rename scripts: do not use package names to name scripts Rename scripts: do not use package names to name scripts to avoid clashes. If a script has the same name as the package, importing the package or its submodules within the script may result in Python trying to import the script itself. Fixes: ``` Traceback (most recent call last): File "/snap/pycharm-professional/443/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/snap/pycharm-professional/443/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/jhlegarreta/src/tract_querier/scripts/tract_querier.py", line 286, in main() File "/home/jhlegarreta/src/tract_querier/scripts/tract_querier.py", line 94, in main if os.path.exists(tract_querier.default_queries_folder): AttributeError: module 'tract_querier' has no attribute 'default_queries_folder' ``` raised locally when debugging `tract_querier.py`. --- doc/example_script.rst | 2 +- pyproject.toml | 4 ++-- scripts/{tract_math.py => apply_tract_maths.py} | 0 scripts/{tract_querier.py => query_tracts.py} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{tract_math.py => apply_tract_maths.py} (100%) rename scripts/{tract_querier.py => query_tracts.py} (100%) diff --git a/doc/example_script.rst b/doc/example_script.rst index 3419a41..a150711 100644 --- a/doc/example_script.rst +++ b/doc/example_script.rst @@ -14,7 +14,7 @@ Once all of these files are setup, the tract bundles are obtained by issuing the .. code-block:: bash - tract_querier -t tractography_file.vtk -a wmparc.nii.gz -q wmql_script.qry -o tract_output + query_tracts -t tractography_file.vtk -a wmparc.nii.gz -q wmql_script.qry -o tract_output where **tractography_file.vtk** is the full-brain tractography, **wmparc.nii.gz** is the brain parcellation, **wmql_script.qry** is the WMQL script and **tract_output** is the prefix for the output bundles. diff --git a/pyproject.toml b/pyproject.toml index a5020e5..74adff9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,8 +46,8 @@ homepage = "http://demianw.github.io/tract_querier" repository = "https://github.com/demianw/tract_querier" [project.scripts] -tract_math = "scripts.tract_math:main" -tract_querier = "scripts.tract_querier:main" +tract_math = "scripts.apply_tract_maths:main" +tract_querier = "scripts.query_tracts:main" [tool.setuptools] include-package-data = true diff --git a/scripts/tract_math.py b/scripts/apply_tract_maths.py similarity index 100% rename from scripts/tract_math.py rename to scripts/apply_tract_maths.py diff --git a/scripts/tract_querier.py b/scripts/query_tracts.py similarity index 100% rename from scripts/tract_querier.py rename to scripts/query_tracts.py