Skip to content

Commit

Permalink
Proper approach to self version
Browse files Browse the repository at this point in the history
  • Loading branch information
dvershinin committed Jun 12, 2019
1 parent 2a01777 commit aefa547
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions lastversion/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.10"
4 changes: 3 additions & 1 deletion lastversion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""

__author__ = "Danila Vershinin"
__version__ = "0.0.10"

from .lastversion import main
from .__about__ import (
__version__,
)
5 changes: 2 additions & 3 deletions lastversion/lastversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import json
from bs4 import BeautifulSoup
from packaging.version import Version, InvalidVersion
import pkg_resources # for fetching version info
import logging as log # for verbose output
from __about__ import __version__


def sanitize_version(version):
Expand Down Expand Up @@ -156,8 +156,7 @@ def main():
choices=['json', 'version'],
help='Output format')
parser.add_argument('--version', action='version',
version='%(prog)s {version}'.format(
version=pkg_resources.require("lastversion")[0].version))
version='%(prog)s {version}'.format(version=__version__))
parser.set_defaults(sniff=True, validate=True, verbose=False, format='version', pre=False)
args = parser.parse_args()

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
base_dir = os.path.dirname(__file__)

version = {}
with open(os.path.join(base_dir, "lastversion", "__init__.py")) as f:
exec(f.read(), version)
with open(os.path.join(base_dir, "lastversion", "__about__.py")) as fp:
exec(fp.read(), version)

setup(
name="lastversion",
Expand Down

0 comments on commit aefa547

Please sign in to comment.