pypi-publisher
Generic Dagger functions for publishing Python distributions to PyPI.
Installation
dagger install github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618Entrypoint
Return Type
PypiPublisher ! Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
func (m *MyModule) Example() *dagger.PypiPublisher {
return dag.
Pypipublisher()
}@function
def example() -> dagger.PypiPublisher:
return (
dag.pypi_publisher()
)@func()
example(): PypiPublisher {
return dag
.pypiPublisher()
}Types
PypiPublisher 🔗
Build Python distributions with uv and upload them to a PyPI index.
build() 🔗
Build a wheel and source distribution and return them as a directory.
The project is supplied explicitly instead of being read from the module’s working directory. This lets the module publish any Python project, locally or from another Dagger pipeline.
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Project directory containing pyproject.toml |
| pythonVersion | String ! | "3.13" | Python image tag used to build the distribution |
Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
build --source DIR_PATH --python-version stringfunc (m *MyModule) Example(source *dagger.Directory, pythonVersion string) *dagger.Directory {
return dag.
Pypipublisher().
Build(source, pythonVersion)
}@function
def example(source: dagger.Directory, pythonversion: str) -> dagger.Directory:
return (
dag.pypi_publisher()
.build(source, pythonversion)
)@func()
example(source: Directory, pythonVersion: string): Directory {
return dag
.pypiPublisher()
.build(source, pythonVersion)
}publish() 🔗
Build the project and upload its wheel and sdist to a PyPI index.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Project directory containing pyproject.toml |
| pypiToken | Secret ! | - | PyPI API token |
| repositoryUrl | String ! | "https://upload.pypi.org/legacy/" | Upload endpoint, for example TestPyPI’s legacy endpoint |
| pythonVersion | String ! | "3.13" | Python image tag used to build the distribution |
Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
publish --source DIR_PATH --pypi-token env:MYSECRET --repository-url string --python-version stringfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory, pypiToken *dagger.Secret, repositoryUrl string, pythonVersion string) string {
return dag.
Pypipublisher().
Publish(ctx, source, pypiToken, repositoryUrl, pythonVersion)
}@function
async def example(source: dagger.Directory, pypitoken: dagger.Secret, repositoryurl: str, pythonversion: str) -> str:
return await (
dag.pypi_publisher()
.publish(source, pypitoken, repositoryurl, pythonversion)
)@func()
async example(source: Directory, pypiToken: Secret, repositoryUrl: string, pythonVersion: string): Promise<string> {
return dag
.pypiPublisher()
.publish(source, pypiToken, repositoryUrl, pythonVersion)
}publishArtifacts() 🔗
Upload already-built artifacts to a PyPI-compatible index.
pypi_token remains a Dagger Secret throughout the call and is not
written to the artifact directory or included in command output.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| artifacts | Directory ! | - | Directory containing only wheel and source-distribution artifacts |
| pypiToken | Secret ! | - | PyPI API token |
| repositoryUrl | String ! | "https://upload.pypi.org/legacy/" | Upload endpoint, for example TestPyPI’s legacy endpoint |
Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
publish-artifacts --artifacts DIR_PATH --pypi-token env:MYSECRET --repository-url stringfunc (m *MyModule) Example(ctx context.Context, artifacts *dagger.Directory, pypiToken *dagger.Secret, repositoryUrl string) string {
return dag.
Pypipublisher().
Publishartifacts(ctx, artifacts, pypiToken, repositoryUrl)
}@function
async def example(artifacts: dagger.Directory, pypitoken: dagger.Secret, repositoryurl: str) -> str:
return await (
dag.pypi_publisher()
.publishartifacts(artifacts, pypitoken, repositoryurl)
)@func()
async example(artifacts: Directory, pypiToken: Secret, repositoryUrl: string): Promise<string> {
return dag
.pypiPublisher()
.publishArtifacts(artifacts, pypiToken, repositoryUrl)
}