Skip to content

Commit 69bb731

Browse files
committed
Move versioning to pyproject.toml, adjust version extracting to use importlib
1 parent dae08b0 commit 69bb731

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
uses: pypa/[email protected]
2323
with:
2424
user: __token__
25-
password: ${{ secrets.pypi_password }}
25+
password: ${{ secrets.PYPI_PASSWORD }}
2626
- name: Install tox
2727
run: pip install tox
2828
- name: Generate API docs
2929
run: |
3030
rm -rf ./docs/_build
3131
tox -e docs
32-
- name : Docs Upload
32+
- name: Docs Upload
3333
uses: actions/upload-artifact@v3
3434
with:
3535
name: python_sdk_docs

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
name: Python CI
22

3-
on:
4-
[ push, workflow_dispatch ]
3+
on: [push, workflow_dispatch]
54

65
jobs:
76
build:
8-
97
runs-on: ${{ matrix.os }}
108
strategy:
119
matrix:
1210
os:
1311
- ubuntu-latest
14-
python: [ 3.9, 3.13 ]
12+
python: [3.9, 3.13]
1513
splunk-version:
1614
- "8.1"
1715
- "8.2"
@@ -34,7 +32,7 @@ jobs:
3432
uses: actions/checkout@v3
3533

3634
- name: Run docker compose
37-
run: SPLUNK_VERSION=${{matrix.splunk-version}} docker compose up -d
35+
run: SPLUNK_VERSION=${{ matrix.splunk-version }} docker compose up -d
3836

3937
- name: Setup Python
4038
uses: actions/setup-python@v4
@@ -48,4 +46,4 @@ jobs:
4846
run: tox -e py
4947
fossa-scan:
5048
uses: splunk/oss-scanning-public/.github/workflows/oss-scan.yml@main
51-
secrets: inherit
49+
secrets: inherit

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ tests/searchcommands/data/app/app.log
2020
tests/searchcommands/apps/app_with_logging_configuration/*.log
2121
Test Results*.html
2222
splunk_sdk.egg-info/
23-
splunk_sdk_python.egg-info/
2423
dist/
2524
*.observed
2625
venv/

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

splunklib/__init__.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,29 @@
1414

1515
"""Python library for Splunk."""
1616

17+
# Assure backport for Python <3.9
18+
try:
19+
from importlib.metadata import version as importlib_metadata_version
20+
except (ImportError, ModuleNotFoundError):
21+
from importlib_metadata import version as importlib_metadata_version
22+
1723
import logging
1824

19-
DEFAULT_LOG_FORMAT = '%(asctime)s, Level=%(levelname)s, Pid=%(process)s, Logger=%(name)s, File=%(filename)s, ' \
20-
'Line=%(lineno)s, %(message)s'
21-
DEFAULT_DATE_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
25+
DEFAULT_LOG_FORMAT = (
26+
"%(asctime)s, Level=%(levelname)s, Pid=%(process)s, Logger=%(name)s, File=%(filename)s, "
27+
"Line=%(lineno)s, %(message)s"
28+
)
29+
DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%M:%S %Z"
2230

2331

2432
# To set the logging level of splunklib
2533
# ex. To enable debug logs, call this method with parameter 'logging.DEBUG'
2634
# default logging level is set to 'WARNING'
27-
def setup_logging(level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT):
28-
logging.basicConfig(level=level,
29-
format=log_format,
30-
datefmt=date_format)
35+
def setup_logging(
36+
level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT
37+
):
38+
logging.basicConfig(level=level, format=log_format, datefmt=date_format)
3139

3240

33-
__version_info__ = (2, 1, 0)
34-
__version__ = ".".join(map(str, __version_info__))
41+
# Extract current package version from pyproject.toml
42+
__version__: str = importlib_metadata_version("splunk-sdk")

0 commit comments

Comments
 (0)