Skip to content

Commit d2d6989

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

7 files changed

Lines changed: 65 additions & 40 deletions

File tree

.github/workflows/pre-release.yml

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

49
env:
510
PYTHON_VERSION: 3.13
11+
MOCK_APP_PATH: ./tests/system/test_apps/generating_app
612

713
jobs:
8-
publish-to-test-pypi:
14+
publish-pre-release:
915
runs-on: ubuntu-latest
1016
permissions:
1117
id-token: write
@@ -17,9 +23,30 @@ jobs:
1723
with:
1824
python-version: ${{ env.PYTHON_VERSION }}
1925
deps-group: release
26+
- name: Set pre-release version
27+
env:
28+
RUN_NUMBER: ${{ github.run_number }}
29+
run: |
30+
SHA=$(git rev-parse --short HEAD)
31+
BASE=$(uv version --short)
32+
uv version --frozen "${BASE}.dev${RUN_NUMBER}+g${SHA}"
2033
- name: Build packages for distribution
2134
run: uv build
22-
- name: Publish packages to Test PyPI
23-
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
24-
with:
25-
repository-url: https://test.pypi.org/legacy/
35+
36+
- name: Install splunk-appinspect dependencies
37+
run: sudo apt-get install -y libmagic1
38+
- name: Install packages for the mock app
39+
run: |
40+
mkdir -p ${{ env.MOCK_APP_PATH }}/bin/lib
41+
uv pip install ".[openai, anthropic]" --target ${{ env.MOCK_APP_PATH }}/bin/lib
42+
- name: Copy splunklib to a test app and package it as a mock app
43+
run: |
44+
cd ${{ env.MOCK_APP_PATH }}
45+
tar -czf mock_app.tgz --exclude="__pycache__" bin default metadata
46+
- name: Validate mock app with splunk-appinspect
47+
run: uvx splunk-appinspect inspect ${{ env.MOCK_APP_PATH }}/mock_app.tgz
48+
--included-tags cloud
49+
# - name: Publish packages to Test PyPI
50+
# uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
51+
# with:
52+
# repository-url: https://test.pypi.org/legacy/

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.0a0"
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

splunklib/client.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
jobs, saved searches, inputs, and indexes). All of these fields are
3333
:class:`Collection` objects::
3434
35-
appcollection = service.apps
36-
my_app = appcollection.create('my_app')
37-
my_app = appcollection['my_app']
38-
appcollection.delete('my_app')
35+
app_collection = service.apps
36+
my_app = app_collection.create('my_app')
37+
my_app = app_collection['my_app']
38+
app_collection.delete('my_app')
3939
4040
The individual elements of the collection, in this case *applications*,
4141
are subclasses of :class:`Entity`. An ``Entity`` object has fields for its
@@ -887,7 +887,7 @@ def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
887887
('content-type', 'text/xml; charset=utf-8')],
888888
'reason': 'OK',
889889
'status': 200}
890-
apps.get('nonexistant/path') # raises HTTPError
890+
apps.get('nonexistent/path') # raises HTTPError
891891
s.logout()
892892
apps.get() # raises AuthenticationError
893893
"""
@@ -969,7 +969,7 @@ def post(self, path_segment="", owner=None, app=None, sharing=None, **query):
969969
('content-type', 'text/xml; charset=utf-8')],
970970
'reason': 'Created',
971971
'status': 201}
972-
apps.get('nonexistant/path') # raises HTTPError
972+
apps.get('nonexistent/path') # raises HTTPError
973973
s.logout()
974974
apps.get() # raises AuthenticationError
975975
"""
@@ -1468,7 +1468,7 @@ def __iter__(self, **kwargs):
14681468
:type kwargs: ``dict``
14691469
:rtype: iterator over entities.
14701470
1471-
Implemented to give Collection a listish interface. This
1471+
Implemented to give Collection a list-ish interface. This
14721472
function always makes a roundtrip to the server, plus at most
14731473
two additional round trips if
14741474
the ``autologin`` field of :func:`connect` is set to ``True``.
@@ -1488,7 +1488,7 @@ def __iter__(self, **kwargs):
14881488
def __len__(self):
14891489
"""Enable ``len(...)`` for ``Collection`` objects.
14901490
1491-
Implemented for consistency with a listish interface. No
1491+
Implemented for consistency with a list-ish interface. No
14921492
further failure modes beyond those possible for any method on
14931493
an Endpoint.
14941494
@@ -1867,7 +1867,7 @@ def get(self, name="", owner=None, app=None, sharing=None, **query):
18671867
('content-type', 'text/xml; charset=utf-8')],
18681868
'reason': 'OK',
18691869
'status': 200}
1870-
saved_searches.get('nonexistant/search') # raises HTTPError
1870+
saved_searches.get('nonexistent/search') # raises HTTPError
18711871
s.logout()
18721872
saved_searches.get() # raises AuthenticationError
18731873
@@ -1967,7 +1967,7 @@ def delete(self, key):
19671967
def _entity_path(self, state):
19681968
# Overridden to make all the ConfigurationFile objects
19691969
# returned refer to the configs/ path instead of the
1970-
# properties/ path used by Configrations.
1970+
# properties/ path used by Configurations.
19711971
return PATH_CONF % state["title"]
19721972

19731973

@@ -3204,7 +3204,7 @@ def create(self, query, **kwargs):
32043204
32053205
:param query: The search query.
32063206
:type query: ``string``
3207-
:param kwargs: Additiona parameters (optional). For a list of available
3207+
:param kwargs: Additional parameters (optional). For a list of available
32083208
parameters, see `Search job parameters
32093209
<http://dev.splunk.com/view/SP-CAAAEE5#searchjobparams>`_
32103210
on Splunk Developer Portal.

uv.lock

Lines changed: 5 additions & 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)