diff --git a/packages/pyright-internal/src/common/configOptions.ts b/packages/pyright-internal/src/common/configOptions.ts index 202898ab6..76f26c5d0 100644 --- a/packages/pyright-internal/src/common/configOptions.ts +++ b/packages/pyright-internal/src/common/configOptions.ts @@ -1374,6 +1374,8 @@ export class ConfigOptions { if (configObj.pythonPlatform !== undefined) { if (typeof configObj.pythonPlatform !== 'string') { errors.push(`Config "pythonPlatform" field must contain a string.`); + } else if (!['Linux', 'Windows', 'Darwin', 'All'].includes(configObj.pythonPlatform)) { + `'${configObj.pythonPlatform}' is not a supported Python platform; specify All, Darwin, Linux, or Windows.`; } else { this.defaultPythonPlatform = configObj.pythonPlatform; } @@ -1515,15 +1517,12 @@ export class ConfigOptions { ensureDefaultPythonPlatform(host: Host, console: ConsoleInterface) { // If no default python platform was specified, assume that the - // user wants to use the current platform. + // user wants to use all mode if (this.defaultPythonPlatform !== undefined) { return; } - this.defaultPythonPlatform = host.getPythonPlatform(); - if (this.defaultPythonPlatform !== undefined) { - console.log(`Assuming Python platform ${this.defaultPythonPlatform}`); - } + this.defaultPythonPlatform = 'All'; } ensureDefaultPythonVersion(host: Host, console: ConsoleInterface) { diff --git a/packages/pyright-internal/src/pyright.ts b/packages/pyright-internal/src/pyright.ts index d9e6a4203..9f300d2e5 100644 --- a/packages/pyright-internal/src/pyright.ts +++ b/packages/pyright-internal/src/pyright.ts @@ -274,11 +274,11 @@ async function processArgs(): Promise { } if (args.pythonplatform) { - if (args.pythonplatform === 'Darwin' || args.pythonplatform === 'Linux' || args.pythonplatform === 'Windows') { + if (!['All', 'Darwin', 'Linux', 'Windows'].includes(args.pythonplatform)) { options.pythonPlatform = args.pythonplatform; } else { console.error( - `'${args.pythonplatform}' is not a supported Python platform; specify Darwin, Linux, or Windows` + `'${args.pythonplatform}' is not a supported Python platform; specify All, Darwin, Linux, or Windows` ); return ExitStatus.ParameterError; } diff --git a/pdm_build.py b/pdm_build.py index 80b96827e..029ac9bda 100644 --- a/pdm_build.py +++ b/pdm_build.py @@ -11,12 +11,18 @@ from subprocess import run # noqa: S404 else: from nodejs.npm import run +import os + +from nodejs import node class PackageJson(TypedDict): bin: dict[str, str] +# ah yes, the classic "wrong path" moment! +os.environ["PATH"] = os.pathsep.join([str(Path(node.__file__).parent), os.environ["PATH"]]) + if not Path("node_modules").exists(): _ = run(["ci"], check=True) _ = run(["run", "build:cli:dev"], check=True) diff --git a/pyproject.toml b/pyproject.toml index 8e47cbe10..a7d1760ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -240,7 +240,6 @@ max-line-length = 200 [tool.basedpyright] ignore = ["pw", "basedpyright/dist", "packages"] pythonVersion = "3.8" -pythonPlatform = "All" include = ["basedpyright", "get_version.py", "pdm_build.py"] exclude = ["pw", "basedpyright/dist", "packages"] typeCheckingMode = "all"