diff --git a/tools/azure-sdk-tools/packaging_tools/generate_utils.py b/tools/azure-sdk-tools/packaging_tools/generate_utils.py index afde043f6e51..cca28e3b1416 100644 --- a/tools/azure-sdk-tools/packaging_tools/generate_utils.py +++ b/tools/azure-sdk-tools/packaging_tools/generate_utils.py @@ -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}"): diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py index 434727b8e18a..74c099b8bdaf 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py @@ -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")