Skip to content

Commit 70ec260

Browse files
authored
chore(python): remove release post processing for python monorepo (#1797)
* chore(python): remove release post processing for python monorepo * don't exclude autogenerated gapic_version.py
1 parent 30bd01b commit 70ec260

File tree

1 file changed

+1
-89
lines changed

1 file changed

+1
-89
lines changed

synthtool/languages/python_mono_repo.py

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,6 @@
1818
import shutil
1919
import synthtool as s
2020
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)
5921

6022

6123
def create_symlink_in_docs_dir(package_dir: str, filename: str):
@@ -189,7 +151,7 @@ def owlbot_main(package_dir: str) -> None:
189151
f"{package_dir}/samples/generated_samples", ignore_errors=True
190152
)
191153
clean_up_generated_samples = False
192-
s.move([library], package_dir, excludes=["**/gapic_version.py"])
154+
s.move([library], package_dir, excludes=[])
193155

194156
templated_files = gcp.CommonTemplates().py_mono_repo_library(
195157
relative_dir=f"packages/{Path(package_dir).name}",
@@ -203,9 +165,6 @@ def owlbot_main(package_dir: str) -> None:
203165
)
204166
s.move([templated_files], package_dir)
205167

206-
# create gapic_version.py if it doesn't exist
207-
create_gapic_version_py(package_dir)
208-
209168
# create symlink docs/README.rst if it doesn't exist
210169
create_symlink_docs_readme(package_dir)
211170

@@ -222,55 +181,8 @@ def owlbot_main(package_dir: str) -> None:
222181
s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)
223182

224183

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-
271184
if __name__ == "__main__":
272185
owlbot_dirs = walk_through_owlbot_dirs(Path.cwd())
273-
configure_release_please(owlbot_dirs)
274186
for package_dir in owlbot_dirs:
275187
owlbot_main(package_dir)
276188

0 commit comments

Comments
 (0)