dbx-patch
Patchception: A library to patch the Databricks patching of Python to enable editable package installs.
Features
- ✅ Enables editable Python package installs (
pip install -e .) in Databricks notebooks - ✅ Patches Databricks' custom import system to allow workspace directory imports
- ✅ Automatic patch application via
sitecustomize.py(recommended) - ✅ Manual patching via
patch_dbx()for immediate use - ✅ Debug mode with
DBX_PATCH_DEBUGenvironment variable for troubleshooting
Installation
With pip:
python -m pip install dbx-patch
With uv:
uv add dbx-patch
Quick Start
🚀 Recommended: One-Command Setup
The simplest way to get started - patches current session AND installs automatic patching:
from dbx_patch import patch_and_install
patch_and_install()
# Patches applied + sitecustomize.py installed
# Python will restart automatically in Databricks!
⚡ Manual Patching (Current Session Only)
If you only want to patch the current Python session without persistence:
from dbx_patch import patch_dbx
patch_dbx()
# Editable installs now work in this session!
🔧 Automatic Patching (Persistent)
For permanent solution that works across all Python restarts:
# Run ONCE per cluster (e.g., in init script or setup notebook)
from dbx_patch import install_sitecustomize
install_sitecustomize()
# Python will restart automatically in Databricks!
# After restart, patches are applied automatically on every Python startup
sys_path_init.pyruns during Python interpreter initialization- Your notebook code runs after initialization completes
- By the time you call
patch_dbx(), the import system is already configured - Editable install paths have already been removed from
sys.path - Import hooks are already installed and active
The Solution: sitecustomize.py
Python automatically imports sitecustomize.py during interpreter initialization, before any Databricks code runs:
- Python interpreter starts
sitecustomize.pyruns → ✅ Patches are applied early- Databricks code tries to run → ✅ Already patched!
- Your notebook code runs → ✅ Editable installs work!
# ✅ This WORKS - patches applied at startup
from dbx_patch import install_sitecustomize
install_sitecustomize() # Installs sitecustomize.py + auto-restarts Python
Implementation details:
sitecustomize.pypatchessys_path_initbefore it runs- Import hooks are modified before they're installed
- Editable install paths are preserved in
sys.path - All patches are applied silently during startup
For detailed technical explanation, see Technical Implementation
Docs
uv run mkdocs build -f ./mkdocs.yml -d ./_build/
Update template
copier update --trust -A --vcs-ref=HEAD
Credits
Metadata
Release files for dbx-patch 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dbx_patch-0.1.0.tar.gz | 26.1 kB | Without provenance | Details for dbx_patch-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dbx_patch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dbx_patch-0.1.0-py3-none-any.whl |
Total release size: 59.1 kB
Release files / dbx_patch-0.1.0.tar.gz
| Download URL | dbx_patch-0.1.0.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff3119867d3d3498fadd01cd9c83f97cfcaefd8076e41a5dc0fdb52266c76151
|
|
BLAKE2b-256 checksum How to use checksums |
672bcc8f6b85a710b2ca36f2d6a89d54c65696d2dbaa6d237b66c052078e22f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dbx_patch-0.1.0-py3-none-any.whl
| Download URL | dbx_patch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0130fc1e442112dc838dd82aaa5a101a8d3e5622926bea7d793ae768a97a71b6
|
|
BLAKE2b-256 checksum How to use checksums |
b1951b383168cb2ce76fc6bcfc7f52c8ca31d8d66ae063df0a0dc88df771b5a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for dbx-patch 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.