Skip to content

Commit

Permalink
docs(examples/python-app): fixes for python example
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Aug 14, 2022
1 parent 3c2a1bb commit db8bdb8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ new JsonFile(project, '.vscode/settings.json', {
'[svg]': {
'editor.defaultFormatter': 'jock.svg',
},
'python.formatting.provider': 'black',
},
});

Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions examples/python-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ All interfaces are available, but the esbuild binary must be available in path,

To set up a new virtualenv, run

```
$ python3 -m venv .venv
```bash
python3 -m venv .venv
```

Then activate the venv and install all dependencies:

```
$ source .venv/bin/activate
$ pip install -r requirements.txt
$ npm install --location=global esbuild
```bash
source .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt
npm install -g esbuild
```

Finally run the CDK app:
Run the CDK app providing the `CDK_ESBUILD_MODULE_PATH`:

```bash
CDK_ESBUILD_MODULE_PATH="$(npm prefix -g)/lib/node_modules/esbuild" cdk synth
```
$ cdk synth
```
9 changes: 8 additions & 1 deletion examples/python-app/python_app/python_app_stack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from aws_cdk import Stack
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_s3 as s3
Expand All @@ -19,7 +20,10 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
self,
"Website",
sources=[
TypeScriptSource("lambda-handler/index.ts", copy_dir="lambda-handler")
TypeScriptSource(
"lambda-handler/index.ts",
copy_dir="lambda-handler",
)
],
destination_bucket=s3.Bucket(
self,
Expand All @@ -37,6 +41,9 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
build_options=BuildOptions(
format="esm", outfile="index.mjs", external=["aws-sdk"]
),
# Override the global setting with a specific path per Construct
# This can be useful if a Construct requires a different version of esbuild
esbuild_module_path="/project/node_modules/esbuild@13",
),
)

Expand Down
1 change: 1 addition & 0 deletions examples/python-app/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest==6.2.5
black>=22.6.0
4 changes: 2 additions & 2 deletions examples/python-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aws-cdk-lib==2.27.0
aws-cdk-lib==2.37.1
constructs>=10.0.0,<11.0.0
mrgrain.cdk-esbuild>=4.0.0
mrgrain.cdk-esbuild>=3.10.0

0 comments on commit db8bdb8

Please sign in to comment.