Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_tag(self):
setup(
author="miles Team",
name="miles",
version="0.2.1",
version="0.2.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability, it's a good practice to define the version number in a single source of truth, such as your project's __init__.py file (e.g., miles/__init__.py), instead of hardcoding it in setup.py.

This allows you to access the version from your package code and simplifies the release process. You can then read this version in setup.py without importing the package, which avoids potential issues with dependencies.

For example, in miles/__init__.py:

__version__ = "0.2.2"

And in setup.py, you could read it by parsing the file:

import re
import os

def get_version(package_name):
    # A simple regex to extract the version string.
    version_re = re.compile(r'__version__ = "(.*?)"')
    with open(os.path.join(package_name, '__init__.py')) as f:
        match = version_re.search(f.read())
    
    if not match:
        raise RuntimeError(f"Unable to find version string in {package_name}/__init__.py")
    return match.group(1)

setup(
    # ...
    version=get_version('miles'),
    # ...
)

This approach centralizes version management and is a common pattern in Python packaging. Note that this example only handles double quotes for simplicity; a more robust solution would handle single quotes as well.

packages=find_packages(include=["miles*", "miles_plugins*"]),
include_package_data=True,
install_requires=_fetch_requirements("requirements.txt"),
Expand Down
Loading