Skip to content

Commit

Permalink
[python] catch ModuleNotFoundError (#5853)
Browse files Browse the repository at this point in the history
fixes #5829

---------

Co-authored-by: iscai-msft <[email protected]>
  • Loading branch information
iscai-msft and iscai-msft authored Feb 4, 2025
1 parent acceccf commit 29fbfec
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/python-pyodideLogging-2025-1-4-14-27-40.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

Improve logging by catching expected `ModuleNotFoundError`
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

try:
import pip
except ImportError:
except (ImportError, ModuleNotFoundError):
raise Exception("Your Python installation doesn't have pip available")


Expand Down
4 changes: 2 additions & 2 deletions packages/http-client-python/eng/scripts/setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

try:
import pip
except ImportError:
except (ImportError, ModuleNotFoundError):
raise Warning(
"Your Python installation doesn't have pip available. We will run your code with Pyodide since your Python version isn't adequate."
)

try:
import venv
except ImportError:
except (ImportError, ModuleNotFoundError):
raise Warning(
"Your Python installation doesn't have venv available. We will run your code with Pyodide since your Python version isn't adequate."
)
Expand Down
2 changes: 1 addition & 1 deletion packages/http-client-python/eng/scripts/setup/run_tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if "--debug" in sys.argv or "--debug=true" in sys.argv:
try:
import debugpy # pylint: disable=import-outside-toplevel
except ImportError:
except (ImportError, ModuleNotFoundError):
raise SystemExit("Please pip install ptvsd in order to use VSCode debugging")

# 5678 is the default attach port in the VS Code debug configurations
Expand Down
36 changes: 18 additions & 18 deletions packages/http-client-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,44 @@
"emitter"
],
"peerDependencies": {
"@typespec/compiler": ">=0.64.0 <1.0.0",
"@typespec/http": ">=0.64.0 <1.0.0",
"@typespec/rest": ">=0.64.0 <1.0.0",
"@typespec/versioning": ">=0.64.0 <1.0.0",
"@typespec/openapi": ">=0.64.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.50.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.50.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.50.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.50.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.50.0 <3.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.50.2 <1.0.0"
"@azure-tools/typespec-client-generator-core": ">=0.50.2 <1.0.0",
"@typespec/compiler": ">=0.64.0 <1.0.0",
"@typespec/http": ">=0.64.0 <1.0.0",
"@typespec/openapi": ">=0.64.0 <1.0.0",
"@typespec/rest": ">=0.64.0 <1.0.0",
"@typespec/versioning": ">=0.64.0 <1.0.0"
},
"dependencies": {
"js-yaml": "~4.1.0",
"pyodide": "0.26.2",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"pyodide": "0.26.2"
"tsx": "~4.19.1"
},
"devDependencies": {
"@typespec/compiler": "~0.64.0",
"@typespec/versioning": "~0.64.0",
"@typespec/openapi": "~0.64.0",
"@typespec/http": "~0.64.0",
"@typespec/rest": "~0.64.0",
"@azure-tools/azure-http-specs": "0.1.0-alpha.5",
"@azure-tools/typespec-autorest": "~0.50.0",
"@azure-tools/typespec-azure-core": "~0.50.0",
"@azure-tools/typespec-azure-rulesets": "~0.50.0",
"@azure-tools/typespec-azure-resource-manager": "~0.50.0",
"@azure-tools/typespec-azure-rulesets": "~0.50.0",
"@azure-tools/typespec-client-generator-core": "~0.50.2",
"@azure-tools/azure-http-specs": "0.1.0-alpha.5",
"@typespec/http-specs": "0.1.0-alpha.7",
"@types/js-yaml": "~4.0.5",
"@types/node": "~22.5.4",
"@types/semver": "7.5.8",
"@typespec/compiler": "~0.64.0",
"@typespec/http": "~0.64.0",
"@typespec/http-specs": "0.1.0-alpha.7",
"@typespec/openapi": "~0.64.0",
"@typespec/rest": "~0.64.0",
"@typespec/versioning": "~0.64.0",
"c8": "^10.1.2",
"chalk": "5.3.0",
"rimraf": "~6.0.1",
"typescript": "~5.6.3",
"typescript-eslint": "^8.8.1",
"chalk": "5.3.0",
"vitest": "^2.1.2"
}
}

0 comments on commit 29fbfec

Please sign in to comment.