Use of normalized (e.g. with hyphens) name in console scripts #3459
Replies: 2 comments 2 replies
-
Hi @ChrisBarker-NOAA , I have a question, how are you generating the script wrappers? Are you installing the project via |
Beta Was this translation helpful? Give feedback.
-
Bingo! -- I had been using:
And when I do
why I didn't think to check that myself, I don't know -- sorry for the noise. I do see why an editable install would be more complex, though I'm still confused about the use of the normalized distribution name, rather than the regular module name -- but if it's only for the editable installs -- then it won't leak out in a risky way. (and now that I think about it -- why wouldn't this simple approach work for editable installs as well?) Thanks for the quick reply, -CHB |
Beta Was this translation helpful? Give feedback.
-
I recently happened upon a weird bug whereby my console scripts failed:
(see: https://discuss.python.org/t/whats-up-with-scripts-and-hyphens-underscores/17571)
It turns out my issue was due to a mess of broken interactions between conda environments, editable installs, and multiple git branches -- so something got weirdly out of sync -- all my fault.
However, in the process, I noticed that the console script wrapper is using the hyphenated name for teh package, which seems really odd to me.
The Python package name is
adios_db
and I don't specify a hyphenated version anywhere.I understand the distinction between a "package" and a "distribution", and that a distribution does not need to have a name that is a Python legal identifier. And that a distribution name of "adios_db" and "adios-db" are considered the same, and that the concept of a normalized name is important.
( I have no idea why the normalized form is with the hyphen, rather than the underscore, but I'll leave that alone for now)
What I don't get is why the normalized distribution name is used in this context, rather than the python package name -- it seems to me that the package name is the core, "proper" name when used in python code -- and that a console script should be identified with the python package, not the distribution.
and I'm very confused as to what would happen if the distribution provided multiple packages and / or a package with a different name than the distribution. After all, I made no mention of the distribution when I set up the console script:
That seems very clearly to mean:
the script called
adios_db_process_json
should call therun_through
function in theadios_db.scripts.process_json
module.There is no statement there about what distribution this may be a part of.
I guess this all reflects my general discomfort with pushing the concept of a "distribution" into Python itself, at run time, rather than keeping python itself all about packages and modules, and the distribution concept being about, well, the distribution of packages, and no longer reevent at run time.
And it seems gratuitous -- once you are running a console script, the code that needs to be run has to be installed as a proper python package, accessible via the usual import mechanism anyway -- shouldn't the question of what distribution it was installed as part of be irrelevant?
I suppose this is all philosophical -- it works as it is -- but I'd still like to know why it's done this way -- it feels like the wrong direction to be heading to me.
Beta Was this translation helpful? Give feedback.
All reactions