Skip to content

Commit

Permalink
Fixing issues aws#2180 and aws#2183 related to Python init templates (a…
Browse files Browse the repository at this point in the history
…ws#2189)

* Fixing issues aws#2180 and aws#2183 related to Python init templates

* Add some instructions for manually creating a virtualenv
  • Loading branch information
garnaat authored Apr 7, 2019
1 parent 6728b41 commit 17ba29a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 10 deletions.
31 changes: 29 additions & 2 deletions packages/aws-cdk/lib/init-templates/app/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,39 @@ This is a blank project for Python development with CDK.
The `cdk.json` file tells the CDK Toolkit how to execute your app.

This project is set up like a standard Python project. The initialization process also creates
a virtualenv within this project, stored under the .env directory.
a virtualenv within this project, stored under the .env directory. To create the virtualenv
it assumes that there is a `python3` executable in your path with access to the `venv` package.
If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv
manually once the init process completes.

After the init process completes, you can use the following steps to get your project set up.
To manually create a virtualenv on MacOS and Linux:

```
$ python3 -m venv .env
```

For Windows, use:

```
% python -m venv .env
```

After the init process completes and the virtualenv is created, you can use the following
step to activate your virtualenv.

```
$ source .env/bin/activate
```

If you are a Windows platform, you would activate the virtualenv like this:

```
% .env\Scripts\activate.bat
```

Once the virtualenv is activated, you can install the required dependencies.

```
$ pip install -r requirements.txt
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from aws_cdk import cdk

from %name%.%name%_stack import PyStack
from %name.PythonModule%.%name.PythonModule%_stack import %name.PascalCased%Stack


app = cdk.App()
PyStack(app, "%name%-cdk-1")
%name.PascalCased%Stack(app, "%name%-cdk-1")

app.run()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


setuptools.setup(
name="%name%",
name="%name.PythonModule%",
version="0.0.1",

description="An empty CDK Python app",
Expand All @@ -15,8 +15,8 @@

author="author",

package_dir={"": "%name%"},
packages=setuptools.find_packages(where="%name%"),
package_dir={"": "%name.PythonModule%"},
packages=setuptools.find_packages(where="%name.PythonModule%"),

install_requires=[
"aws-cdk.cdk",
Expand Down
31 changes: 29 additions & 2 deletions packages/aws-cdk/lib/init-templates/sample-app/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,39 @@ a stack (`HelloStack`) which also uses a user-defined construct (`HelloConstruct
The `cdk.json` file tells the CDK Toolkit how to execute your app.

This project is set up like a standard Python project. The initialization process also creates
a virtualenv within this project, stored under the .env directory.
a virtualenv within this project, stored under the .env directory. To create the virtualenv
it assumes that there is a `python3` executable in your path with access to the `venv` package.
If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv
manually once the init process completes.

After the init process completes, you can use the following steps to get your project set up.
To manually create a virtualenv on MacOS and Linux:

```
$ python3 -m venv .env
```

For Windows, use:

```
% python -m venv .env
```

After the init process completes and the virtualenv is created, you can use the following
step to activate your virtualenv.

```
$ source .env/bin/activate
```

If you are a Windows platform, you would activate the virtualenv like this:

```
% .env\Scripts\activate.bat
```

Once the virtualenv is activated, you can install the required dependencies.

```
$ pip install -r requirements.txt
```

Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export class InitTemplate {
.replace(/%name\.camelCased%/g, camelCase(project.name))
.replace(/%name\.PascalCased%/g, camelCase(project.name, { pascalCase: true }))
.replace(/%cdk-version%/g, cdkVersion)
.replace(/%cdk-home%/g, CDK_HOME);
.replace(/%cdk-home%/g, CDK_HOME)
.replace(/%name\.PythonModule%/g, project.name.replace(/-/g, '_'));
}
}

Expand Down

0 comments on commit 17ba29a

Please sign in to comment.