abichinger / semantic-release-pypi

semantic-release plugin to publish a python package to PyPI
MIT License
26 stars 11 forks source link

Reading package version from metadata #20

Open cuent opened 2 years ago

cuent commented 2 years ago

When making a release, the version number is hard coded. However, setup.cfg allows reading the package version from configuration files for example (if the pckg name is my_package):

setup.cfg

[metadata]
version = attr: my_package.VERSION

Problem: current implementation will override the version in setup.cfg when it should override in VERSION.

abichinger commented 11 months ago

You probably have moved on by now, but I'm still going to comment on your request.

In order to override my_package.VERSION the plugin would first need to find the line of code where VERSION is assigned. As far as I know the assignment can be in any source file of the package. The only method I can think of to accomplish this task is to use the ast module, but that seems rather difficult.

Can you think of a better solution?

pyproject.toml also allows dynamic metadata (PEP 621)