aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.github/workflows/ci.yml9
-rw-r--r--pyproject.toml7
-rw-r--r--vk/mutuals.py3
-rw-r--r--vk/tracking/sessions.py3
-rw-r--r--vk/tracking/status.py5
-rw-r--r--vk/version.py15
6 files changed, 39 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 27164ea..a564a9b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -27,12 +27,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '${{ matrix.python-version }}'
- name: 'Install package & dependencies'
run: pip install -q -e .
+ - name: Check that scripts are runnable
+ run: |
+ vk-mutuals --version
+ vk-status --version
+ vk-sessions --version
- name: Run tests
run: ./test/bin/main.sh
@@ -43,6 +50,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
diff --git a/pyproject.toml b/pyproject.toml
index e317174..d70286e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,17 +1,18 @@
[build-system]
-requires = ["setuptools>=61.0"]
+requires = ["setuptools>=61.0", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[project]
name = "vk_scripts"
description = "Scripts to stalk people on VK"
license = {text = "MIT"}
-version = "1.0.2"
+dynamic = ["version"]
authors = [{name = "Egor Tensin", email = "Egor.Tensin@gmail.com"}]
readme = "README.md"
requires-python = ">=3.4"
dependencies = [
+ 'importlib-metadata ~= 4.0 ; python_version < "3.8"',
"matplotlib",
]
@@ -28,3 +29,5 @@ classifiers = [
vk-sessions = "vk.tracking.sessions:main"
vk-status = "vk.tracking.status:main"
vk-mutuals = "vk.mutuals:main"
+
+[tool.setuptools_scm]
diff --git a/vk/mutuals.py b/vk/mutuals.py
index 644baf8..10dcc2e 100644
--- a/vk/mutuals.py
+++ b/vk/mutuals.py
@@ -12,6 +12,7 @@ import sys
from vk.api import API
from vk.user import UserField
from vk.utils import io
+import vk.version
_OUTPUT_USER_FIELDS = UserField.UID, UserField.FIRST_NAME, UserField.LAST_NAME
@@ -84,6 +85,8 @@ def _parse_args(args=None):
parser = argparse.ArgumentParser(
description='Learn who your ex and her new boyfriend are both friends with.')
+ vk.version.add_to_arg_parser(parser)
+
parser.add_argument('uids', metavar='UID', nargs='+',
help='user IDs or "screen names"')
parser.add_argument('-f', '--format', dest='out_fmt',
diff --git a/vk/tracking/sessions.py b/vk/tracking/sessions.py
index 278a004..4b6fd66 100644
--- a/vk/tracking/sessions.py
+++ b/vk/tracking/sessions.py
@@ -15,6 +15,7 @@ from vk.tracking.db import Format as DatabaseFormat
from vk.user import UserField
from vk.utils.bar_chart import BarChartBuilder
from vk.utils import io
+import vk.version
class Weekday(Enum):
@@ -436,6 +437,8 @@ def _parse_args(args=None):
parser = argparse.ArgumentParser(
description='View/visualize the amount of time people spend online.')
+ vk.version.add_to_arg_parser(parser)
+
parser.add_argument('db_path', metavar='input', nargs='?',
help='database file path (standard input by default)')
parser.add_argument('out_path', metavar='output', nargs='?',
diff --git a/vk/tracking/status.py b/vk/tracking/status.py
index 0a02413..0dd5e42 100644
--- a/vk/tracking/status.py
+++ b/vk/tracking/status.py
@@ -12,8 +12,9 @@ import sys
from vk.api import API
import vk.error
-from vk.user import UserField
from vk.tracking.db import Format as DatabaseFormat
+from vk.user import UserField
+import vk.version
class StatusTracker:
@@ -171,6 +172,8 @@ def _parse_args(args=None):
parser = argparse.ArgumentParser(
description='Track when people go online/offline.')
+ vk.version.add_to_arg_parser(parser)
+
parser.add_argument('uids', metavar='UID', nargs='+',
help='user IDs or "screen names"')
parser.add_argument('-t', '--timeout', metavar='SECONDS',
diff --git a/vk/version.py b/vk/version.py
new file mode 100644
index 0000000..6843bf4
--- /dev/null
+++ b/vk/version.py
@@ -0,0 +1,15 @@
+try:
+ import importlib.metadata as metadata
+except ImportError:
+ import importlib_metadata as metadata
+
+
+try:
+ __version__ = metadata.version('vk_scripts')
+except Exception:
+ __version__ = 'unknown'
+
+
+def add_to_arg_parser(parser):
+ parser.add_argument('--version', '-V', action='version',
+ version=f'%(prog)s {__version__}')