Skip to main content

CLI for creating a Python Package Repository in a GCS bucket

Project description

Python package

gcs_pypi is a CLI for creating a Python Package Repository in an GCS bucket.

Getting started

Installation

Install gcs_pypi using pip:

pip install gcs_pypi

Usage

GCS Bucket

  • Create a new bucket

IAM (Role & Service Account)

Setup service account with the following permissions

storage.buckets.get
storage.buckets.getIamPolicy
storage.buckets.update
storage.objects.create
storage.objects.delete
storage.objects.get
storage.objects.getIamPolicy
storage.objects.list
storage.objects.setIamPolicy

Recommended that you create a custom Role which can be inherited by the service account

Example

  • Create Role “PYPI”

  • Assign Permissions

storage.buckets.get
storage.buckets.getIamPolicy
storage.buckets.update
storage.objects.create
storage.objects.delete
storage.objects.get
storage.objects.getIamPolicy
storage.objects.list
storage.objects.setIamPolicy
  • Create a Service Account e.g pypi

  • Select the “PYPI” Role created above

  • Add a condition to limit access to only that GCS bucket

resource.name == "mybucket"

Visit Cloud IAM Conditions for more information

Distributing packages

You can now use gcspypi to create Python packages and upload them to your GCS bucket. To hide packages from the public, you can use the --private option to prevent the packages from being accessible directly via the GCS bucket (they will only be accessible via your Domain or alternatively you can specify a secret subdirectory using the --secret option:

cd /path/to/your-project/
gcspypi --bucket mybucket [--private] [--secret SECRET]

Cache Header

Set cache-control header for index.html

$ gsutil setmeta -h "cache-control:public, must-revalidate, proxy-revalidate, max-age=0" gs://[BUCKET]/index.html

Installing packages

Install your packages using pip by pointing the --extra-index-url to your Custom domain (optionally followed by a secret subdirectory):

pip install your-project --extra-index-url https://pypi.example.com/SECRET/

Alternatively, you can configure the index URL in ~/.pip/pip.conf:

[global]
extra-index-url = https://pypi.example.com/SECRET/

Credits

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcs_pypi-0.1.34.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

gcs_pypi-0.1.34-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file gcs_pypi-0.1.34.tar.gz.

File metadata

  • Download URL: gcs_pypi-0.1.34.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for gcs_pypi-0.1.34.tar.gz
Algorithm Hash digest
SHA256 8a2fdf00e74fee2d55bf7f3c889ed05ecdae5539d878e41ab4dbbf90b5ad034a
MD5 0c376a9a6bf043ad2ed6255bfc9762ba
BLAKE2b-256 b3a279121a4d3456b32ebdbc5236289da28d31b1a9b8b8210a936b1f1867dba9

See more details on using hashes here.

File details

Details for the file gcs_pypi-0.1.34-py3-none-any.whl.

File metadata

  • Download URL: gcs_pypi-0.1.34-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for gcs_pypi-0.1.34-py3-none-any.whl
Algorithm Hash digest
SHA256 5acd00677d0708d49f8a3cfc8ec58ece74b1e0fd5f8eceef09c8f2b8d64dc570
MD5 5d62156d5f447d98a8e240a9476af2f0
BLAKE2b-256 b8da4febc71bc766fcbd7d82620cd1f8f519e2d7cc77175f1b84010fb02a0f87

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page