From a468e167cf8c515ef06463ae5385558984c1866e 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`. --- pyproject.toml | 4 ++-- scripts/{tract_math.py => apply_tract_maths.py} | 0 scripts/{tract_querier.py => query_tracts.py} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename scripts/{tract_math.py => apply_tract_maths.py} (100%) rename scripts/{tract_querier.py => query_tracts.py} (100%) 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