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
66 changes: 57 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
CONTAINER_NAME := "splunk"
### Conveniences for splunk-sdk-python development

## VIRTUALENV MANAGEMENT

# https://docs.astral.sh/uv/reference/cli/#uv-run--upgrade
# --no-config skips Splunk's internal PyPI mirror
UV_SYNC_CMD := uv sync --no-config

.PHONY: uv-sync
uv-sync:
$(UV_SYNC_CMD) --dev

.PHONY: uv-upgrade
uv-upgrade:
$(UV_SYNC_CMD) --dev --upgrade


# Workaround for make being unable to pass arguments to underlying cmd
# $ SDK_DEPS_GROUP="build" make uv-sync-ci
.PHONY: uv-sync-ci
uv-sync-ci:
uv sync --locked --group $(SDK_DEPS_GROUP)

.PHONY: clean
clean:
rm -rf ./build ./dist ./.venv ./.ruff_cache ./.pytest_cache ./splunk_sdk.egg-info ./__pycache__ ./**/__pycache__

.PHONY: docs
docs:
@make -C ./docs html
make -C ./docs html

## TESTING

# --ff lets previously failing tests go first
# -ra prints a report on all failed tests after a run
# -vv shows why a test failed while the rest of the suite is running
PYTHON_CMD := uv run python
PYTEST_CMD := $(PYTHON_CMD) -m pytest --no-header --ff -ra -vv

.PHONY: test
test:
@python -m pytest ./tests
$(PYTEST_CMD) ./tests

.PHONY: test-unit
test-unit:
@python -m pytest ./tests/unit
$(PYTEST_CMD) ./tests/unit

.PHONY: test-integration
test-integration:
@python -m pytest ./tests/integration ./tests/system
$(PYTEST_CMD) --ff ./tests/integration ./tests/system

## DOCKER

CONTAINER_NAME := splunk
SPLUNK_HOME := /opt/splunk

.PHONY: docker-up
docker-up:
@docker-compose up -d
# For podman (at least on macOS) you might need to add DOCKER_BUILDKIT=0
# --build forces Docker to build a new image instead of using an existing one
@docker-compose up -d --build

.PHONY: docker-ensure-up
docker-ensure-up:
Expand All @@ -35,14 +75,22 @@ docker-start: docker-up docker-ensure-up

.PHONY: docker-down
docker-down:
@docker-compose stop
docker-compose stop

.PHONY: docker-restart
docker-restart: docker-down docker-start

.PHONY: docker-remove
docker-remove:
@docker-compose rm -f -s
docker-compose rm -f -s

.PHONY: docker-refresh
docker-refresh: docker-remove docker-start
docker-refresh: docker-remove docker-start

.PHONY: docker-splunk-restart
docker-splunk-restart:
docker exec -it $(CONTAINER_NAME) sudo sh -c '$(SPLUNK_HOME)/bin/splunk restart --run-as-root'

.PHONY: docker-tail-python-log
docker-tail-python-log:
docker exec -it $(CONTAINER_NAME) sudo tail $(SPLUNK_HOME)/var/log/splunk/python.log
14 changes: 5 additions & 9 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
# Makefile for Sphinx docs generation
#

SPHINXBUILD = sphinx-build
BUILDDIR = ./_build
HTMLDIR = ${BUILDDIR}/html

# Internal variables
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees .

.PHONY: html
html:
@rm -rf $(BUILDDIR)
@$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(HTMLDIR)
@sh munge_links.sh $(HTMLDIR)
@echo
@echo "Build finished. HTML pages available at docs/$(HTMLDIR)."
rm -rf $(BUILDDIR)
sphinx-build -b html -d $(BUILDDIR)/doctrees . $(HTMLDIR)
sh munge_links.sh $(HTMLDIR)
@echo "[splunk-sdk] ---"
@echo "[splunk-sdk] Build finished. HTML pages available at docs/$(HTMLDIR)."
50 changes: 35 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ name = "splunk-sdk"
dynamic = ["version"]
description = "Splunk Software Development Kit for Python"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
license = { text = "Apache-2.0" }
authors = [{ name = "Splunk, Inc.", email = "devinfo@splunk.com" }]
keywords = ["splunk", "sdk"]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.13",
"Development Status :: 6 - Mature",
Expand All @@ -29,25 +28,27 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Application Frameworks",
]

dependencies = ["python-dotenv>=0.21.1"]
optional-dependencies = { compat = ["six>=1.17.0"] }
dependencies = []

# https://github.com/astral-sh/uv/issues/8981#issuecomment-2466787211
# Treat the same as NPM's `dependencies`
[project.optional-dependencies]
compat = ["six>=1.17.0"]

# Treat the same as NPM's `devDependencies`
[dependency-groups]
build = ["build>=1.1.1", "twine>=4.0.2"]
# Can't pin `sphinx` otherwise installation fails on python>=3.7
docs = ["sphinx", "jinja2>=3.1.6"]
lint = ["mypy>=1.4.1", "ruff>=0.13.1"]
test = ["pytest>=7.4.4", "pytest-cov>=4.1.0"]
release = [{ include-group = "build" }, { include-group = "docs" }]
test = ["pytest>=8.4.2", "pytest-cov>=7.1.0", "python-dotenv>=1.2.1"]
release = ["build>=1.4.2", "jinja2>=3.1.6", "sphinx>=7.4.7", "twine>=6.2.0"]
lint = ["basedpyright>=1.38.4", "ruff>=0.15.8"]
dev = [
{ include-group = "test" },
{ include-group = "lint" },
{ include-group = "build" },
{ include-group = "docs" },
{ include-group = "release" },
]

[build-system]
requires = ["setuptools"]
# setuptools v61 introduces pyproject.toml support
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
Expand All @@ -56,13 +57,32 @@ packages = ["splunklib", "splunklib.modularinput", "splunklib.searchcommands"]
[tool.setuptools.dynamic]
version = { attr = "splunklib.__version__" }

[tool.basedpyright]
exclude = [".venv"]
allowedUntypedLibraries = ["splunklib"]
reportAny = false
reportExplicitAny = false
reportMissingTypeStubs = false
reportUnknownMemberType = false
reportUnusedCallResult = false

# https://docs.astral.sh/ruff/configuration/
[tool.ruff.lint]
fixable = ["ALL"]
select = [
"F", # pyflakes
"ANN", # flake-8-annotations
"C4", # comprehensions
"DOC", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"ANN", # flake8 type annotations
"PT", # flake-8-pytest-rules
"RUF", # ruff-specific rules
"UP", # pyupgrade
]
ignore = [
"E501", # line-length
]

[tool.ruff.lint.isort]
combine-as-imports = true
Loading