Skip to content

Commit

Permalink
Fix install issue (#2861)
Browse files Browse the repository at this point in the history
* fix for install

* fix for install

* changelog

* fix ci
  • Loading branch information
msyyc authored Sep 30, 2024
1 parent d17850e commit 27b6ecd
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 38 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/fix-install-2024-8-30-21-14-32.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-python"
---

Fix install issue
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,3 @@ node_modules/
# Generated test folders
test/services/*/_generated
**/autorest.python/generator
**/typespec-python/generator
2 changes: 0 additions & 2 deletions packages/typespec-python/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
-r ../../eng/requirements.txt
-r ../../eng/dev_requirements.txt
-e generator

12 changes: 12 additions & 0 deletions packages/typespec-python/generator/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pyright==1.1.375
pylint==3.2.6
tox==4.16.0
mypy==1.10.1
azure-pylint-guidelines-checker==0.0.8
colorama==0.4.6
debugpy==1.8.2
pytest==8.3.2
coverage==7.6.1
black==24.8.0
ptvsd==4.3.2
types-PyYAML==6.0.12.8
12 changes: 12 additions & 0 deletions packages/typespec-python/generator/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
black==24.4.0
click==8.1.3
docutils==0.19
Jinja2==3.1.4
m2r2==0.3.3
MarkupSafe==2.1.2
mistune==0.8.4
pathspec==0.11.1
platformdirs==3.2.0
PyYAML==6.0.1
tomli==2.0.1
setuptools==69.2.0
8 changes: 4 additions & 4 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
"lint": "tsx ./scripts/eng/lint.ts",
"lint:fix": "eslint . --fix --ext .ts",
"format": "npx prettier **/*.ts --write && tsx ./scripts/eng/format.ts",
"install": "tsx ./scripts/copy-scripts.ts --force && tsx ./scripts/run-python3.ts ./scripts/install.py",
"install": "tsx ./scripts/run-python3.ts ./scripts/install.py",
"prepare": "tsx ./scripts/run-python3.ts ./scripts/prepare.py",
"regenerate": "tsx ./scripts/eng/regenerate.ts",
"test": "tsx ./scripts/eng/run-tests.ts"
},
"files": [
"dist/**",
"!dist/test/**",
"scripts/**"
"scripts/**",
"generator/**"
],
"peerDependencies": {
"@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0",
Expand All @@ -51,7 +52,6 @@
"@azure-tools/typespec-azure-rulesets": ">=0.46.0 <3.0.0",
"@typespec/compiler": ">=0.60.0 <1.0.0",
"@typespec/http": ">=0.60.0 <1.0.0",
"@typespec/http-client-python": ">=0.2.0 <1.0.0",
"@typespec/rest": ">=0.60.0 <1.0.0",
"@typespec/versioning": ">=0.60.0 <1.0.0",
"@typespec/openapi": ">=0.60.0 <1.0.0"
Expand All @@ -61,6 +61,7 @@
"@typespec/openapi3": "~0.60.0",
"semver": "~7.6.2",
"tsx": "4.17.0",
"@typespec/http-client-python": "0.2.0",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand All @@ -87,7 +88,6 @@
"@azure-tools/typespec-azure-rulesets": "~0.46.0",
"yargs": "~17.7.2",
"chalk": "5.3.0",
"@typespec/http-client-python": "~0.2.0",
"@types/fs-extra": "11.0.4"
}
}
26 changes: 0 additions & 26 deletions packages/typespec-python/scripts/copy-scripts.ts

This file was deleted.

18 changes: 17 additions & 1 deletion packages/typespec-python/scripts/eng/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { runCommand, executeCommand } from "./utils.js";
import fs from "fs";
import path from "path";

interface Arguments {
folderName: string;
Expand Down Expand Up @@ -40,9 +42,23 @@ const argv = yargs(hideBin(process.argv))
export function pylint() {
runCommand(`pylint ${argv.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
}
function checkPythonFile(directory: string): boolean {
const files = fs.readdirSync(directory);
for (let i = 0; i < files.length; i++) {
if (path.extname(files[i]) === ".py") {
return true;
}
}
return false;
}

export function mypy() {
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
if (checkPythonFile(argv.folderName)) {
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
} else {
console.log("No python file found in the directory");
console.log("mypy passed");
}
}

export function pyright() {
Expand Down
1 change: 0 additions & 1 deletion packages/typespec-python/scripts/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def main():

python_run(venv_context, "pip", ["install", "-U", "pip"])
python_run(venv_context, "pip", ["install", "-r", f"{_ROOT_DIR}/generator/requirements.txt"])
python_run(venv_context, "pip", ["install", "-e", f"{_ROOT_DIR}/generator"])


if __name__ == "__main__":
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 27b6ecd

Please sign in to comment.