Skip to content

Publish an Artifact to jax-cs-registry

Python

Here is a generic GCP tutorial how to publish an python package to jax-cs-registry artifact registry. The GCP tutorial uses GCP Cloud Shell, and the commands run inside the Cloud Shell with all the permission in place. However, when we build the package on our local machine, it is not easy to upload them directly from our local machines, due to permission. The work around is to build locally, and transfer the artifacts to Cloud Shell, and push to the registry from Cloud Shell.

Build Artifact

Build and generate the .whl and .gz files into the dist directory.

for python project

python -m pip install --upgrade build
python -m build

for poetry project

poetry build
The build output should be in dist folder

Copy the Artifact into a Bucket

Copy the artifact into a bucket first, and then from bucket copy them to the Cloud Shell.

copy the artifact to a bucket

gsutil -m cp -r dist gs://jax-cube-prd-ctrl-01-project-test

Open Cloud Shell

Launch the Cloud Shell in the GCP console cloud_shell.png

Copy the Artifact into Cloud Shell

In Cloud Shell, run

gsutil -m cp -r gs://jax-cube-prd-ctrl-01-project-test/dist .
cloud_shell_copy.png

Upload the Artifacts

The jax-cs-registry has three python reporistoires:

Beware which repository to upload, and each repository has a different upload url

Upload to python repository:

if twine is not installed, install it

pip install twine

to upload

python -m twine upload --repository-url https://us-python.pkg.dev/jax-cs-registry/python/ dist/*

Attention

The location for this repository us (multiple regions in United States) is different from other twos us-east1 (South Carolina)

cloud_shell_upload.png

Upload to python-dev repository:

python -m twine upload --repository-url https://us-east1-python.pkg.dev/jax-cs-registry/python-dev/ dist/*

Upload to python-test repository:

python -m twine upload --repository-url https://us-east1-python.pkg.dev/jax-cs-registry/python-test/ dist/*

Check the Artifact

cloud_shell_check.png