Skip to content

Commit

Permalink
fix version traceback in python 3.12 (#276)
Browse files Browse the repository at this point in the history
* fix version traceback in python 3.12

* bump version
  • Loading branch information
nosarthur authored Jun 4, 2024
1 parent 8c17759 commit 4eae9d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
19 changes: 17 additions & 2 deletions gita/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
import pkg_resources
import sys

__version__ = pkg_resources.get_distribution("gita").version

def get_version() -> str:
try:
import pkg_resources
except ImportError:
try:
from importlib.metadata import version
except ImportError:
print("cannot determine version", sys.version_info)
else:
return version("gita")
else:
return pkg_resources.get_distribution("gita").version


__version__ = get_version()
8 changes: 4 additions & 4 deletions gita/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
import argcomplete
import subprocess
from functools import partial
import pkg_resources
from itertools import chain
from pathlib import Path
import glob
from typing import Dict, Optional

from . import utils, info, common, io
from . import utils, info, common, io, get_version


def _group_name(name: str, exclude_old_names=True) -> str:
Expand Down Expand Up @@ -453,8 +452,9 @@ def main(argv=None):
title="sub-commands", help="additional help with sub-command -h"
)

version = pkg_resources.require("gita")[0].version
p.add_argument("-v", "--version", action="version", version=f"%(prog)s {version}")
p.add_argument(
"-v", "--version", action="version", version=f"%(prog)s {get_version()}"
)

# bookkeeping sub-commands
p_add = subparsers.add_parser("add", description="add repo(s)", help="add repo(s)")
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup(
name="gita",
packages=["gita"],
version="0.16.7",
version="0.16.7.1",
license="MIT",
description="Manage multiple git repos with sanity",
long_description=long_description,
Expand Down Expand Up @@ -35,6 +35,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
include_package_data=True,
)

0 comments on commit 4eae9d7

Please sign in to comment.