Skip to content

Commit 83a921f

Browse files
authored
[Internal] Make databricks-sdk-py compliant with PEP 621 and PEP 625 (#895)
## What changes are proposed in this pull request? We've received messages from PyPI that the current SDK library is not compliant with PEP 625. With help from the administrators at PyPI, I've converted our `setup.py` to a `pyproject.toml` and, with help from the setuptools `build` frontend, we can produce PEP 625-compliant artifacts. Additionally, we can run `check-manifest` to verify that our source distribution and wheel contain the same set of files. I noticed in particular that all of our examples and docs are included in both our wheel and sdist, polluting customer's python environments with unnecessary packages. ## How is this tested? Ran `python -m build` and saw that the desired build artifacts were produced. The `check-manifest` job should be passing. Tested uploading the resulting artifact to Test PyPI: https://github.com/databricks/databricks-sdk-py/actions/runs/13438801138/job/37547674236 NO_CHANGELOG=true
1 parent 998a117 commit 83a921f

File tree

8 files changed

+132
-51
lines changed

8 files changed

+132
-51
lines changed

.github/workflows/push.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,19 @@ jobs:
3939

4040
- name: Fail on differences
4141
run: git diff --exit-code
42+
43+
check-manifest:
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v2
49+
50+
- uses: actions/setup-python@v4
51+
with:
52+
python-version: 3.13
53+
54+
- name: Check MANIFEST.in
55+
run: |
56+
pip install check-manifest
57+
check-manifest .

.github/workflows/release-test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919

20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.13
23+
24+
- name: Install build
25+
run: pip install build
26+
2027
- name: Build wheel
21-
run: make dev install dist
28+
run: python -m build
2229
env:
2330
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2431

.github/workflows/release.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v3
2222

23+
- uses: actions/setup-python@v4
24+
with:
25+
python-version: 3.13
26+
27+
- name: Install build
28+
run: pip install build
29+
2330
- name: Build wheel
24-
run: make dev install dist
31+
run: python -m build
2532
env:
2633
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2734

@@ -30,8 +37,8 @@ jobs:
3037
with:
3138
draft: true
3239
files: |
33-
dist/databricks-*.whl
34-
dist/databricks-*.tar.gz
40+
dist/databricks_*.whl
41+
dist/databricks_*.tar.gz
3542
3643
- uses: pypa/gh-action-pypi-publish@release/v1
3744
name: Publish package distributions to PyPI

MANIFEST.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
include README.md
2+
include LICENSE
3+
include NOTICE
4+
include DCO
5+
include Makefile
6+
include SECURITY.md
7+
include CHANGELOG.md
8+
include CONTRIBUTING.md
9+
include pyproject.toml
10+
include databricks/sdk/py.typed
11+
12+
exclude .codegen.json
13+
exclude .readthedocs.yaml
14+
exclude docs-requirements.txt
15+
exclude NEXT_CHANGELOG.md
16+
exclude tagging.py
17+
exclude .package.json
18+
19+
recursive-exclude docs *
20+
recursive-exclude examples *
21+
recursive-exclude tests *
22+
recursive-exclude .codegen *
23+
recursive-exclude .vscode *

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,5 @@ benchmark:
3636
coverage: test
3737
open htmlcov/index.html
3838

39-
dist:
40-
python3 setup.py bdist_wheel sdist
41-
4239
clean:
4340
rm -fr dist *.egg-info .pytest_cache build htmlcov

pyproject.toml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "databricks-sdk"
7+
dynamic = ["version"]
8+
description = "Databricks SDK for Python (Beta)"
9+
readme = "README.md"
10+
requires-python = ">=3.7"
11+
keywords = ["databricks", "sdk"]
12+
classifiers = [
13+
"Development Status :: 4 - Beta",
14+
"Intended Audience :: Developers",
15+
"Intended Audience :: Science/Research",
16+
"Intended Audience :: System Administrators",
17+
"License :: OSI Approved :: Apache Software License",
18+
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
"Operating System :: OS Independent"
26+
]
27+
dependencies = [
28+
"requests>=2.28.1,<3",
29+
"google-auth~=2.0"
30+
]
31+
32+
[project.urls]
33+
Documentation = "https://databricks-sdk-py.readthedocs.io"
34+
35+
[project.optional-dependencies]
36+
dev = [
37+
"pytest",
38+
"pytest-cov",
39+
"pytest-xdist",
40+
"pytest-mock",
41+
"yapf",
42+
"pycodestyle",
43+
"autoflake",
44+
"isort",
45+
"wheel",
46+
"ipython",
47+
"ipywidgets",
48+
"requests-mock",
49+
"pyfakefs",
50+
"databricks-connect",
51+
"pytest-rerunfailures",
52+
"openai",
53+
'langchain-openai; python_version > "3.7"',
54+
"httpx",
55+
"build", # some integration tests depend on the databricks-sdk-py wheel
56+
]
57+
notebook = [
58+
"ipython>=8,<9",
59+
"ipywidgets>=8,<9"
60+
]
61+
openai = [
62+
"openai",
63+
'langchain-openai; python_version > "3.7"',
64+
"httpx"
65+
]
66+
67+
[tool.setuptools.dynamic]
68+
version = { attr = "databricks.sdk.version.__version__" }
69+
70+
[tool.setuptools.packages.find]
71+
include = ["databricks", "databricks.*"]
72+
73+
[tool.setuptools.package-data]
74+
"databricks.sdk" = ["py.typed"]

setup.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

tests/integration/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def fresh_wheel_file(tmp_path) -> Path:
2525
build_root = tmp_path / 'databricks-sdk-py'
2626
shutil.copytree(project_root, build_root)
2727
try:
28-
completed_process = subprocess.run([sys.executable, 'setup.py', 'bdist_wheel'],
28+
completed_process = subprocess.run([sys.executable, '-m', 'build'],
2929
capture_output=True,
3030
cwd=build_root)
3131
if completed_process.returncode != 0:

0 commit comments

Comments
 (0)