pydanny / cookiecutter-djangopackage

A cookiecutter template for creating reusable Django packages quickly.
435 stars 152 forks source link

Use a version manager tool instead of get_version() #113

Closed audreyfeldroy closed 4 years ago

audreyfeldroy commented 8 years ago

Our current approach to getting the version number involves a custom get_version() that reads __init__py and parses it with a regexp: https://github.com/pydanny/cookiecutter-djangopackage/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/setup.py#L20-L29

It's better than importing the package to get the version (which causes chicken-egg problems), but really not ideal.

There are tools that can handle this for us:

TODOs:

browniebroke commented 7 years ago

This commit added bumpversion to this package, but it's currently crashing* because it cannot find the version string in the setup.py file: it was removed a few days ago in 89157eef71a16b9d60959141de09ce59cdf90b3c

Either we remove [bumpversion:file:setup.py] from setup.cfg or we revert 89157eef71a16b9d60959141de09ce59cdf90b3c and document it properly.

(*) I just tried to run bumpversion on a recently generated package and I had: AssertionError: Did not find '0.1.0' or '0.1.0' in file setup.py.

audiolion commented 7 years ago

I just ran into this and thought I did something wrong with the setup, I feel like it should be reverted until fixed because grabbing the latest from github includes this bug :(

also the bumpversion docs and stuff are a little confusing, I found just doing

bumpversion patch for 0.1.0 -> 0.1.1 bumpversion minor for 0.1.0 -> 0.2.0 bumpversion major for 0.1.0 -> 1.0.0

works because bumpversion automatically looks for a .bumpversion.cfg file and if not found falls back to setup.cfg, finds the settings and uses those.

the whole get_version() doesn't really need to be used with bumpversion because it automatically modifies the setup.py, __init__.py, and setup.cfg versioning along with providing the commit message for the version bump.

bumpversion also takes care of creating the git tag based on the new version so the documentation about creating the git tag isn't needed, but we could also include how you pass a message to the git tag with bumpversion if that is desired.

I am willing to update all these things in a PR if you want!