This repo is a simple example of using Artifact Registry to store Python Packages. The official docs can be foundhere
Set the project environment variable
export PROJECT_ID=your-project-id
Config gcloud to use this by default
gcloud config set project $PROJECT_ID
This will be used to push the python packages to AR
pip install twine
Create the AR instance to store the Python Pacakages
gcloud artifacts repositories create python \
--repository-format=python \
--location=northamerica-northeast1 \
--description="Python packages for in Artifact Registry"
Set the AR in your gcloud configs
gcloud config set artifacts/repository python
Install keyring to store the credentials for PIP twine to authenticate with against the AR instance.
pip install keyring
pip install keyrings.google-artifactregistry-auth
gcloud auth application-default login
Create a dir to store the packages in
mkdir pip-packages
mkdir pip-packages/dist
cd pip-packages
cat the packages list into a requirements.txt file so we can tell pip to download them.
cat <<EOF > requirements.txt
flask
requests
waitress
google-auth
google-cloud-storage
marshmallow
google-cloud-asset
protobuf
google-cloud-logging
google-cloud-securitycenter
EOF
pip download -r requirements.txt -d dist
python3 -m twine upload --repository-url https://northamerica-northeast1-python.pkg.dev/${PROJECT_ID}/python/ dist/*
Follow the instructions printed by this command to update your .pypirc and pip.conf files.
gcloud artifacts print-settings python --project=${PROJECT_ID} \
--repository=python \
--location=northamerica-northeast1
You can now use pip to install the packages
pip install -r requirements.txt