Why does `python_artifact()` map the `name` field ...
# general
h
Why does
python_artifact()
map the
name
field with underscores rather than keeping the original dashes here? Is that expected behaviour? It would be useful to map the artifact target name to the resulting file.
Copy code
python_distribution(
    name="banana-python-tool-wheel",
    dependencies=[
        "banana_python/subdir",
    ],
    provides=python_artifact(name="banana-python-tool", version="1.1"),
)

> pants package banana_python/subdir:banana-python-tool-wheel
15:42:26.25 [INFO] Wrote dist/banana_python_tool-1.1-py3-none-any.whl
s
h
Oh. That’s surprising to me as other
python_distribution
targets we have haven’t experienced the same issue. Maybe because of differences in providing/generating setup.py?
s
I don't know python_distribution internals, but from wheel's point of view this looks according to spec
h
Is that spec not outdated, actually? It says archived and links to a different page where the file name convention uses dashes: https://packaging.python.org/en/latest/specifications/binary-distribution-format/#file-name-convention
Copy code
In distribution names, any run of -_. characters (HYPHEN-MINUS, LOW LINE and FULL STOP) should be replaced with _ (LOW LINE)
h
Ah yes, I should’ve scrolled further before responding
Thanks for your help. I’m fine with not being able to map wheel names to target names if it’s not simple for this case .
👍 1
s
In general wheel might have native code, so the wheel name would have platform, so it isn't straight-forward anyways though I'm pretty sure you can do that with plugins
h
There's some name canonicalization logic that is standard in Python packaging, yeah
h
Not sure how we’d managed to sidestep that name canonicalization in the past but I’ll leave it as a mystery of the universe. Thanks both