CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 1 · Lesson 1/45

    Building Python wheels as bundle artifacts

    Implement scalable Python project structures for Declarative Automation Bundles (formerly Databricks Asset Bundles / DABs) to support modular development and CI/CD integration.

    9 min read
    1.92% of exam
    2 sources
    Published 22 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Describe a bundle's Python package in pyproject.toml with a version and an entry point
    • Configure the artifacts mapping so that bundle deploy builds a wheel with uv or Poetry
    • Attach the built wheel to a job task through libraries and python_wheel_task, and know when the build step is skipped

    1.Packaging src code as a wheel

    A Declarative Automation Bundle deploys source code and resource definitions to a workspace together. When the code is a Python package under src/, the cleanest way to ship it is as a wheel. A wheel has a version and installs as a library, and every task that needs the package installs that same file. The default-python template from databricks bundle init is built this way: it builds the wheel with uv from the project's pyproject.toml.

    The [project] table of a bundle's pyproject.toml: name, version and runtime dependenciestoml
    [project]
    name = "test"
    version = "0.0.1"
    authors = [{ name = "someone@example.com" }]
    requires-python = ">=3.10,<3.13"
    dependencies = [
        # Any dependencies for jobs and pipelines in this project can be added here
        #
        # LIMITATION: for pipelines, dependencies are cached during development;
        # add dependencies to the 'environment' section of your pipeline.yml file instead
    
        "numpy==1.25.2"
    ]

    Three parts of this file matter once it is deployed. version goes into the wheel file name, so two builds can be told apart. dependencies are installed with the wheel. Further down the same file, [project.scripts] maps main = "test.main:main", which gives the package an entry point that a job can call by name. Development-only tools such as pytest, ruff and databricks-connect belong in a separate [dependency-groups] dev list, so they stay out of production installs. When an install fails or two libraries conflict, see dependency troubleshooting.

    uv is the recommended tool for this, but not the only one. With Poetry, the same metadata goes under [tool.poetry], with entry points in [tool.poetry.scripts]. With setuptools, a setup.py declares packages=find_packages(where='./src') and package_dir={'': 'src'}. In every case the package sits under src/my_package/ with an __init__.py, and build output such as dist and build is kept out of Git through .gitignore.

    Checkpoint 1 of 3· Fill the gap

    You rebuild the same package after a code change and want each build's wheel file to be distinguishable when deployed. Which key in this [project] table do you change?

    [project]
    name = "test"
     ?  = "0.0.1"
    authors = [{ name = "someone@example.com" }]
    requires-python = ">=3.10,<3.13"
    dependencies = [
        # Any dependencies for jobs and pipelines in this project can be added here
        #
        # LIMITATION: for pipelines, dependencies are cached during development;
        # add dependencies to the 'environment' section of your pipeline.yml file instead
    
        "numpy==1.25.2"
    ]

    Sources12

    2.The artifacts mapping builds the wheel at deploy time

    The artifacts top-level mapping tells the CLI what to build and how. Each named artifact has a type (for a wheel, whl), a build command, and optionally a path to the folder holding the build file. The schema also lists dynamic_version, executable and files keys. Since this mapping is top-level, every target inherits it unless a target overrides it.

    A uv-based wheel artifact in databricks.ymlyaml
    # databricks.yml
    ...
    artifacts:
      python_artifact:
        type: whl
        build: uv build --wheel
    ...

    The build runs as part of databricks bundle deploy, and there is no separate build command. Running databricks bundle deploy --target dev builds the wheel on the machine running the CLI and uploads it under the bundle's deployment folder, at .bundle/<project-name>/dev/artifacts/.internal/<whl-file-name>.whl in the deploying user's workspace folder. A CI runner that deploys therefore also builds, and each commit produces the wheel from the source checked out in that run.

    Leaving out artifacts is supported, and it is what you want when a separate pipeline step builds and signs wheels. The bundle then just ships the file. The risk runs the other way: if nothing builds the wheel and the whl glob matches nothing current, the deploy ships a stale file or none at all.

    Ways a bundle can get its wheel
    Approachartifacts configurationBuild file
    uv (template default)type: whl, build: uv build --wheelpyproject.toml
    Poetrytype: whl, build: poetry build, path: .pyproject.toml with [tool.poetry]
    Prebuilt wheelNo artifacts mapping; CLI deploys the libraries whl entriesNone at deploy time

    Checkpoint 2 of 3· Check yourself

    A CI runner checks out a commit and runs databricks bundle deploy -t prod. The databricks.yml has a top-level artifacts entry with type: whl and build: uv build --wheel, and the prod target does not mention artifacts. What happens to the wheel?

    Sources1

    3.Attaching the wheel to tasks

    A task gets the wheel through its libraries list, with one whl entry per wheel. The path can be relative to the bundle, which is how a locally built artifact is referenced, for example ./dist/*.whl. It can also point at workspace files, a Unity Catalog volume or cloud object storage. Use workspace files or volumes, not DBFS. Library files stored in the DBFS root can be modified by any workspace user, and that option is deprecated and disabled by default from Databricks Runtime 15.1.

    Three wheel sources on one task: local to the bundle, workspace files, and a UC volumeyaml
    resources:
      jobs:
        my_job:
          # ...
          tasks:
            - task_key: my_task
              # ...
              libraries:
                - whl: ./my-wheel-0.1.0.whl
                - whl: /Workspace/Shared/Libraries/my-wheel-0.0.1-py3-none-any.whl
                - whl: /Volumes/main/default/my-volume/my-wheel-0.1.0.whl

    To run code from the package, use a python_wheel_task that names the package_name (for example my_package) and an entry_point (for example main). The entry point must match a script declared in the build file, such as main = "my_package.main:main". After a deploy, the job's Tasks tab shows a single python_wheel_task. Clusters on Databricks Runtime 12.2 LTS or below also need a top-level experimental: python_wheel_wrapper: true mapping, which applies to every python_wheel_task in the bundle.

    Pipelines consume the same pyproject.toml in a different way. Instead of a whl library, the pipeline's environment.dependencies lists --editable ${workspace.file_path}, which points at the deployed project folder so that every declared dependency is installed. Choosing environments for serverless compute is covered in compute and environment configuration.

    Checkpoint 3 of 3· Check yourself

    A bundle's python_wheel_task jobs must also run on a cluster with Databricks Runtime 12.2 LTS. The wheel builds and uploads fine, but older runtimes need an extra setting to install it. What does the bundle need?

    Sources21

    Practise it for real

    Generate a wheel-based bundle, deploy it to dev, and confirm that the deploy step built and uploaded the wheel.

    1. 1.Run databricks bundle init, keep the default-python template, answer yes to the stub Python package and to serverless, and give an existing Unity Catalog catalog.

      Why: The template produces the src/, resources/, tests/ and pyproject.toml layout together with a wheel artifact definition.

      You should see: A my_project folder containing databricks.yml, resources/sample_job.job.yml, src/ and tests/.

    2. 2.Open databricks.yml and find the artifacts mapping and the include list.

      Why: These two mappings are what build the wheel and pull in the job definition.

      You should see: A whl-type artifact and an include entry that covers the resources folder.

    3. 3.From the bundle root, run databricks bundle validate.

      Why: Validation catches configuration errors before anything is built or uploaded.

      You should see: A summary of the bundle configuration and no errors.

    4. 4.Run databricks bundle deploy --target dev.

      Why: Deploy runs the artifact build and uploads the result.

      You should see: A .whl file under .bundle/<project-name>/dev/artifacts/.internal/ in your workspace user folder, and a job named [dev <your-username>] sample_job.

    5. 5.Run databricks bundle run --target dev sample_job and open the printed Run URL.

      Why: This shows that the task installs the deployed wheel and calls its entry point.

      You should see: A single python_wheel_task that completes successfully.

    Stuck? Get a nudge

    If the job is missing after deploy, check that its YAML file is matched by a glob in the include list.

    Sources

    (2)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “a bundle is created that shows how to configure a bundle that builds a Python wheel using uv and pyproject.toml”
      ↩︎ Packaging src code as a wheel
      “Next, deploy the bundle to your remote Databricks workspace. This builds the Python wheel file.”
      ↩︎ The artifacts mapping builds the wheel at deploy time
      “dev > artifacts > .internal > <whl-file-name>.whl”
      ↩︎ The artifacts mapping builds the wheel at deploy time
      “This configuration runs the poetry build command”
      ↩︎ The artifacts mapping builds the wheel at deploy time
      “on a cluster with Databricks Runtime 12.2 LTS or below, you must add the following top-level mapping”
      ↩︎ Attaching the wheel to tasks
      “The Databricks CLI will then assume that the Python wheel file is already built”
      ↩︎ Exam trap 1
      “The Databricks CLI will then assume that the Python wheel file is already built”
      ↩︎ Prediction
      “on a cluster with Databricks Runtime 12.2 LTS or below, you must add the following top-level mapping to the databricks.yml file”
      ↩︎ Checkpoint
    2. 2.
      “uv is the recommended method for managing Python library dependencies.”
      ↩︎ Packaging src code as a wheel
      “To add a Python wheel file to a job task, in libraries specify a whl mapping for each library to be installed.”
      ↩︎ Attaching the wheel to tasks
      “adding an editable environment that points to the folder where pyproject.toml is deployed”
      ↩︎ Attaching the wheel to tasks
      “storing library files in the DBFS root is deprecated and disabled by default in Databricks Runtime 15.1 and above.”
      ↩︎ Exam trap 2

    Spotted a mistake, or was something unclear? Tell us.