Skip to content

Commit

Permalink
Add a guide for publishing packages
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Aug 5, 2024
1 parent ce30bff commit b229088
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/guides/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ See the documentation on [running commands](../concepts/projects.md#running-comm
To learn more about working on projects with uv, see the [Projects concept](../concepts/projects.md)
page and the [command reference](../reference/cli.md#uv).

Or, read on to learn how to [run and install tools](./tools.md) with uv.
Or, read on to learn how to [publish your project as a package](./publish.md).
42 changes: 42 additions & 0 deletions docs/guides/publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Publishing a package

uv does not yet have dedicated commands for building and publishing a package. Instead, you can use
the PyPA tools [`build`](https://github.com/pypa/build) and
[`twine`](https://github.com/pypa/twine).

## Building your package

Build your package with official `build` frontend:

```console
$ uvx --from build pyproject-build
```

The build artifacts will be placed in `dist/`.

## Publishing your package

Publish your package with `twine`:

```console
$ uvx twine upload dist/*
```

!!! tip

To provide credentials, use the `TWINE_USERNAME` and `TWINE_PASSWORD` environment variables.

## Installing your package

Test that the package can be installed and imported with `uv run`:

```console
$ uv run --with <PACKAGE> --no-project -- python -c "import <PACKAGE>"
```

The `--no-project` flag is used to avoid installing the package from your local project directory.

!!! tip

If you have recently installed the package, you may need to include the
`--refresh-package <PACKAGE>` option to avoid using a cached version of the package.
2 changes: 1 addition & 1 deletion docs/guides/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ for more details on requesting Python versions.

To learn more about `uv run`, see the [command reference](../reference/cli.md#uv-run).

Or, read on to learn how to to [work on projects](./projects.md).
Or, read on to learn how to [run and install tools](./tools.md) with uv.
2 changes: 2 additions & 0 deletions docs/guides/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ $ uv tool install mkdocs --with mkdocs-material

To learn more about managing tools with uv, see the [Tools concept](../concepts/projects.md) page
and the [command reference](../reference/cli.md#uv-tool).

Or, read on to learn how to to [work on projects](./projects.md).
3 changes: 2 additions & 1 deletion mkdocs.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ nav:
- guides/index.md
- Installing Python: guides/install-python.md
- Running scripts: guides/scripts.md
- Working on projects: guides/projects.md
- Using tools: guides/tools.md
- Working on projects: guides/projects.md
- Publishing packages: guides/publish.md
- Concepts:
- concepts/index.md
- Projects: concepts/projects.md
Expand Down

0 comments on commit b229088

Please sign in to comment.