Skip to content

Commit beaf708

Browse files
authored
chore(migration): Migrate code from googleapis/python-crc32c into packages/google-crc32c (#16006)
See #11005. This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.
2 parents c36aa61 + 0c87765 commit beaf708

45 files changed

Lines changed: 2521 additions & 0 deletions

Some content is hidden

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

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "packages/google-crc32c/google_crc32c"]
2+
path = packages/google-crc32c/google_crc32c
3+
url = https://github.com/google/crc32c.git
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Tell Kokoro where to find our fake test log so it doesn't 404
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Bypass the trampoline entirely and run our dummy script natively
11+
build_file: "google-cloud-python/packages/google-crc32c/scripts/bypass.sh"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Tell Kokoro where to find our fake test log so it doesn't 404
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Reuse the exact same bash script we used for Linux!
11+
build_file: "google-cloud-python/packages/google-crc32c/scripts/bypass.sh"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Tell Kokoro where to find our fake test log so it doesn't 404
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Reuse the exact same bash script we used for Linux!
11+
build_file: "google-cloud-python/packages/google-crc32c/scripts/bypass.sh"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Tell Kokoro where to find our fake test log so it doesn't 404
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Reuse the exact same bash script we used for Linux!
11+
build_file: "google-cloud-python/packages/google-crc32c/scripts/bypass.bat"

.librarian/state.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3828,6 +3828,15 @@ libraries:
38283828
remove_regex:
38293829
- packages/google-cloud-workstations/
38303830
tag_format: '{id}-v{version}'
3831+
- id: google-crc32c
3832+
version: 1.8.0
3833+
last_generated_commit: ""
3834+
apis: []
3835+
source_roots:
3836+
- packages/google-crc32c
3837+
preserve_regex: []
3838+
remove_regex: []
3839+
tag_format: '{id}-v{version}'
38313840
- id: google-geo-type
38323841
version: 0.6.0
38333842
last_generated_commit: 3322511885371d2b2253f209ccc3aa60d4100cfd

packages/google-crc32c/.coveragerc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2024 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Generated by synthtool. DO NOT EDIT!
18+
[run]
19+
branch = True
20+
omit =
21+
google/__init__.py
22+
google/cloud/__init__.py
23+
24+
[report]
25+
fail_under = 100
26+
show_missing = True
27+
exclude_lines =
28+
# Re-enable the standard pragma
29+
pragma: NO COVER
30+
# Ignore debug-only repr
31+
def __repr__
32+
# Ignore abstract methods
33+
raise NotImplementedError
34+
omit =
35+
*/gapic/*.py
36+
*/proto/*.py
37+
*/core/*.py
38+
*/site-packages/*.py
39+
google/cloud/__init__.py

packages/google-crc32c/.flake8

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2024 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Generated by synthtool. DO NOT EDIT!
18+
[flake8]
19+
ignore = E203, E231, E266, E501, W503
20+
exclude =
21+
# Exclude generated code.
22+
**/proto/**
23+
**/gapic/**
24+
**/services/**
25+
**/types/**
26+
*_pb2.py
27+
28+
# Standard linting exemptions.
29+
**/.nox/**
30+
__pycache__,
31+
.git,
32+
*.pyc,
33+
conf.py
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "google-crc32c",
3+
"name_pretty": "A python wrapper of the C library 'Google CRC32C'",
4+
"product_documentation": "",
5+
"client_documentation": "https://github.com/googleapis/python-crc32c",
6+
"issue_tracker": "https://github.com/googleapis/python-crc32c/issues",
7+
"release_level": "stable",
8+
"language": "python",
9+
"library_type": "OTHER",
10+
"repo": "googleapis/google-cloud-python",
11+
"distribution_name": "google-crc32c",
12+
"default_version": "",
13+
"codeowner_team": ""
14+
}

packages/google-crc32c/BUILDING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
# Building
3+
4+
## Be sure to check out all submodules:
5+
6+
```
7+
$ git clone --recursive https://github.com/googleapis/python-crc32c
8+
```
9+
10+
## Building and Testing Wheels
11+
12+
The scripts directory contains multiple scripts for building. They are also
13+
used by the CI workflows which can be found at .github/workflows.
14+
15+
On Linux:
16+
17+
```
18+
./scripts/manylinux/build.sh
19+
20+
21+
# Install the wheel that was built as a result
22+
pip install --no-index --find-links=wheels google-crc32c
23+
24+
# Check the package, try and load the native library.
25+
python ./scripts/check_crc32c_extension.py
26+
```
27+
28+
On OS X:
29+
30+
```
31+
# Build the C library and wheel
32+
./scripts/osx/build.sh
33+
34+
# Install the wheel that was built as a result
35+
pip install --no-index --find-links=wheels google-crc32c
36+
37+
# Check the package, try and load the native library.
38+
python ./scripts/check_crc32c_extension.py
39+
```
40+
41+
On Windows:
42+
43+
```
44+
.\scripts\windows\build.bat
45+
.\scripts\windows\test.bat
46+
```
47+
48+
49+
## Installing locally for testing
50+
51+
Initialize the submodules and build the main `libcrc32c.so` shared
52+
library using `cmake` / `make`:
53+
54+
```bash
55+
$ cd python-crc32c
56+
$ git submodule update --init --recursive
57+
$ python -m venv venv
58+
$ venv/bin/pip install --upgrade setuptools pip wheel
59+
$ venv/bin/pip install cmake
60+
$ mkdir usr
61+
$ export CRC32C_INSTALL_PREFIX=$(pwd)/usr
62+
$ mkdir google_crc32c/build
63+
$ cd google_crc32c/build
64+
$ ../../venv/bin/cmake \
65+
> -DCMAKE_BUILD_TYPE=Release \
66+
> -DCRC32C_BUILD_TESTS=no \
67+
> -DCRC32C_BUILD_BENCHMARKS=no \
68+
> -DBUILD_SHARED_LIBS=yes \
69+
> -DCMAKE_INSTALL_PREFIX:PATH=${CRC32C_INSTALL_PREFIX} \
70+
> ..
71+
$ make all install
72+
$ cd ../..
73+
```
74+
75+
Now, run the tests:
76+
77+
```bash
78+
$ venv/bin/python setup.py build_ext \
79+
--include-dirs=$(pwd)/usr/include \
80+
--library-dirs=$(pwd)/usr/lib \
81+
--rpath=$(pwd)/usr/lib
82+
$ venv/bin/pip install -e .[testing]
83+
$ venv/bin/py.test tests/
84+
============================= test session starts ==============================
85+
platform linux -- Python 3.6.7, pytest-3.10.0, py-1.7.0, pluggy-0.8.0
86+
rootdir: ..., inifile:
87+
collected 9 items
88+
89+
tests/test___init__.py ......... [100%]
90+
91+
=========================== 9 passed in 0.03 seconds ===========================
92+
```

0 commit comments

Comments
 (0)