Skip to content

Commit

Permalink
feat: adds version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Aug 25, 2023
1 parent d294c24 commit 8d1712e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[run]
omit = pip_tree/cli.py
omit =
pip_tree/cli.py
pip_tree/_version.py
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v3.1.0 (2023-08-24)

- Adds `--version` flag

## v3.0.0 (2023-07-01)

- Drop support for Python 3.7
Expand Down
1 change: 1 addition & 0 deletions pip_tree/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '3.1.0'
6 changes: 6 additions & 0 deletions pip_tree/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json

import pip_tree
from pip_tree._version import __version__


class PipTreeCli:
Expand All @@ -20,6 +21,11 @@ def __init__(self):
' the virtual environment Pip Tree is run from will be used.'
),
)
parser.add_argument(
'--version',
action='version',
version=f'%(prog)s {__version__}',
)
parser.parse_args(namespace=self)

def generate_console_output(self):
Expand Down
18 changes: 14 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import re

import setuptools


with open('README.md', 'r') as fh:
long_description = fh.read()
with open('README.md', 'r') as readme_file:
long_description = readme_file.read()

# Inspiration: https://stackoverflow.com/a/7071358/6064135
with open('pip_tree/_version.py', 'r') as version_file:
version_groups = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file.read(), re.M)
if version_groups:
version = version_groups.group(1)
else:
raise RuntimeError('Unable to find version string!')

DEV_REQUIREMENTS = [
'bandit == 1.7.*',
'black == 23.*',
'build == 0.10.*',
'flake8 == 6.*',
'isort == 5.*',
'mypy == 1.3.*',
'mypy == 1.5.*',
'pytest == 7.*',
'pytest-cov == 4.*',
'twine == 4.*',
Expand All @@ -19,7 +29,7 @@

setuptools.setup(
name='pip-tree',
version='3.0.0',
version=version,
description='Get the dependency tree of your Python virtual environment via Pip.',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 8d1712e

Please sign in to comment.