|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
| 14 | + |
| 15 | +import json |
| 16 | +from pathlib import Path |
| 17 | +import shutil |
| 18 | + |
14 | 19 | import synthtool as s
|
15 | 20 | import synthtool.gcp as gcp
|
16 | 21 | from synthtool.languages import python
|
17 | 22 |
|
| 23 | +# ---------------------------------------------------------------------------- |
| 24 | +# Copy the generated client from the owl-bot staging directory |
| 25 | +# ---------------------------------------------------------------------------- |
| 26 | + |
| 27 | +clean_up_generated_samples = True |
18 | 28 |
|
19 |
| -for library in s.get_staging_dirs(): |
20 |
| - s.move([library / "**/*.py*"]) |
| 29 | +# Load the default version defined in .repo-metadata.json. |
| 30 | +default_version = json.load(open(".repo-metadata.json", "rt")).get( |
| 31 | + "default_version" |
| 32 | +) |
| 33 | + |
| 34 | +for library in s.get_staging_dirs(default_version): |
| 35 | + if clean_up_generated_samples: |
| 36 | + shutil.rmtree("samples/generated_samples", ignore_errors=True) |
| 37 | + clean_up_generated_samples = False |
| 38 | + s.move([library], excludes=["**/gapic_version.py"]) |
21 | 39 | s.remove_staging_dirs()
|
22 | 40 |
|
23 | 41 | # ----------------------------------------------------------------------------
|
24 |
| -# Add templated files |
| 42 | +# Add templated files |
25 | 43 | # ----------------------------------------------------------------------------
|
26 |
| -common = gcp.CommonTemplates() |
27 |
| -templated_files = common.py_library() |
28 |
| -# TODO: use protoc-docs-plugin to add docstrings to protos |
29 |
| -s.move(templated_files / ".kokoro", excludes=["docs/**/*", "publish-docs.sh"]) |
30 |
| -s.move(templated_files / "setup.cfg") |
31 |
| -s.move(templated_files / "LICENSE") |
32 |
| -s.move(templated_files / "MANIFEST.in") |
33 |
| -s.move(templated_files / "renovate.json") |
34 |
| -s.move(templated_files / ".github", excludes=["workflows"]) |
35 |
| - |
36 |
| -s.shell.run(["nox", "-s", "blacken"], hide_output=False) |
37 |
| - |
38 |
| -# Add license headers |
39 |
| -python.fix_pb2_headers() |
| 44 | + |
| 45 | +templated_files = gcp.CommonTemplates().py_library( |
| 46 | + cov_level=100, |
| 47 | + microgenerator=True, |
| 48 | + versions=gcp.common.detect_versions(path="./google", default_first=True), |
| 49 | +) |
| 50 | +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"]) |
| 51 | + |
| 52 | +python.py_samples(skip_readmes=True) |
| 53 | + |
| 54 | +# run format session for all directories which have a noxfile |
| 55 | +for noxfile in Path(".").glob("**/noxfile.py"): |
| 56 | + s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) |
0 commit comments