From 71006c51233a9f1bf7917a22d9a22c7822c0c064 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Fri, 10 Dec 2021 12:44:21 -0800 Subject: [PATCH 1/5] revise readme links and venv set up --- README.rst | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index 358a28f29..ea3615221 100644 --- a/README.rst +++ b/README.rst @@ -34,20 +34,21 @@ In order to use this library, you first need to go through the following steps: .. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project .. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project .. _Enable the Google Cloud Storage API.: https://cloud.google.com/storage -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html +.. _Setup Authentication.: https://cloud.google.com/storage/docs/reference/libraries#setting_up_authentication Installation ~~~~~~~~~~~~ -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. +`Set up a Python development environment`_ and install this library in a `venv`. +`venv`_ is a tool to create isolated Python environments. The basic problem it +addresses is one of dependencies and versions, and indirectly permissions. -With `virtualenv`_, it's possible to install this library without needing system +With `venv`_, it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies. -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ +.. _Set up a Python development environment: https://cloud.google.com/python/docs/setup +.. _`venv`: https://docs.python.org/3/library/venv.html Supported Python Versions @@ -68,10 +69,9 @@ Mac/Linux .. code-block:: console - pip install virtualenv - virtualenv - source /bin/activate - /bin/pip install google-cloud-storage + python -m venv env + source env/bin/activate + pip install google-cloud-storage Windows @@ -79,10 +79,9 @@ Windows .. code-block:: console - pip install virtualenv - virtualenv - \Scripts\activate - \Scripts\pip.exe install google-cloud-storage + py -m venv env + .\env\Scripts\activate + pip install google-cloud-storage Example Usage @@ -90,8 +89,13 @@ Example Usage .. code:: python + # Imports the Google Cloud client library from google.cloud import storage + + # Instantiates a client client = storage.Client() + + # Creates a new bucket and uploads an object new_bucket = client.create_bucket('new-bucket-id') new_blob = new_bucket.blob('remote/path/storage.txt') new_blob.upload_from_filename(filename='/local/path.txt') From accdc42149221981f4122da22eb28c67d855b003 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Fri, 10 Dec 2021 13:02:30 -0800 Subject: [PATCH 2/5] remove duplicate steps in samples readme --- samples/README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/samples/README.md b/samples/README.md index bb48adc9b..f90522c66 100644 --- a/samples/README.md +++ b/samples/README.md @@ -21,7 +21,8 @@ Before running the samples, make sure you've followed the steps outlined in [Quick Start](https://github.com/googleapis/python-storage#quick-start). ### Authentication -This sample requires you to have authentication setup. Refer to the [Authentication Getting Started Guide](https://cloud.google.com/docs/authentication/getting-started) +The samples require you to have authentication setup. Provide authentication credentials to your application code by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS`. +Refer to the [Authentication Set Up Guide](https://cloud.google.com/storage/docs/reference/libraries#setting_up_authentication) for instructions on setting up credentials for applications. ### Install Dependencies @@ -30,15 +31,12 @@ for instructions on setting up credentials for applications. git clone https://github.com/googleapis/python-storage.git ``` -2. Install [pip](https://pip.pypa.io/) and [virtualenv](https://virtualenv.pypa.io) if you do not already have them. You may want to refer to the [Python Development Environment Setup Guide](https://cloud.google.com/python/setup) for Google Cloud Platform for instructions. - -3. Create a virtualenv. Samples are compatible with Python 3.6+. +2. Activate a venv if you have not already. ``` - virtualenv env source env/bin/activate ``` -4. Install the dependencies needed to run the samples. +3. Install the dependencies needed to run the samples. ``` cd samples/snippets pip install -r requirements.txt From c2e85fb2f4ddd60753641db648b5dee8b8ff2fd1 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Fri, 10 Dec 2021 13:27:12 -0800 Subject: [PATCH 3/5] add details and link to readme --- samples/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/README.md b/samples/README.md index f90522c66..f4af06583 100644 --- a/samples/README.md +++ b/samples/README.md @@ -31,9 +31,9 @@ for instructions on setting up credentials for applications. git clone https://github.com/googleapis/python-storage.git ``` -2. Activate a venv if you have not already. +2. Activate a venv if you have not already from the [Quick Start](https://github.com/googleapis/python-storage#quick-start). ``` - source env/bin/activate + source /bin/activate ``` 3. Install the dependencies needed to run the samples. From 6213929139d43f5098639f81ed670decb9d18791 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Mon, 13 Dec 2021 15:40:11 -0800 Subject: [PATCH 4/5] respond comments --- README.rst | 3 ++- samples/README.md | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index ea3615221..59f506f2c 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,8 @@ Installation `venv`_ is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions. -With `venv`_, it's possible to install this library without needing system +Make sure you're using Python 3.3 or later, which includes `venv`_ by default. +With `venv`, it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies. diff --git a/samples/README.md b/samples/README.md index 0609b3ed4..c343fca9e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -21,9 +21,8 @@ Before running the samples, make sure you've followed the steps outlined in [Quick Start](https://github.com/googleapis/python-storage#quick-start). ### Authentication -The samples require you to have authentication setup. Provide authentication credentials to your application code by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS`. Refer to the [Authentication Set Up Guide](https://cloud.google.com/storage/docs/reference/libraries#setting_up_authentication) -for instructions on setting up credentials for applications. +for more detailed instructions. ### Install Dependencies 1. Clone this repository and change to the sample directory you want to use. From 95a12017c9f49378e2cd0671a1a6f7c9c322b0c6 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Mon, 13 Dec 2021 15:50:10 -0800 Subject: [PATCH 5/5] add next steps to quickstart --- README.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 59f506f2c..0796bb05d 100644 --- a/README.rst +++ b/README.rst @@ -108,4 +108,12 @@ Example Usage blob = bucket.get_blob('remote/path/to/file.txt') print(blob.download_as_bytes()) blob.upload_from_string('New contents!') - + + +What's Next +~~~~~~~~~~~ + +Now that you've set up your Python client for Cloud Storage, +you can get started running `Storage samples.`_ + +.. _Storage samples.: https://github.com/googleapis/python-storage/tree/main/samples