Version "attr" method in setup.py builds dist names incorrectly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
Hello,
Currently, the "Single-sourcing the package version" page provides several methods for storing a package's version in one location. The first includes a "modern" technique as of setuptools 46.4.0, describing this mechanism for use in setup.cfg:
[metadata]
version = attr: package.__version__
I was pleasantly surprised to find the setuptools.setup() call would also accept (read: not halt in an error state) this string in its version= parameter. However, I found none of the distribution files build with the correct name embedded.
I have set up a repository to test this issue here.
Setup
Given a package example_pkg, the setup.py program includes these lines:
setuptools.setup(
name="example_pkg",
version="attr: example_pkg.__version__",
# ...
)
A wheel is built with this command:
python3 setup.py bdist_wheel
Expected output
I expect the generated file to be dist/example_pkg-0.0.1-py3-none-any.whl. This is the effect when the setup() call is written like this:
setuptools.setup(
name="example_pkg",
version="0.0.1",
# ...
)
Current output
The output file is currently errantly named dist/example_pkg-attr_.example_pkg._version_-py3-none-any.whl.
Reproduction instructions
- Clone the above linked repository.
- Run
make. The errant file is in the directoryusing_setup_py/dist. A functioning example of the same version retrieval syntax is inusing_setup_cfg/.
As a last comment, it seems a bit ironic that the configuration file currently has more programmatic access to code variables than the setup script. Shouldn't these two methods behave the same? Or, is there a specification somewhere I've missed?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by cloning the linked reproduction repository and running make; compare using_setup_py/ with the functioning using_setup_cfg/ example, especially their setup.py and setup.cfg files. Reproduce the wheel built by python3 setup.py bdist_wheel and trace why its filename differs from the expected example_pkg-0.0.1-py3-none-any.whl; done means the setup.py version form produces the correct distribution name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100