Skip to content

Commit e1b4352

Browse files
authored
chore(migration): Migrate code from googleapis/python-api-core into packages/google-api-core (#15567)
See #10892. This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.
2 parents 3928ddc + 5f4fbde commit e1b4352

158 files changed

Lines changed: 31492 additions & 0 deletions

File tree

Some content is hidden

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

.librarian/state.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ libraries:
9696
remove_regex:
9797
- packages/google-analytics-data/
9898
tag_format: '{id}-v{version}'
99+
- id: google-api-core
100+
version: 2.29.0
101+
last_generated_commit: ""
102+
apis: []
103+
source_roots:
104+
- packages/google-api-core
105+
preserve_regex: []
106+
remove_regex: []
107+
tag_format: '{id}-v{version}'
99108
- id: google-apps-card
100109
version: 0.5.0
101110
last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
fail_under = 100
6+
show_missing = True
7+
exclude_lines =
8+
# Re-enable the standard pragma
9+
pragma: NO COVER
10+
# Ignore debug-only repr
11+
def __repr__
12+
# Ignore abstract methods
13+
raise NotImplementedError
14+
# Ignore coverage for code specific to static type checkers
15+
TYPE_CHECKING

packages/google-api-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
7+
exclude =
8+
__pycache__,
9+
.git,
10+
*.pyc,
11+
conf.py
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "google-api-core",
3+
"name_pretty": "Google API client core library",
4+
"client_documentation": "https://googleapis.dev/python/google-api-core/latest",
5+
"release_level": "stable",
6+
"language": "python",
7+
"library_type": "CORE",
8+
"repo": "googleapis/google-cloud-python",
9+
"distribution_name": "google-api-core",
10+
"default_version": "",
11+
"codeowner_team": "@googleapis/cloud-sdk-python-team"
12+
}

packages/google-api-core/CHANGELOG.md

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

0 commit comments

Comments
 (0)