Skip to content
Edit this page View source of this page

Initialize your Python project

The template starts with development tools and configuration. It has no Python source code or pyproject.toml. After setting up your environment, choose a layout and run the commands for that option from your repository root.

Start with one application

For a small app you want to run directly from its source folder, create a minimal project with --no-package.

uv init --no-package
uv run main.py

This creates pyproject.toml and a starter main.py, with no build system. Plain uv init also creates an application, using the defaults of your installed uv version.

For an installable app or command-line tool, initialize it with --package.

uv init --package

uv sets up a src/ layout and a build system. Look under [project.scripts] in pyproject.toml for the generated command name. For example, if the entry is named my-app, run uv run my-app.

Create an importable library

Use --lib when your project's main purpose is to provide Python code that other projects can import.

uv init --lib
uv sync

Put your public functions and classes in the generated package under src/. If you plan to distribute it, read the uv publishing guide.

Start with one standalone script

For a single file with its own Python requirement and dependencies, initialize it in script mode.

uv init --script task.py
uv run task.py

uv records script metadata inside the file. See Running scripts for adding dependencies to the script.

Use a workspace for multiple packages

A uv workspace lets an app and one or more libraries in the same repository share a lockfile. Start in a fresh template checkout so you can create a minimal root project and initialize the members beneath it.

uv init --bare
uv init --package packages/demo-app
uv init --lib packages/demo-lib
uv sync --all-packages
uv run --package demo-app demo-app

uv adds the member paths to [tool.uv.workspace] in the root pyproject.toml. Each member has its own pyproject.toml. If demo-app uses demo-lib, run uv add --package demo-app ./packages/demo-lib from the workspace root. uv records the dependency and marks it as a workspace source in packages/demo-app/pyproject.toml. See Using workspaces for when separate projects are a better fit.

Before your first pull request

Check the project name and requires-python in the generated metadata. If uv generated a .python-version file, make sure it agrees with the version your team wants to develop against. Commit the project files and, for a project with a pyproject.toml, generate and commit uv.lock with uv sync. Then make the project yours by updating the inherited names, links, and contact details.

See Creating projects for other layouts and build backends. Once you've initialized your project, run the repository checks and add tests when you have behavior to verify.