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 13, 2025
1 parent af87be4 commit a468e16
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
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 a468e16

Please sign in to comment.