The process for setting up PyPI with a Poetry client is done in 3 stages:
Configure the Poetry Client
In the command line, configure the upload endpoint for your publishable repository with the following commands:
poetry config repositories.artifactory-<REPOSITORY_NAME> https://<YOUR_JFROG_DOMAIN>/artifactory/api/pypi/<REPOSITORY_KEY> poetry config http-basic.artifactory-<REPOSITORY_NAME> <USER> <PASSWORD/TOKEN>
For example:
poetry config repositories.artifactory-pypi-local https://my-awesome.jfrog.io/artifactory/api/pypi/pypi-local poetry config http-basic.artifactory-pypi-local johnfrog RANDOM_TOKEN_YWRtaW46QVBBVWJjTExkZTU4WT
Add the repository source with the source add command as follows:
poetry config http-basic.<REPOSITORY_NAME> <USER><PASSWORD/TOKEN> poetry source add <REPOSITORY_NAME> https://<YOUR_JFROG_DOMAIN>/artifactory/api/pypi/<REPOSITORY_NAME>/simple
For example:
poetry config http-basic.pypi-local johnfrog RANDOM_TOKEN_YWRtaW46QVBBVWJjTExkZTU4WT poetry source add pypi-local https://my-awesome.jfrog.io/artifactory/api/pypi/pypi-local/simple
Note
The
source add
command inserts the URL into the project'spyproject.toml
.
Publish a Python Package to Artifactory
To publish a Python package to Artifactory, run the following command:
poetry publish --repository artifactory-<REPOSITORY_NAME> --dist-dir dist
For example:
poetry publish --repository artifactory-pypi-local --dist-dir dist
Install a Python Package
To install a Python package, run the following command:
poetry add --source <REPOSITORY_NAME> <PACKAGE_NAME>
For example:
poetry add --source pypi-local my_pypi_package