Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Publish SDK to Test PyPI
on: [workflow_dispatch]
name: Publish pre-release to Test PyPI
on:
push:
branches:
- develop
- release/2.x

env:
PYTHON_VERSION: 3.13

jobs:
publish-to-test-pypi:
publish-pre-release:
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -17,9 +21,18 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
deps-group: release
- name: Set pre-release version
env:
RUN_NUMBER: ${{ github.run_number }}
# --frozen skips re-locking since we only need to patch the version, not update deps.
run: |
SHA=$(git rev-parse --short HEAD)
BASE=$(uv version --short)
uv version --frozen "${BASE}.dev${RUN_NUMBER}+g${SHA}"
- name: Build packages for distribution
run: uv build
- name: Publish packages to Test PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
with:
repository-url: https://test.pypi.org/legacy/
- run: ls -Al dist/
# - name: Publish packages to Test PyPI
# uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
# with:
# repository-url: https://test.pypi.org/legacy/
13 changes: 6 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import importlib.metadata
from datetime import datetime

import splunklib

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down Expand Up @@ -40,17 +39,17 @@
master_doc = "index"

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

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

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ download = "https://github.com/splunk/splunk-sdk-python/releases/latest"

[project]
name = "splunk-sdk"
dynamic = ["version"]
version = "3.0.0"
description = "Splunk Software Development Kit for Python"
readme = "README.md"
requires-python = ">=3.13"
Expand Down Expand Up @@ -71,9 +71,6 @@ packages = [
"splunklib.ai.engines",
]

[tool.setuptools.dynamic]
version = { attr = "splunklib.__version__" }

[tool.basedpyright]
exclude = [".venv"]
allowedUntypedLibraries = ["splunklib"]
Expand Down
2 changes: 0 additions & 2 deletions splunklib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ def setup_logging(
logging.basicConfig(level=level, format=log_format, datefmt=date_format)


__version_info__ = (2, 2, 0, "alpha")
__version__ = ".".join(map(str, __version_info__))
12 changes: 7 additions & 5 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:mod:`splunklib.client` module.
"""

import importlib.metadata
import io
import json
import logging
Expand All @@ -34,14 +35,13 @@
from contextlib import contextmanager
from datetime import datetime
from functools import wraps
from io import BytesIO
from urllib import parse
from http import client
from http.cookies import SimpleCookie
from io import BytesIO
from urllib import parse
from xml.etree.ElementTree import XML, ParseError
from .data import record
from . import __version__

from .data import record

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1787,9 +1787,11 @@ def connect(scheme, host, port):
def request(url, message, **kwargs):
scheme, host, port, path = _spliturl(url)
body = message.get("body", "")

sdk_version = importlib.metadata.version("splunk-sdk")
head = {
"Content-Length": str(len(body)),
"User-Agent": "splunk-sdk-python/%s" % __version__,
"User-Agent": f"splunk-sdk-python/{sdk_version}",
"Accept": "*/*",
"Connection": "Close",
} # defaults
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright © 2011-2026 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


def test_sdk_version_readable_via_metadata() -> None:
import importlib.metadata

sdk_version = importlib.metadata.version("splunk-sdk")
assert sdk_version, "version should be a non-empty string"
assert "." in sdk_version, f"version {sdk_version!r} should contain a dot"
1 change: 1 addition & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading