Skip to content

Commit 58bc973

Browse files
committed
Adjust pre-release.yml to set the version before uploading to Test PyPI
1 parent be76151 commit 58bc973

6 files changed

Lines changed: 31 additions & 25 deletions

File tree

.github/workflows/pre-release.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
name: Publish SDK to Test PyPI
2-
on: [workflow_dispatch]
1+
name: Publish pre-release to Test PyPI
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- release/2.x
7+
workflow_dispatch:
38

49
env:
510
PYTHON_VERSION: 3.13
611

712
jobs:
8-
publish-to-test-pypi:
13+
publish-pre-release:
914
runs-on: ubuntu-latest
1015
permissions:
1116
id-token: write
@@ -17,6 +22,13 @@ jobs:
1722
with:
1823
python-version: ${{ env.PYTHON_VERSION }}
1924
deps-group: release
25+
- name: Set pre-release version
26+
env:
27+
RUN_NUMBER: ${{ github.run_number }}
28+
run: |
29+
SHA=$(git rev-parse --short HEAD)
30+
BASE=$(uv version --short)
31+
uv version --frozen "${BASE}.dev${RUN_NUMBER}+g${SHA}"
2032
- name: Build packages for distribution
2133
run: uv build
2234
- name: Publish packages to Test PyPI

docs/conf.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
# All configuration values have a default; values that are commented out
1010
# serve to show the default.
1111

12+
import importlib.metadata
1213
from datetime import datetime
1314

14-
import splunklib
15-
1615
# If extensions (or modules to document with autodoc) are in another directory,
1716
# add these directories to sys.path here. If the directory is relative to the
1817
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -40,17 +39,17 @@
4039
master_doc = "index"
4140

4241
# General information about the project.
43-
project = "Splunk SDK for Python"
44-
copyright = f"{datetime.now().year}, Splunk Inc."
42+
package_name = "splunk-sdk"
43+
project = f"Splunk SDK for Python (f{package_name}/splunklib)"
44+
copyright = f"2011-{datetime.now().year} Splunk, Inc."
4545

4646
# The version info for the project you're documenting, acts as replacement for
4747
# |version| and |release|, also used in various other places throughout the
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = splunklib.__version__
52-
# The full version, including alpha/beta/rc tags.
53-
release = splunklib.__version__
51+
release = importlib.metadata.version(package_name)
52+
version = ".".join(release.split(".")[:2])
5453

5554
# The language for content autogenerated by Sphinx. Refer to documentation
5655
# for a list of supported languages.

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ download = "https://github.com/splunk/splunk-sdk-python/releases/latest"
88

99
[project]
1010
name = "splunk-sdk"
11-
dynamic = ["version"]
11+
version = "3.0.0"
1212
description = "Splunk Software Development Kit for Python"
1313
readme = "README.md"
1414
requires-python = ">=3.13"
@@ -57,8 +57,7 @@ dev = [
5757
]
5858

5959
[build-system]
60-
# setuptools v61 introduces pyproject.toml support
61-
requires = ["setuptools>=61.0.0"]
60+
requires = ["setuptools>=82.0.1"]
6261
build-backend = "setuptools.build_meta"
6362

6463
[tool.setuptools]
@@ -71,9 +70,6 @@ packages = [
7170
"splunklib.ai.engines",
7271
]
7372

74-
[tool.setuptools.dynamic]
75-
version = { attr = "splunklib.__version__" }
76-
7773
[tool.basedpyright]
7874
exclude = [".venv"]
7975
allowedUntypedLibraries = ["splunklib"]

splunklib/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,3 @@ def setup_logging(
3030
level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT
3131
):
3232
logging.basicConfig(level=level, format=log_format, datefmt=date_format)
33-
34-
35-
__version_info__ = (3, 0, 0)
36-
__version__ = ".".join(map(str, __version_info__))

splunklib/binding.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:mod:`splunklib.client` module.
2525
"""
2626

27+
import importlib.metadata
2728
import io
2829
import json
2930
import logging
@@ -34,14 +35,13 @@
3435
from contextlib import contextmanager
3536
from datetime import datetime
3637
from functools import wraps
37-
from io import BytesIO
38-
from urllib import parse
3938
from http import client
4039
from http.cookies import SimpleCookie
40+
from io import BytesIO
41+
from urllib import parse
4142
from xml.etree.ElementTree import XML, ParseError
42-
from .data import record
43-
from . import __version__
4443

44+
from .data import record
4545

4646
logger = logging.getLogger(__name__)
4747

@@ -1787,9 +1787,11 @@ def connect(scheme, host, port):
17871787
def request(url, message, **kwargs):
17881788
scheme, host, port, path = _spliturl(url)
17891789
body = message.get("body", "")
1790+
1791+
sdk_version = importlib.metadata.version("splunk-sdk")
17901792
head = {
17911793
"Content-Length": str(len(body)),
1792-
"User-Agent": "splunk-sdk-python/%s" % __version__,
1794+
"User-Agent": f"splunk-sdk-python/{sdk_version}",
17931795
"Accept": "*/*",
17941796
"Connection": "Close",
17951797
} # defaults

uv.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)