Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove own usage of incremental. #398

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
version = attr: towncrier.__version__
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#!/usr/bin/env python


# If incremental is not present then setuptools just silently uses v0.0.0 so
# let's import it and fail instead.
import incremental # noqa

from setuptools import find_packages, setup


Expand Down Expand Up @@ -37,17 +31,18 @@
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
use_incremental=True,
python_requires=">=3.7",
install_requires=[
"click",
"click-default-group",
"incremental",
"jinja2",
"setuptools",
"tomli",
],
extras_require={"dev": ["packaging"]},
extras_require={
"dev": ["packaging"],
"incremental": ["incremental"],
},
package_dir={"": "src"},
packages=find_packages("src"),
license="MIT",
Expand Down
3 changes: 1 addition & 2 deletions src/towncrier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
towncrier, a builder for your news files.
"""

from ._version import __version__

__version__ = "21.9.1.dev0"

__all__ = ["__version__"]
11 changes: 8 additions & 3 deletions src/towncrier/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

from importlib import import_module

from incremental import Version

# Incremental is a soft dependency.
try:
from incremental import Version as IncrementalVersion
except ImportError:
IncrementalVersion = None


def _get_package(package_dir, package):
Expand Down Expand Up @@ -47,7 +52,7 @@ def get_version(package_dir, package):
if isinstance(version, str):
return version.strip()

if isinstance(version, Version):
if IncrementalVersion and isinstance(version, IncrementalVersion):
return version.base().strip()

if isinstance(version, tuple):
Expand All @@ -73,6 +78,6 @@ def get_project_name(package_dir, package):
if isinstance(version, str):
return package.title()

if isinstance(version, Version):
if IncrementalVersion and isinstance(version, IncrementalVersion):
# Incremental has support for package names
return version.package
13 changes: 7 additions & 6 deletions src/towncrier/_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@

from click_default_group import DefaultGroup

from ._version import __version__
from towncrier import __version__

from .build import _main as _build_cmd
from .check import _main as _check_cmd
from .create import _main as _create_cmd


@click.group(cls=DefaultGroup, default="build", default_if_no_args=True)
@click.version_option(__version__.public())
def cli():
@click.version_option(__version__)
def towncrier():
pass


cli.add_command(_build_cmd)
cli.add_command(_check_cmd)
cli.add_command(_create_cmd)
towncrier.add_command(_build_cmd)
towncrier.add_command(_check_cmd)
towncrier.add_command(_create_cmd)
12 changes: 0 additions & 12 deletions src/towncrier/_version.py

This file was deleted.

4 changes: 4 additions & 0 deletions src/towncrier/newsfragments/308.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Towncrier no longer used `incremental` to manage its version.
Extracting the target project name and version from an `incremental Version`
instance is still supported.
You will need to intall the `incremental` extra dependency.
23 changes: 23 additions & 0 deletions src/towncrier/test/test_shell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Tests for the high-level CLI command.
# Sub-commands are tested via separate test files.
#
from click.testing import CliRunner
from twisted.trial.unittest import TestCase

from towncrier import __version__
from towncrier._shell import towncrier


class TestCli(TestCase):
def test_version(self):
"""
The top level `--version` arguments returns towncrier own version.
"""

runner = CliRunner()

result = runner.invoke(towncrier, ["--version"])

self.assertEqual(0, result.exit_code)
self.assertEqual(result.output.strip(), f"towncrier, version {__version__}")