18
18
import shutil
19
19
import synthtool as s
20
20
import synthtool .gcp as gcp
21
- from typing import Union , Dict , List
22
-
23
-
24
- def create_gapic_version_py (package_dir : str ):
25
- """
26
- Create a version file `gapic_version.py` if it doesn't exist.
27
-
28
- Args:
29
- package_dir (str): path to the directory for a specific package. For example
30
- 'packages/google-cloud-video-transcoder'
31
- """
32
- sub_directory_to_gapic = Path (package_dir ).name .replace ("-" , "/" )
33
- gapic_version_path = Path (
34
- f"{ package_dir } /{ sub_directory_to_gapic } /gapic_version.py"
35
- )
36
-
37
- gapic_version_text = """# -*- coding: utf-8 -*-
38
- # Copyright 2022 Google LLC
39
- #
40
- # Licensed under the Apache License, Version 2.0 (the "License");
41
- # you may not use this file except in compliance with the License.
42
- # You may obtain a copy of the License at
43
- #
44
- # http://www.apache.org/licenses/LICENSE-2.0
45
- #
46
- # Unless required by applicable law or agreed to in writing, software
47
- # distributed under the License is distributed on an "AS IS" BASIS,
48
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
- # See the License for the specific language governing permissions and
50
- # limitations under the License.
51
- #
52
-
53
- __version__ = "0.0.0" # {x-release-please-version}
54
- """
55
-
56
- if not gapic_version_path .exists ():
57
- with open (gapic_version_path , "w" ) as f :
58
- f .write (gapic_version_text )
59
21
60
22
61
23
def create_symlink_in_docs_dir (package_dir : str , filename : str ):
@@ -189,7 +151,7 @@ def owlbot_main(package_dir: str) -> None:
189
151
f"{ package_dir } /samples/generated_samples" , ignore_errors = True
190
152
)
191
153
clean_up_generated_samples = False
192
- s .move ([library ], package_dir , excludes = ["**/gapic_version.py" ])
154
+ s .move ([library ], package_dir , excludes = [])
193
155
194
156
templated_files = gcp .CommonTemplates ().py_mono_repo_library (
195
157
relative_dir = f"packages/{ Path (package_dir ).name } " ,
@@ -203,9 +165,6 @@ def owlbot_main(package_dir: str) -> None:
203
165
)
204
166
s .move ([templated_files ], package_dir )
205
167
206
- # create gapic_version.py if it doesn't exist
207
- create_gapic_version_py (package_dir )
208
-
209
168
# create symlink docs/README.rst if it doesn't exist
210
169
create_symlink_docs_readme (package_dir )
211
170
@@ -222,55 +181,8 @@ def owlbot_main(package_dir: str) -> None:
222
181
s .shell .run (["nox" , "-s" , "format" ], cwd = noxfile .parent , hide_output = False )
223
182
224
183
225
- def configure_release_please (owlbot_dirs : str ):
226
- # add all packages to the .release-please-manifest.json
227
- # and release-please-config.json files if they don't exist
228
- release_please_manifest = Path (".release-please-manifest.json" )
229
- release_please_config = Path ("release-please-config.json" )
230
-
231
- with open (release_please_manifest , "r" ) as f :
232
- manifest_json = json .load (f )
233
- for package_dir in owlbot_dirs :
234
- package_name = Path (package_dir ).name
235
- if f"packages/{ package_name } " not in manifest_json :
236
- manifest_json [f"packages/{ package_name } " ] = "0.0.0"
237
-
238
- with open (release_please_manifest , "w" ) as f :
239
- json .dump (manifest_json , f , indent = 4 )
240
-
241
- with open (release_please_config , "r" ) as f :
242
- config_json = json .load (f )
243
- for package_dir in owlbot_dirs :
244
- package_name = Path (package_dir ).name
245
- # if package_name not in config_json["packages"]:
246
- path_to_version_file = "{}/gapic_version.py" .format (
247
- package_name .replace ("-" , "/" )
248
- )
249
-
250
- output : List [Union [str , Dict [str , str ]]] = []
251
- output .append (path_to_version_file )
252
- for file in Path (package_dir ).glob ("samples/**/*.json" ):
253
- sample_json = {}
254
- sample_json ["type" ] = "json"
255
- sample_json ["path" ] = str (file ).replace (
256
- f"/workspace/google-cloud-python/packages/{ package_name } /" , ""
257
- )
258
- sample_json ["jsonpath" ] = "$.clientLibrary.version"
259
- output .append (sample_json )
260
-
261
- config_json ["packages" ][f"packages/{ package_name } " ] = {
262
- "component" : f"{ package_name } " ,
263
- "release-type" : "python" ,
264
- "extra-files" : output ,
265
- }
266
-
267
- with open (release_please_config , "w" ) as f :
268
- json .dump (config_json , f , indent = 4 )
269
-
270
-
271
184
if __name__ == "__main__" :
272
185
owlbot_dirs = walk_through_owlbot_dirs (Path .cwd ())
273
- configure_release_please (owlbot_dirs )
274
186
for package_dir in owlbot_dirs :
275
187
owlbot_main (package_dir )
276
188
0 commit comments