peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 147 forks source link

Wrongly bump other package's version if they're in same file and version number are same with current package version #83

Closed nyanshell closed 9 years ago

nyanshell commented 9 years ago

If current_version same with a requirement package's version in a meta file(like setup.py), bumpversion will wrongly bump requirments's version.

In following example, "package>=0.0.1" shouldn't be changed:

(yasaka)mitsukeru@Miku:~/project/test-proj$ bumpversion patch --dry-run --verbose
Reading config file .bumpversion.cfg:
[bumpversion]
files = setup.py test-proj/__init__.py
commit = True
tag = True
current_version = 0.0.1

Parsing version '0.0.1' using regexp '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'
Parsed the following values: major=0, minor=0, patch=1
Attempting to increment part 'patch'
Values are now: major=0, minor=0, patch=2
Dry run active, won't touch any files.
New version will be '0.0.2'
Asserting files setup.py, test-proj/__init__.py contain the version string:
Found '0.0.1' in setup.py at line 11:     "package>=0.0.1"
Found '0.0.1' in test-proj/__init__.py at line 2: __version__ = '0.0.1'
Would change file setup.py:
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@
 readme = open('README.rst').read()

 requirements = [
-    "package>=0.0.1"
+    "package>=0.0.2"
     # TODO: put package requirements here
 ]

@@ -19,7 +19,7 @@

 setup(
     name='test-proj',
-    version='0.0.1',
+    version='0.0.2',
     description='feature generators used inside BosonData.',
     long_description=readme,
     author='gestapolur',
Would change file test-proj/__init__.py:
--- a/test-proj/__init__.py
+++ b/test-proj/__init__.py
@@ -1,3 +1,3 @@
 # -*- coding: utf-8 -*-

-__version__ = '0.0.1'
+__version__ = '0.0.2'
Would write to config file .bumpversion.cfg:
[bumpversion]
files = setup.py test-proj/__init__.py
commit = True
tag = True
current_version = 0.0.2
peritus commented 9 years ago

So, bumpversion is agnostic to the file format by design (i.e. it doesn't know about what version is a dependency and which is the software that is versioned).

Does https://github.com/peritus/bumpversion/issues/76#issuecomment-75938030 work for you or is this about something else ?

nyanshell commented 9 years ago

@peritus Not really, I edited my .bumpversion.cfg like this:

[bumpversion]
files = setup.py
commit = True
tag = True
current_version = 0.0.1
[bumpversion:file:setup.py]
search = version='{current_version}',
replace = version='{new_version}',

but it still did change like this:

 requirements = [
-    "package>=0.0.1"
+    "package>=0.0.2"
     # TODO: put package requirements here
 ]

@@ -19,7 +19,7 @@

 setup(
     name='test-proj',
-    version='0.0.1',
+    version='0.0.2',
     description='blablabla',
     long_description=readme,
peritus commented 9 years ago

Strange. What if you remove

files = setup.py

?

nyanshell commented 9 years ago

Oh, it works somehow:

(yasaka)mitsukeru@Miku:~/project/test-proj$ bumpversion patch --dry-run --verbose
Reading config file .bumpversion.cfg:
[bumpversion]
commit = True
tag = True
current_version = 0.0.1
[bumpversion:file:setup.py]
search = version='{current_version}',
replace = version='{new_version}',

Parsing version '0.0.1' using regexp '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'
Parsed the following values: major=0, minor=0, patch=1
Attempting to increment part 'patch'
Values are now: major=0, minor=0, patch=2
Dry run active, won't touch any files.
New version will be '0.0.2'
Asserting files setup.py contain the version string:
Found 'version='0.0.1',' in setup.py at line 21:     version='0.0.1',
Would change file setup.py:
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@

 setup(
     name='test-proj',
-    version='0.0.1',
+    version='0.0.2',
     description='blablabla',
     long_description=readme,
     author='gestapolur',
Would write to config file .bumpversion.cfg:
[bumpversion]
commit = True
tag = True
current_version = 0.0.2

[bumpversion:file:setup.py]
search = version='{current_version}',
replace = version='{new_version}',

Would prepare Git commit
Would add changes in file 'setup.py' to Git
Would add changes in file '.bumpversion.cfg' to Git
Would commit to Git with message 'Bump version: 0.0.1 → 0.0.2'
Would tag 'v0.0.2' in Git

But such configure seems werid.

peritus commented 9 years ago

But such configure seems werid.

I'm committed to making bumpversion as simple as possible (though, not simpler). I'd like your opinion on what could be done better (one action point for me is pointing this out in the docs because you're not the first person to ask about this since it was implemented).

One idea would be to make bumpversion language-specific (so that it knows about setup.py or setup.cfg and to differentiate between deps and versions of the package at hand), but then again there are a few hundred other software package metadata specifications.

peritus commented 9 years ago

Also happy for you that it works :)