Skip to content

Commit 540025b

Browse files
authored
chore(migration): Migrate code from googleapis/python-cloud-core into packages/google-cloud-core (googleapis#15542)
See googleapis#11000. This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.
2 parents 9f6e8f5 + 4ee639b commit 540025b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+6699
-0
lines changed

.librarian/state.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,15 @@ libraries:
11581158
remove_regex:
11591159
- packages/google-cloud-contentwarehouse/
11601160
tag_format: '{id}-v{version}'
1161+
- id: google-cloud-core
1162+
version: 2.5.0
1163+
last_generated_commit: ""
1164+
apis: []
1165+
source_roots:
1166+
- packages/google-cloud-core
1167+
preserve_regex: []
1168+
remove_regex: []
1169+
tag_format: '{id}-v{version}'
11611170
- id: google-cloud-data-fusion
11621171
version: 1.15.0
11631172
last_generated_commit: 3322511885371d2b2253f209ccc3aa60d4100cfd
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
omit =
6+
/tmp/*
7+
google/cloud/__init__.py
8+
google/cloud/_testing/__init__.py
9+
google/cloud/environment_vars/__init__.py
10+
fail_under = 100
11+
show_missing = True
12+
exclude_lines =
13+
# Re-enable the standard pragma
14+
pragma: NO COVER
15+
# Ignore debug-only repr
16+
def __repr__
17+
# Ignore abstract methods
18+
raise NotImplementedError
19+
raise NotImplementedError()

packages/google-cloud-core/.flake8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
import-order-style=google
3+
# Note: this forces all google imports to be in the third group. See
4+
# https://github.com/PyCQA/flake8-import-order/issues/111
5+
application-import-names=google
6+
ignore = E203, E266, E501, W503, I202
7+
exclude =
8+
__pycache__,
9+
.git,
10+
*.pyc,
11+
conf.py
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "google-cloud-core",
3+
"name_pretty": "Google API client core library",
4+
"client_documentation": "https://cloud.google.com/python/docs/reference/google-cloud-core/latest",
5+
"issue_tracker": "https://github.com/googleapis/google-cloud-python/issues",
6+
"release_level": "stable",
7+
"language": "python",
8+
"library_type": "CORE",
9+
"repo": "googleapis/google-cloud-python",
10+
"distribution_name": "google-cloud-core",
11+
"default_version": "",
12+
"codeowner_team": ""
13+
}

packages/google-cloud-core/CHANGELOG.md

Lines changed: 407 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
.. Generated by synthtool. DO NOT EDIT!
2+
############
3+
Contributing
4+
############
5+
6+
#. **Please sign one of the contributor license agreements below.**
7+
#. Fork the repo, develop and test your code changes, add docs.
8+
#. Make sure that your commit messages clearly describe the changes.
9+
#. Send a pull request. (Please Read: `Faster Pull Request Reviews`_)
10+
11+
.. _Faster Pull Request Reviews: https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
12+
13+
.. contents:: Here are some guidelines for hacking on the Google Cloud Client libraries.
14+
15+
***************
16+
Adding Features
17+
***************
18+
19+
In order to add a feature:
20+
21+
- The feature must be documented in both the API and narrative
22+
documentation.
23+
24+
- The feature must work fully on the following CPython versions:
25+
3.8, 3.9, 3.10, 3.11, 3.12, 3.13 and 3.14 on both UNIX and Windows.
26+
27+
- The feature must not add unnecessary dependencies (where
28+
"unnecessary" is of course subjective, but new dependencies should
29+
be discussed).
30+
31+
****************************
32+
Using a Development Checkout
33+
****************************
34+
35+
You'll have to create a development environment using a Git checkout:
36+
37+
- While logged into your GitHub account, navigate to the
38+
``google-cloud-python`` `repo`_ on GitHub.
39+
40+
- Fork and clone the ``google-cloud-python`` repository to your GitHub account by
41+
clicking the "Fork" button.
42+
43+
- Clone your fork of ``google-cloud-python`` from your GitHub account to your local
44+
computer, substituting your account username and specifying the destination
45+
as ``hack-on-google-cloud-python``. E.g.::
46+
47+
$ cd ${HOME}
48+
$ git clone git@github.com:USERNAME/google-cloud-python.git hack-on-google-cloud-python
49+
$ cd hack-on-google-cloud-python
50+
# Configure remotes such that you can pull changes from the googleapis/google-cloud-python
51+
# repository into your local repository.
52+
$ git remote add upstream git@github.com:googleapis/google-cloud-python.git
53+
# fetch and merge changes from upstream into main
54+
$ git fetch upstream
55+
$ git merge upstream/main
56+
57+
Now your local repo is set up such that you will push changes to your GitHub
58+
repo, from which you can submit a pull request.
59+
60+
To work on the codebase and run the tests, we recommend using ``nox``,
61+
but you can also use a ``virtualenv`` of your own creation.
62+
63+
.. _repo: https://github.com/googleapis/google-cloud-python
64+
65+
Using ``nox``
66+
=============
67+
68+
We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
69+
70+
- To test your changes, run unit tests with ``nox``::
71+
$ nox -s unit
72+
73+
- To run a single unit test::
74+
75+
$ nox -s unit-3.14 -- -k <name of test>
76+
77+
78+
.. note::
79+
80+
The unit tests and system tests are described in the
81+
``noxfile.py`` files in each directory.
82+
83+
.. nox: https://pypi.org/project/nox/
84+
85+
*****************************************
86+
I'm getting weird errors... Can you help?
87+
*****************************************
88+
89+
If the error mentions ``Python.h`` not being found,
90+
install ``python-dev`` and try again.
91+
On Debian/Ubuntu::
92+
93+
$ sudo apt-get install python-dev
94+
95+
************
96+
Coding Style
97+
************
98+
- We use the automatic code formatter ``black``. You can run it using
99+
the nox session ``blacken``. This will eliminate many lint errors. Run via::
100+
101+
$ nox -s blacken
102+
103+
- PEP8 compliance is required, with exceptions defined in the linter configuration.
104+
If you have ``nox`` installed, you can test that you have not introduced
105+
any non-compliant code via::
106+
107+
$ nox -s lint
108+
109+
- In order to make ``nox -s lint`` run faster, you can set some environment
110+
variables::
111+
112+
export GOOGLE_CLOUD_TESTING_REMOTE="upstream"
113+
export GOOGLE_CLOUD_TESTING_BRANCH="main"
114+
115+
By doing this, you are specifying the location of the most up-to-date
116+
version of ``google-cloud-python``. The
117+
remote name ``upstream`` should point to the official ``googleapis``
118+
checkout and the branch should be the default branch on that remote (``main``).
119+
120+
- This repository contains configuration for the
121+
`pre-commit <https://pre-commit.com/>`__ tool, which automates checking
122+
our linters during a commit. If you have it installed on your ``$PATH``,
123+
you can enable enforcing those checks via:
124+
125+
.. code-block:: bash
126+
127+
$ pre-commit install
128+
pre-commit installed at .git/hooks/pre-commit
129+
130+
Exceptions to PEP8:
131+
132+
- Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for
133+
"Function-Under-Test"), which is PEP8-incompliant, but more readable.
134+
Some also use a local variable, ``MUT`` (short for "Module-Under-Test").
135+
136+
********************
137+
Running System Tests
138+
********************
139+
140+
- To run system tests, you can execute::
141+
142+
# Run all system tests
143+
$ nox -s system
144+
145+
# Run a single system test
146+
$ nox -s system-3.8 -- -k <name of test>
147+
148+
149+
.. note::
150+
151+
System tests are only configured to run under Python 3.8.
152+
For expediency, we do not run them in older versions of Python 3.
153+
154+
This alone will not run the tests. You'll need to change some local
155+
auth settings and change some configuration in your project to
156+
run all the tests.
157+
158+
- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication <https://cloud.google.com/docs/authentication/best-practices-applications#local_development_and_testing_with_the>`__. Some tests require a service account. For those tests see `Authenticating as a service account <https://cloud.google.com/docs/authentication/production>`__.
159+
160+
*************
161+
Test Coverage
162+
*************
163+
164+
- The codebase *must* have 100% test statement coverage after each commit.
165+
You can test coverage via ``nox -s cover``.
166+
167+
******************************************************
168+
Documentation Coverage and Building HTML Documentation
169+
******************************************************
170+
171+
If you fix a bug, and the bug requires an API or behavior modification, all
172+
documentation in this package which references that API or behavior must be
173+
changed to reflect the bug fix, ideally in the same commit that fixes the bug
174+
or adds the feature.
175+
176+
Build the docs via:
177+
178+
$ nox -s docs
179+
180+
*************************
181+
Samples and code snippets
182+
*************************
183+
184+
Code samples and snippets live in the `samples/` catalogue. Feel free to
185+
provide more examples, but make sure to write tests for those examples.
186+
Each folder containing example code requires its own `noxfile.py` script
187+
which automates testing. If you decide to create a new folder, you can
188+
base it on the `samples/snippets` folder (providing `noxfile.py` and
189+
the requirements files).
190+
191+
The tests will run against a real Google Cloud Project, so you should
192+
configure them just like the System Tests.
193+
194+
- To run sample tests, you can execute::
195+
196+
# Run all tests in a folder
197+
$ cd samples/snippets
198+
$ nox -s py-3.8
199+
200+
# Run a single sample test
201+
$ cd samples/snippets
202+
$ nox -s py-3.8 -- -k <name of test>
203+
204+
********************************************
205+
Note About ``README`` as it pertains to PyPI
206+
********************************************
207+
208+
The `description on PyPI`_ for the project comes directly from the
209+
``README``. Due to the reStructuredText (``rst``) parser used by
210+
PyPI, relative links which will work on GitHub (e.g. ``CONTRIBUTING.rst``
211+
instead of
212+
``https://github.com/googleapis/google-cloud-python/blob/main/CONTRIBUTING.rst``)
213+
may cause problems creating links or rendering the description.
214+
215+
.. _description on PyPI: https://pypi.org/project/google-cloud-core
216+
217+
218+
*************************
219+
Supported Python Versions
220+
*************************
221+
222+
We support:
223+
224+
- `Python 3.8`_
225+
- `Python 3.9`_
226+
- `Python 3.10`_
227+
- `Python 3.11`_
228+
- `Python 3.12`_
229+
- `Python 3.13`_
230+
- `Python 3.14`_
231+
232+
.. _Python 3.8: https://docs.python.org/3.8/
233+
.. _Python 3.9: https://docs.python.org/3.9/
234+
.. _Python 3.10: https://docs.python.org/3.10/
235+
.. _Python 3.11: https://docs.python.org/3.11/
236+
.. _Python 3.12: https://docs.python.org/3.12/
237+
.. _Python 3.13: https://docs.python.org/3.13/
238+
.. _Python 3.14: https://docs.python.org/3.14/
239+
240+
241+
Supported versions can be found in our ``noxfile.py`` `config`_.
242+
243+
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/noxfile.py
244+
245+
246+
We also explicitly decided to support Python 3 beginning with version 3.8.
247+
Reasons for this include:
248+
249+
- Encouraging use of newest versions of Python 3
250+
- Taking the lead of `prominent`_ open-source `projects`_
251+
- `Unicode literal support`_ which allows for a cleaner codebase that
252+
works in both Python 2 and Python 3
253+
254+
.. _prominent: https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django
255+
.. _projects: http://flask.pocoo.org/docs/0.10/python3/
256+
.. _Unicode literal support: https://www.python.org/dev/peps/pep-0414/
257+
258+
**********
259+
Versioning
260+
**********
261+
262+
This library follows `Semantic Versioning`_.
263+
264+
.. _Semantic Versioning: http://semver.org/
265+
266+
Some packages are currently in major version zero (``0.y.z``), which means that
267+
anything may change at any time and the public API should not be considered
268+
stable.
269+
270+
******************************
271+
Contributor License Agreements
272+
******************************
273+
274+
Before we can accept your pull requests you'll need to sign a Contributor
275+
License Agreement (CLA):
276+
277+
- **If you are an individual writing original source code** and **you own the
278+
intellectual property**, then you'll need to sign an
279+
`individual CLA <https://developers.google.com/open-source/cla/individual>`__.
280+
- **If you work for a company that wants to allow you to contribute your work**,
281+
then you'll need to sign a
282+
`corporate CLA <https://developers.google.com/open-source/cla/corporate>`__.
283+
284+
You can sign these electronically (just scroll to the bottom). After that,
285+
we'll be able to accept your pull requests.

0 commit comments

Comments
 (0)