Skip to content

Commit

Permalink
typespec compiling with pygen inside dist
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed May 15, 2024
1 parent 1ad22b4 commit 904ba52
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/autorest.python/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from venvtools import ExtendedEnvBuilder, python_run

_ROOT_DIR = Path(__file__).parent
_ROOT_DIR = Path(__file__).parent


def main():
Expand Down
7 changes: 3 additions & 4 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"files": [
"lib/*.cadl",
"dist/**",
"!dist/test/**",
"get-autorest-python-path.cjs"
"!dist/test/**"
],
"peerDependencies": {
"@azure-tools/typespec-azure-core": ">=0.42.0 <1.0.0",
Expand All @@ -58,9 +57,9 @@
}
},
"dependencies": {
"@autorest/python": "workspace:^",
"js-yaml": "~4.1.0",
"@typespec/openapi3": "~0.56.0"
"@typespec/openapi3": "~0.56.0",
"@autorest/system-requirements": "~1.0.2"
},
"devDependencies": {
"@azure-tools/typespec-azure-resource-manager": "~0.42.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/typespec-python/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { execFileSync } from "child_process";
import { PythonEmitterOptions, PythonSdkContext } from "./lib.js";
import { emitCodeModel } from "./code-model.js";
import { removeUnderscoresFromNamespace } from "./utils.js";
import path from "path";

export function getModelsMode(context: SdkContext): "dpg" | "none" {
const specifiedModelsMode = context.emitContext.options["models-mode"];
Expand Down Expand Up @@ -66,14 +67,14 @@ function createPythonSdkContext<TServiceOperation extends SdkServiceOperation>(
export async function $onEmit(context: EmitContext<PythonEmitterOptions>) {
const program = context.program;
const sdkContext = createPythonSdkContext<SdkHttpOperation>(context);
const root = await resolveModuleRoot(program, "@autorest/python", dirname(fileURLToPath(import.meta.url)));
const root = path.join(dirname(fileURLToPath(import.meta.url)), "pygen");
const outputDir = context.emitterOutputDir;
const yamlMap = emitCodeModel(sdkContext);
addDefaultOptions(sdkContext);
const yamlPath = await saveCodeModelAsYaml("typespec-python-yaml-map", yamlMap);
const commandArgs = [
`${root}/run-python3.js`,
`${root}/run_cadl.py`,
`${root}/run_tsp.py`,
`--output-folder=${outputDir}`,
`--cadl-file=${yamlPath}`,
];
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 904ba52

Please sign in to comment.