Appearance
Using Astral UV with RepoForge
Astral's UV is a fast Python packaging tool that works well with RepoForge for managing private packages. This guide explains how to publish packages to RepoForge with UV and how to install packages stored in RepoForge, including the authentication options that UV supports. Follow these search-friendly steps to share and consume private Python wheels quickly.
Prerequisites
- A RepoForge repository URL copied from the dashboard (for example,
https://api.repoforge.io/<unique_hash_id>/
). Open Python and select Show me how to publish packages to copy the full URL for your repository. - A RepoForge access token with Python - Full access permissions or a RepoForge username and password
- UV installed locally (v0.2.0 or later)
Publish Python Packages to RepoForge with Astral UV
Follow these steps to build your project and upload it to RepoForge.
Collect your RepoForge URL and token. Copy the full repository URL from the RepoForge dashboard (select Python and choose Show me how to publish packages) and make a note of it for later steps. Generate an access token with Python - Full access permissions. To reuse the token without retyping it, export it as an environment variable:
bashexport REPOFORGE_TOKEN="<repoforge_access_token>"
Replace the placeholder with your actual access token and store it securely—avoid committing it to version control or sharing it in shell history.
Create a sample UV project. If you do not already have a project, scaffold a basic package that prints "Hello, RepoForge!" when executed. This makes it easy to verify that publishing and installation both work.
bashuv init --package hello-repoforge cd hello-repoforge
The
uv init --package
command scaffolds apyproject.toml
file and a package insidehello_repoforge/
. Replace the default module content with a simple entry point:python# hello_repoforge/main.py def main() -> None: print("Hello, RepoForge!") if __name__ == "__main__": main()
Configure the RepoForge index. Append a custom UV index configuration to
pyproject.toml
so the publish command knows how to reach your private repository. Replace the example URL with the exact RepoForge URL you copied earlier and keep the trailing slash in place.toml# pyproject.toml [[tool.uv.index]] name = "repoforge" url = "https://api.repoforge.io/<unique_hash_id>/" publish-url = "https://api.repoforge.io/<unique_hash_id>/" authenticate = "always"
Be sure to paste the exact repository URL you copied earlier, including the trailing slash. If you embed a token in the URL for automated installs, update both
url
andpublish-url
.Build your project artifacts. UV can produce source distributions and wheels directly. Run this command from the project root:
bashuv build
Publish the distribution to RepoForge. Run the publish command against the named RepoForge index you just defined.
bashuv publish --index repoforge
UV prompts you for credentials when it connects to RepoForge, so enter
__token__
as the username and then supply your access token when asked.textPublishing 2 files to https://api.repoforge.io/<unique_hash_id>/ Enter username ('__token__' if using a token): __token__ Enter password:
To publish without an interactive prompt, pass the token on the command line:
bashuv publish --index repoforge --token ${REPOFORGE_TOKEN}
Install RepoForge Packages with Astral UV
Once your packages are available in RepoForge, install them in other environments using UV.
Start from a clean project. Initialize a fresh project for consuming the package so the publishing and installation environments stay separate.
bashuv init hello-repoforge-consumer cd hello-repoforge-consumer
Configure the RepoForge index. Open the generated
pyproject.toml
and append the RepoForge index block. Replace the placeholder with your repository's actual URL, including the trailing slash.toml# pyproject.toml [[tool.uv.index]] name = "repoforge" url = "https://api.repoforge.io/<unique_hash_id>/" publish-url = "https://api.repoforge.io/<unique_hash_id>/" authenticate = "always"
Set authentication environment variables. Provide your credentials through the environment so UV can reuse them without prompting.
bashexport UV_INDEX_REPOFORGE_USERNAME=__token__ export UV_INDEX_REPOFORGE_PASSWORD=<repoforge_access_token>
Install the package from RepoForge. Use either
uv add
to record the dependency inpyproject.toml
oruv pip install
to install directly into the environment.bashuv add hello-repoforge
bashuv pip install hello-repoforge
With these steps you can publish and install packages using UV while keeping your RepoForge credentials secure. For more background on authentication, see Authentication and Permissions.