c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Error raised when double commas are used with __version__ #189

Closed strictness closed 3 years ago

strictness commented 3 years ago

Annoying bug where it is not possible to use bump2version if double inverted commas are used with strings denoting a version #(__init__.py, setup.py etc)

florisla commented 3 years ago

Can you share an example and your bump2version configuration?

strictness commented 3 years ago

Sure, here is the setup.py

#!/usr/bin/env python

"""The setup script."""

from setuptools import setup, find_packages

with open("README.md") as readme_file:
    readme = readme_file.read()

with open("HISTORY.rst") as history_file:
    history = history_file.read()

requirements = ["Click>=7.0", "pandas", "numpy", "scikit-learn", "joblib"]

setup_requirements = ["pytest-runner"]

test_requirements = ["pytest>=3", "pytest-mock", "mock"]

setup(
    author="Me",
    author_email="me@me.com",
    python_requires=">=3.7",
    classifiers=[
        "Development Status :: 2 - Pre-Alpha",
        "Intended Audience :: Developers",
        "Natural Language :: English",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
    ],
    install_requires=requirements,
    long_description=readme + "\n\n" + history,
    include_package_data=True,
    keywords="new_pkg",
    name="new_pkg",
    packages=find_packages(include=["new_pkg", "new_pkg.*"]),
    setup_requires=setup_requirements,
    test_suite="tests",
    tests_require=test_requirements,
    version="2.3.0",
    zip_safe=False,
)

So new_env is my conda environment name, and here is what I get running on bump2version patch on Windows 10:

Traceback (most recent call last):
  File "c:\python\envs\new_env\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python\envs\new_env\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python\envs\new_env\Scripts\bump2version.exe\__main__.py", line 7, in <module>
  File "c:\python\envs\new_env\lib\site-packages\bumpversion\cli.py", line 124, in main
    _check_files_contain_version(files, current_version, context)
  File "c:\python\envs\new_env\lib\site-packages\bumpversion\cli.py", line 618, in _check_files_contain_version
    f.should_contain_version(current_version, context)
  File "c:\python\envs\new_env\lib\site-packages\bumpversion\utils.py", line 68, in should_contain_version
    raise VersionNotFoundException(
bumpversion.exceptions.VersionNotFoundException: Did not find 'version='2.3.0'' in file: 'setup.py'

If I run the same command but with single inverted commas around 2.3.0 it works fine

strictness commented 3 years ago

I found the problem in the config. Sorry for the false alarm ;)