Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions tools/azure-sdk-tools/packaging_tools/generate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,19 +415,21 @@ def gen_typespec(
typespec_python = "@azure-tools/typespec-python"
# call scirpt to generate sdk
try:
tsp_dir = (Path(spec_folder) / typespec_relative_path).resolve()
repo_url = rest_repo_url.replace("https://github.com/", "")
tspconfig = tsp_dir / "tspconfig.yaml"
if api_version and tspconfig.exists():
with open(tspconfig, "r") as file_in:
content = yaml.safe_load(file_in)
if content.get("options", {}).get("@azure-tools/typespec-python"):
content["options"]["@azure-tools/typespec-python"]["api-version"] = api_version
with open(tspconfig, "w") as file_out:
yaml.dump(content, file_out)
cmd = (
f"tsp-client init --tsp-config {tsp_dir} --local-spec-repo {tsp_dir} --commit {head_sha} --repo {repo_url}"
)
if spec_folder:
tsp_dir = (Path(spec_folder) / typespec_relative_path).resolve()
repo_url = rest_repo_url.replace("https://github.com/", "")
tspconfig = tsp_dir / "tspconfig.yaml"
if api_version and tspconfig.exists():
with open(tspconfig, "r") as file_in:
content = yaml.safe_load(file_in)
if content.get("options", {}).get("@azure-tools/typespec-python"):
content["options"]["@azure-tools/typespec-python"]["api-version"] = api_version
with open(tspconfig, "w") as file_out:
yaml.dump(content, file_out)
cmd = f"tsp-client init --tsp-config {tsp_dir} --local-spec-repo {tsp_dir} --commit {head_sha} --repo {repo_url}"
else:
tsp_config_url = f"{rest_repo_url}/blob/{head_sha}/{typespec_relative_path}/tspconfig.yaml"
cmd = f"tsp-client init -c {tsp_config_url}"
if run_in_pipeline:
emitter_name = "@azure-tools/typespec-python"
if not os.path.exists(f"node_modules/{emitter_name}"):
Expand Down
2 changes: 1 addition & 1 deletion tools/azure-sdk-tools/packaging_tools/sdk_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def main(generate_input, generate_output):
with open(generate_input, "r") as reader:
data = json.load(reader)

spec_folder = data["specFolder"]
spec_folder = data.get("specFolder", "")
sdk_folder = "."
result = {}
python_tag = data.get("python_tag")
Expand Down
Loading