Skip to content

Commit

Permalink
BUG: Rename scripts: do not use package names to name scripts
Browse files Browse the repository at this point in the history
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 <module>
    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`.
  • Loading branch information
jhlegarreta committed Jan 10, 2025
1 parent a77a449 commit c0ad2a1
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/example_script.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit c0ad2a1

Please sign in to comment.