Utility functions for Google Cloud Storage
Project description
Google Cloud Storage (GCS) Utilities
This project provides a few simple utility functions for interacting with GCS.
Authentication
To function properly, this code needs credentials that it can use to authenticate against the Google Cloud Storage API. Credentials can be provided in one of two ways, and the code will look for them in this order:
- Service Account Key.
Before running this code, create an environment variable named SERVICE_ACCOUNT_KEY
containing the JSON key for a Google Cloud service account with the necessary permissions to perform the actions you're trying to perform in GCS.
- Personal Credentials.
Before running this code, authenticate with the Google Cloud Storage API using the gcloud
command line tool:
$ gcloud auth application-default login --project GCP_PROJECT_NAME
Development
This project uses Pipenv to manage virtual environments and dependencies. Development-time dependencies are documented in the Pipfile
. Follow the Pipenv
documentation to create a virtual environment and install the dependencies.
Makefile
The included Makefile
prescribes actions to test, build, and publish this code to a Python Package Index (PyPI) repository as described in the following sections.
$ make [test | build | publish]
Testing
With the virtual environment active and the dependencies installed, use pytest to run the test suite.
The integration tests interact with the actual GCS API to manipulate blobs in an actual GCS bucket. If needed, change the GCS project and bucket used for these tests by changing the variables in the test_gcs.py
module.
The integration tests require credentials for the GCS bucket that is used for testing. When running the tests, you must provide credentials as described in the Authentication section above.
To run only the unit tests, and skip the integration tests, run:
$ pipenv run pytest -m "not integration"
Building
This project uses the setuptools Python package for packaging as described here.
When building via the make build
command, you may optionally append to the package name using the prerelease
argument. For example, if the current version of gcsutils
specified in the setup.py
module is 1.2.3
, then
$ make build prerelease=rc1
will produce a package named gcsutils-1.2.3rc1
. The default is a beta prerelease name incremented by each git commit (eg/ 1.2.3b7
for the seventh commit on this branch). Specify a final release with
$ make build prerelease=""
Note that prerelease names must comply with PEP 440.
Publishing
This project uses the twine Python package for distribution as described here.
When publishing via the make publish
command, the default PyPI repository is testpypi. To publish to pypi.org, specify that repository:
$ make publish pypi_repository=pypi
The credentials necessary to publish to the target PyPI repository can be provided in one of two ways.
- As these environment variables:
Env Var | Notes |
---|---|
PYPI_REPOSITORY_USERNAME |
PyPI account username. If authenticating using a token, use the literal string __token__ . |
PYPI_REPOSITORY_PASSWORD |
PyPI account password. If authenticating using a token, use the token contents. |
- At the
make publish
command:
$ make publish pypi_repository_password="foo" pypi_repository_password="bar"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gcsutils-1.1.2.tar.gz
.
File metadata
- Download URL: gcsutils-1.1.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1603928d63b49e23486881341ef6620b574f33c4c7c0ea02725fcbf2cb20d8c4 |
|
MD5 | 190cfcdeb3ee0861c9903a2ce8378755 |
|
BLAKE2b-256 | bd9c4bc157aa63bde9a40e22006a582400ff5132d43ca76d00cb857c4df9ec54 |
File details
Details for the file gcsutils-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: gcsutils-1.1.2-py3-none-any.whl
- Upload date:
- Size: 9.6 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/50.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29244647f0d0f7854b1941c66b80c6a114811dcb7ebd4377740fa9ad20936547 |
|
MD5 | 535368d5f0b947a308de7b0304e412ce |
|
BLAKE2b-256 | 340de46fffc9b6e1ebb2e2575659f4d5b6eea5a455ec6b0c6dda07014dc4ad3a |