Skip to content

Commit 8046a8f

Browse files
committed
Align branches after upstreaming
1 parent 47030d8 commit 8046a8f

5 files changed

Lines changed: 78 additions & 41 deletions

File tree

.env renamed to .env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ version=9.0
1313
# Bearer token for authentication
1414
#splunkToken="<Bearer-token>"
1515
# Session key for authentication
16-
#token="<Session-Key>"
16+
#token="<Session-Key>"

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,11 @@ $RECYCLE.BIN/
278278
# End of https://www.toptal.com/developers/gitignore/api/windows,macos,linux,pycharm+all,python
279279

280280
.vscode/
281-
docs/_build/
281+
docs/_build/
282+
283+
!*.conf.spec
284+
**/metadata/local.meta
285+
286+
*.spl
287+
*.tgz
288+
*.tar*

README.md

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,69 @@ The [Splunk Enterprise](https://www.splunk.com/en_us/products/splunk-enterprise.
77

88
You may be asking:
99

10-
- [What are Splunk apps?](https://help.splunk.com/en/splunk-enterprise/administer/admin-manual/10.0/meet-splunk-apps/apps-and-add-ons)
11-
- [What can Splunk apps do?](https://dev.splunk.com/enterprise/docs/developapps/extensionpoints)
12-
- [How do I write Splunk apps?](https://dev.splunk.com/enterprise/docs/welcome)
10+
- [What are Splunk Apps?](https://help.splunk.com/en/splunk-enterprise/administer/admin-manual/10.0/meet-splunk-apps/apps-and-add-ons)
11+
- [What can Splunk Apps do?](https://dev.splunk.com/enterprise/docs/developapps/extensionpoints)
12+
- [How do I write Splunk Apps?](https://dev.splunk.com/enterprise/docs/welcome)
1313
- [Where does the SDK fit in all this?](https://dev.splunk.com/enterprise/docs/devtools/python/sdk-python/)
1414
- What's the difference between `import splunklib` and `import splunk`?
15-
- This repo contains `splunklib`. `splunk` is an internal library bundled with the Splunk platform.
15+
- This repo contains `splunklib`, whereas `splunk` is an internal library bundled with the Splunk platform.
1616

1717
## Getting started
1818

19-
### Pre-requirements
19+
### Requirements
2020

21-
#### Python
21+
- [Python 3.13 or newer](https://www.python.org/downloads/)
22+
- [Splunk Enterprise/Cloud](http://www.splunk.com/download)
2223

23-
Please use the latest Python version supported when developing. Splunk Enterprise SDK for Python is tested with Python 3.9 and 3.13.
24+
### Installing the SDK
2425

25-
#### Splunk Enterprise
26+
Using `uv`:
2627

27-
This SDK is only tested with Splunk Enterprise versions supported in the [Splunk Software Support Policy](https://www.splunk.com/en_us/legal/splunk-software-support-policy.html).
28+
```python
29+
uv init
30+
uv add splunk-sdk
31+
uv sync
32+
```
2833

29-
[Go here](http://www.splunk.com/download) to get Splunk Enterprise.
34+
If you prefer not using `uv`, using `pip` should work as expected:
3035

31-
### Installing the SDK
36+
```sh
37+
python3 -m venv .venv
38+
source .venv/bin/activate
39+
python3 -m pip install splunk-sdk
40+
```
3241

33-
Using `pip` is the easiest way to pull the SDK into your project. `poetry` and `uv` should work just as well. A project-specific virtualenv is recommended.
42+
### Including external dependencies in your App
3443

35-
In your app's project folder:
44+
Because of the way Splunk Apps are built, you need to install your external dependencies to `bin/lib/` for the App to work. Then in your App script files:
45+
46+
```python
47+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "lib"))
48+
```
49+
50+
### Packaging your App
51+
52+
An example workflow to package your App for uploading to Splunk (expect to modify it heavily):
3653

3754
```sh
38-
python -m venv .venv
39-
source .venv/bin/activate
40-
python -m pip install splunk-sdk --target bin/
55+
python3 -m pip install . \
56+
--target bin/lib/ \
57+
# Needs to match the platform Splunk is built and
58+
# ran on, NOT the one you're writing your App on
59+
--platform manylinux2014_aarch64 \
60+
--only-binary=:all:
61+
62+
gtar --transform='s,^,<your_app>/,' \
63+
--exclude="__pycache__" \
64+
-czf dist/<your_app>.tgz \
65+
bin default
66+
67+
# `<your_app>.tgz` should be now ready in `dist/`!
4168
```
4269

43-
Install your dependencies into `bin/` if bundling with an app, otherwise you can skip it.
44-
[See docs](https://dev.splunk.com/enterprise/docs/developapps/createapps/appanatomy/) on more details about packaging additional dependencies with your app.
70+
[See docs](https://dev.splunk.com/enterprise/docs/developapps/createapps/appanatomy) for more details.
4571

46-
### Using SDK in apps
72+
### Using SDK in Splunk Apps
4773

4874
The easiest and most effective way of learning how to use this library should be reading through the apps in our test suite, as well as the [splunk-app-examples](https://github.com/splunk/splunk-app-examples) repository. They show how to programmatically interact with the Splunk platform in a variety of scenarios - from basic metadata retrieval, one-shot searching and managing saved searches to building complete applications with modular inputs and custom search commands.
4975

@@ -166,27 +192,38 @@ class MyScript(Script):
166192
We welcome all contributions!
167193
If you would like to contribute to the SDK, see [Contributing to Splunk](https://www.splunk.com/en_us/form/contributions.html). For additional guidelines, see [CONTRIBUTING](CONTRIBUTING.md).
168194

169-
#### Testing
195+
### Setting up a development environment
170196

171-
This repository contains both unit and integration tests. The latter need `docker`/`podman` to work.
197+
Make sure you have `uv` and `docker`/`podman` installed and available in your `$PATH`. Run `make uv-sync` to get a virtualenv set up or updated. After activating it with `source .venv/bin/activate` you should be ready to go!
172198

173-
##### Create an `.env` file
199+
#### Creating an `.env` file
174200

175-
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and authentication. For convenience during development, you can store these arguments as key-value pairs in a `.env` file.
201+
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and authentication. For convenience during development, you can store these arguments as key-value pairs in an `.env` file.
176202

177203
A file called `.env.template` exists in the root of this repository. Duplicate it as `.env`, then adjust it to your match your environment.
178204

205+
```sh
206+
cp .env.template .env
207+
```
208+
179209
> **WARNING:** The `.env` file isn't part of the Splunk platform. This is **not** the place for production credentials!
180210
211+
#### Testing
212+
213+
This repository contains a suite of unit and integration tests.
214+
181215
```sh
182216
# Run entire test suite:
183217
make test
218+
184219
# Run only the unit tests:
185220
make test-unit
186221
```
187222

188223
##### Integration tests
189224

225+
The integration suite requires `docker`/`podman` to work.
226+
190227
> NOTE: Before running the integration tests, make sure the instance of Splunk you are testing against doesn't have new events being dumped continuously into it. Several of the tests rely on a stable event count. It's best to test against a clean install of Splunk but if you can't, you should at least disable the \*NIX and Windows apps.
191228
192229
```sh
@@ -200,7 +237,7 @@ make test-integration
200237

201238
> Do not run the test suite against a production instance of Splunk! It will run just fine with the free Splunk license.
202239
203-
### Setting up logging for splunklib
240+
#### Enabling logging in `splunklib`
204241

205242
The default level is WARNING, which means that only events of this level and above will be visible
206243
To change a logging level we can call setup_logging() method and pass the logging level as an argument.
@@ -231,23 +268,16 @@ setup_logging(logging.DEBUG)
231268

232269
Stay connected with other developers building on the Splunk platform.
233270

234-
- [E-mail](mailto:devinfo@splunk.com)
235-
- [Issues and pull requests](https://github.com/splunk/splunk-sdk-python/issues/)
236-
- [Community Slack](https://splunk-usergroups.slack.com/app_redirect?channel=appdev)
237271
- [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools)
272+
- [Issues and pull requests](https://github.com/splunk/splunk-sdk-python/issues/)
273+
- [Send an e-mail to Splunk Dev Platform](mailto:devinfo@splunk.com)
238274

239-
### Support
275+
## Support
240276

241-
- You will be granted support if you or your company are already covered under an existing maintenance/support agreement. Submit a new case in the [Support Portal](https://www.splunk.com/en_us/support-and-services.html) and include `Splunk Enterprise SDK for Python` in the subject line.
277+
- You will be granted support if you or your company are already covered under an existing maintenance/support agreement. Submit a new case in the [Support Portal](https://www.splunk.com/en_us/support-and-services.html) and include at least `Splunk Enterprise SDK for Python` in the subject line.
242278

243279
If you are not covered under an existing maintenance/support agreement, you can find help through the broader community at [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
244280

245-
- Splunk will NOT provide support for SDKs if the core library (the code in the `/splunklib` directory) has been modified. If you modify an SDK and want support, you can find help through the broader community and [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
246-
247-
We would also like to know why you modified the core library, so please send feedback to [devinfo@splunk.com](mailto:devinfo@splunk.com).
248-
249-
- File any issues on [GitHub](https://github.com/splunk/splunk-sdk-python/issues).
250-
251-
### Contact us
281+
- Splunk will NOT provide support for SDKs if the core library (code in the `/splunklib` directory) has been modified. If you modify the SDK and want support, try finding it with the broader community, e.g. [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
252282

253-
You can reach the Splunk Developer Platform team at [devinfo@splunk.com](mailto:devinfo@splunk.com).
283+
That said, we'd also like to know why you felt the need to modify the core library, so please send feedback and file any issues in our [GitHub Issues](https://github.com/splunk/splunk-sdk-python/issues).

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ html:
1111
sphinx-build -b html -d $(BUILDDIR)/doctrees . $(HTMLDIR)
1212
sh munge_links.sh $(HTMLDIR)
1313
@echo "[splunk-sdk] ---"
14-
@echo "[splunk-sdk] Build finished. HTML pages available at docs/$(HTMLDIR)."
14+
@echo "[splunk-sdk] Build finished. HTML pages available at docs/$(HTMLDIR)."

sitecustomize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
import coverage
1919

2020
coverage.process_startup()
21-
except:
21+
except: # noqa: E722
2222
pass

0 commit comments

Comments
 (0)