Skip to content

Commit

Permalink
feat(cli): change virtualenv directory to .venv to comply with python…
Browse files Browse the repository at this point in the history
… recommendation
  • Loading branch information
AnderEnder committed Oct 20, 2020
1 parent 585920e commit d5481e0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/aws-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ $ # List the available template types & languages
$ cdk init --list
Available templates:
* app: Template for a CDK Application
└─ cdk init app --language=[java|typescript]
└─ cdk init app --language=[csharp|fsharp|java|javascript|python|typescript]
* lib: Template for a CDK Construct Library
└─ cdk init lib --language=typescript
* sample-app: Example CDK Application with some constructs
└─ cdk init sample-app --language=[csharp|fsharp|java|javascript|python|typescript]

$ # Create a new library application in typescript
$ cdk init lib --language=typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ you can create the virtualenv manually.
To manually create a virtualenv on MacOS and Linux:

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

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

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

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

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

Once the virtualenv is activated, you can install the required dependencies.
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk/lib/init-templates/app/python/source.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

rem The sole purpose of this script is to make the command
rem
rem source .env/bin/activate
rem source .venv/bin/activate
rem
rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
rem On Windows, this command just runs this batch file (the argument is ignored).
rem
rem Now we don't need to document a Windows command for activating a virtualenv.

echo Executing .env\Scripts\activate.bat for you
.env\Scripts\activate.bat
echo Executing .venv\Scripts\activate.bat for you
.venv\Scripts\activate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic.
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. To create the virtualenv
a virtualenv within this project, stored under the .venv 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.

To manually create a virtualenv on MacOS and Linux:

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

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

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

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

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

Once the virtualenv is activated, you can install the required dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

rem The sole purpose of this script is to make the command
rem
rem source .env/bin/activate
rem source .venv/bin/activate
rem
rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
rem On Windows, this command just runs this batch file (the argument is ignored).
rem
rem Now we don't need to document a Windows command for activating a virtualenv.

echo Executing .env\Scripts\activate.bat for you
.env\Scripts\activate.bat
echo Executing .venv\Scripts\activate.bat for you
.venv\Scripts\activate.bat
6 changes: 3 additions & 3 deletions packages/aws-cdk/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ async function postInstallJava(canUseNetwork: boolean, cwd: string) {

async function postInstallPython(cwd: string) {
const python = pythonExecutable();
warning(`Please run '${python} -m venv .env'!`);
warning(`Please run '${python} -m venv .venv'!`);
print(`Executing ${colors.green('Creating virtualenv...')}`);
try {
await execute(python, ['-m venv', '.env'], { cwd });
await execute(python, ['-m venv', '.venv'], { cwd });
} catch (e) {
warning('Unable to create virtualenv automatically');
warning(`Please run '${python} -m venv .env'!`);
warning(`Please run '${python} -m venv .venv'!`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/integ/init/test-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ for template in $templates; do

cdk init -l python $template

source .env/bin/activate
source .venv/bin/activate
type -p pip
pip install -r requirements.txt

Expand Down

0 comments on commit d5481e0

Please sign in to comment.