I have a package that’s been working for years – its name includes a underscore:
adios_db
(GitHub - NOAA-ORR-ERD/adios_oil_database)
It includes a number of command line scripts – defined in the setup.py (I know, old fashioned) like so:
scripts = ['adios_db_init = adios_db.scripts.db_initialize:init_db_cmd',
...
'adios_db_process_json = adios_db.scripts.process_json:run_through',
]
# and then, in the setup call:
...
entry_points={'console_scripts': scripts}
This has worked just fine throughout a couple years worth of Python and setuptools updates.
But suddenly, today (Python 3.9.12, setuptools 63.2.0), I get, when trying to run the scripts:
$ adios_db_process_json ./
Traceback (most recent call last):
File "/Users/chris.barker/miniconda3/envs/adios_db/bin/adios_db_process_json", line 33, in <module>
sys.exit(load_entry_point('adios-db', 'console_scripts', 'adios_db_process_json')())
File "/Users/chris.barker/miniconda3/envs/adios_db/bin/adios_db_process_json", line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
File "/Users/chris.barker/miniconda3/envs/adios_db/lib/python3.9/importlib/metadata.py", line 542, in distribution
return Distribution.from_name(distribution_name)
File "/Users/chris.barker/miniconda3/envs/adios_db/lib/python3.9/importlib/metadata.py", line 196, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: adios-db
WTF? why is it looking for a package with a hyphen in it???
I know that for years, the ecosystem has wanted to use hyphens, rather than underscores, for some kind of normalized package(distribution) naming. I NEVER understood that – you can’t have a hyphen in the importable package name – why would you ever want one in the name in PyPi? or anywhere!!!
Anyway, I can see replacing hyphens with underscores automatically, but why would it ever go the other way around?
SO:
-
How do I fix this?
(I confess, I’ve googled a fair bit, but not gone to the current docs and updated to the latest best practices – but I am very annoyed and frustrated that this would happen to a long-functioning project without even updated to the latest Python or anything else) -
Why is this happening at all? It seems quite crazy – I really think the whole packaging world had gotten away from the “easy things should be easy” philosophy
Finally: My next step is to re-install everything from scratch, and see if this is some weird result that got accidentally introduced by some out-of-syc update – but it’s really, really weird!