-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typespec and autorest.python working with vendored pygen
- Loading branch information
iscai-msft
committed
May 16, 2024
1 parent
ead7533
commit 2bbe3ed
Showing
19 changed files
with
317 additions
and
275 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
|
||
// Define the source and destination directories | ||
const sourceDir = path.join(__dirname, "..", "..", 'pygen'); | ||
const destDir = path.join(__dirname, "..", "node_modules", "pygen"); | ||
|
||
// Define the filter function. Don't want to copy node_modules | ||
const filterFunc = (src) => { | ||
return src.indexOf('node_modules') === -1; | ||
}; | ||
|
||
// Copy the source directory to the destination directory | ||
fs.copySync(sourceDir, destDir, { filter: filterFunc }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
|
||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
import sys | ||
|
||
if not sys.version_info >= (3, 8, 0): | ||
raise Exception("Autorest for Python extension requires Python 3.8 at least") | ||
|
||
try: | ||
import pip | ||
except ImportError: | ||
raise Exception("Your Python installation doesn't have pip available") | ||
|
||
try: | ||
import venv | ||
except ImportError: | ||
raise Exception("Your Python installation doesn't have venv available") | ||
|
||
|
||
# Now we have pip and Py >= 3.8, go to work | ||
|
||
from pathlib import Path | ||
import shutil | ||
|
||
from venvtools import python_run | ||
|
||
_ROOT_DIR = Path(__file__).parent.parent | ||
|
||
|
||
def ignore_node_modules(dirname, filenames): | ||
return ["node_modules"] if "node_modules" in filenames else [] | ||
|
||
|
||
def main(): | ||
# Define the source and destination directories | ||
source_dir = _ROOT_DIR.parent / "pygen" | ||
dest_dir = _ROOT_DIR / "node_modules" / "pygen" | ||
|
||
# Copy the source directory to the destination directory | ||
shutil.copytree(source_dir, dest_dir, dirs_exist_ok=True, ignore=ignore_node_modules) | ||
|
||
# we use pygen's venv | ||
venv_path = dest_dir / "venv" | ||
assert venv_path.exists() # Otherwise install was not done | ||
|
||
env_builder = venv.EnvBuilder(with_pip=True) | ||
venv_context = env_builder.ensure_directories(venv_path) | ||
# install autorest.python specific stuff into it | ||
python_run(venv_context, "pip", ["install", "-r", "requirements.txt"]) | ||
python_run(venv_context, "pip", ["install", "-e", str(_ROOT_DIR)]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-e . | ||
-r ../../eng/requirements.txt | ||
-r ../../eng/dev_requirements.txt | ||
-r ../../../../eng/requirements.txt | ||
-r ../../../../eng/dev_requirements.txt | ||
ptvsd==4.3.2 | ||
types-PyYAML==6.0.12.8 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.