-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install pydantic and orjson with pip
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
- Loading branch information
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
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,23 @@ | ||
import subprocess | ||
import sys | ||
import shutil | ||
import glob | ||
from pathlib import Path | ||
|
||
def install_dependencies(libsPath): | ||
# Delete folders that start with "pydantic" which was installed by FASTAPI during the extension build process | ||
for folder in glob.glob(f"{libsPath}/pydantic*"): | ||
shutil.rmtree(folder, ignore_errors=True) | ||
|
||
try: | ||
import pydantic | ||
import orjson | ||
except ImportError: | ||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'pydantic', 'orjson', '-t', Path(libsPath), '--no-cache-dir']) | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
libsPath = sys.argv[1] | ||
else: | ||
libsPath = None | ||
install_dependencies(libsPath) |
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,21 @@ | ||
import * as cp from 'child_process'; | ||
import { getInterpreterDetails } from './python'; | ||
|
||
export async function installPythonDependencies(context: any): Promise<void> { | ||
return new Promise<void>(async (resolve, reject) => { | ||
const script = context.asAbsolutePath('bundled/tool/install_dependencies.py'); | ||
const interpreterDetails = await getInterpreterDetails(); | ||
const pythonPath = interpreterDetails['path'] && interpreterDetails['path'][0]; | ||
const libsPath = context.asAbsolutePath('bundled/libs'); | ||
|
||
cp.exec(`${pythonPath} ${script} ${libsPath}`, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(stderr); | ||
reject(error); | ||
} else { | ||
console.log(stdout); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} |
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