Skip to content

Commit

Permalink
Update configuring_your_machine.md and launch.json (#6205)
Browse files Browse the repository at this point in the history
* Update configuring_your_machine.md

* More update

* Address PR comment
  • Loading branch information
Ernest Wong authored and derekbekoe committed Apr 25, 2018
1 parent 979854e commit 5d46afc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 48 deletions.
36 changes: 10 additions & 26 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Integrated Terminal/Console",
"name": "Azure CLI Debug (Integrated Console)",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
Expand All @@ -19,54 +19,38 @@
]
},
{
"name": "Scripts",
"name": "Azure CLI Debug (External Console)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/tools/automation/__main__.py",
"program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
"-h"
"--help"
],
"console": "integratedTerminal",
"console": "externalTerminal",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
"WaitOnNormalExit"
]
},
{
"name": "Azure CLI Tests",
"name": "Azdev Scripts",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/tools/automation/tests/run.py",
"program": "${workspaceRoot}/tools/automation/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
"--help"
],
"console": "integratedTerminal",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "External Terminal/Console",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
"--help"
],
"console": "externalTerminal",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
}
]
}
52 changes: 30 additions & 22 deletions doc/configuring_your_machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/
- Create pull requests against the https://github.com/azure/azure-cli repository to get your code changes merged into the project repository.

## Preparing your machine
1. Install Python 3.5.x from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7.
2. Clone your repository and check out the master branch.
3. Create a new virtual environment “env” for Python 3.5 in the root of your clone. You can do this by running:
1. Install Python 3.5.x or higher from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7.
2. Clone your repository and check out the [`dev`](https://github.com/Azure/azure-cli/tree/dev) branch.
3. Create a new virtual environment “env” for Python in the root of your clone. You can do this by running:

#### Windows
```BatchFile
Expand All @@ -18,7 +18,7 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/
```Shell
python -m venv <clone root>/env
```
4. Activate the env virtual environment by running:
4. Activate the env virtual environment by running:

#### Windows
```BatchFile
Expand All @@ -29,11 +29,11 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/
. <clone root>/env/bin/activate
```

5. Install the dependencies and load the command modules as local packages using pip.
5. Install the dependencies and load the command modules as local packages using pip.
```Shell
python scripts/dev_setup.py
```
6. Add `<clone root>\src` to your PYTHONPATH environment variable:
6. Add `<clone root>\src` to your PYTHONPATH environment variable:

#### Windows
```BatchFile
Expand All @@ -43,7 +43,7 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/
```Shell
export PYTHONPATH=<clone root>/src:${PYTHONPATH}
```
7. Setup tab completion (OSX/Ubuntu ONLY).
7. Setup tab completion (OSX/Ubuntu ONLY).

Open Bash or zsh window and run:

Expand All @@ -53,22 +53,23 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/

## Configuring your IDE
#### Visual Studio (Windows only)
1. Install Python Tools for Visual Studio. As of 2/18/2016, the current version (PTVS 2.2) can be found at http://microsoft.github.io/PTVS/.
2. Open the azure-cli.pyproj project
1. Install Python Tools for Visual Studio. As of 2/18/2016, the current version (PTVS 2.2) can be found at http://microsoft.github.io/PTVS/.
2. Open the `azure-cli.pyproj` project
You should now be able to launch your project by pressing F5/start debugging

#### Visual Studio Code (Any platform)
Experimental steps – still haven’t been able to get virtual environments to work well with VSCode

1. Install VS Code
2. Install (one of) the python extension(s) (https://marketplace.visualstudio.com/items?itemName=donjayamanne.python)
Debugging should now work (including stepping and setting breakpoints).
1. Install VS Code
2. Install (one of) the python extension(s) (https://marketplace.visualstudio.com/items?itemName=donjayamanne.python)
3. Put [breakpoints](https://code.visualstudio.com/docs/editor/debugging#_breakpoints) in your code, then click on the Debug icon in the Activity Bar on the side of Visual Studio Code, and select `Azure CLI Debug` from the drop down menu. After that, press the play button to start debugging.
4. To add custom arguments to the command that you want to debug, press the gear icon beside the drop down menu and modify the `args` field in `launch.json`

The repo has a launch.json file that will launch the version of Python that is first on your path.
The repo has a `launch.json` file that will launch the version of Python that is first on your path.

## Running CLI
#### Command line
1. Activate your virtual environment if not already done
1. Activate your virtual environment if not already done:

#### OSX/Ubuntu (bash):
```Shell
Expand All @@ -80,32 +81,39 @@ The repo has a launch.json file that will launch the version of Python that is f
<clone root>\env\scripts\activate.bat
```

2. Invoke the CLI using:
2. Invoke the CLI using:

#### Windows/OSX/Ubuntu:
```
az
```

## Running Tests:
## Running Tests and Checking Code Style
#### Command line
Running the `dev_setup.py` file installed the test and style check scripts into the `tools` directory under your
`<clone root>` directory and added them into the current virtualenv.
Running the `dev_setup.py` file will install `azdev`, a CLI that performs useful tasks for Azure CLI developers such as executing CLI tests, CLI linter, and style checking.

##### Windows/OSX/Ubuntu:

For a list of available `azdev` commands:
```
azdev --help
```

To run the CLI tests:
```
run_tests [-h] [--module MODULES [MODULES ...]] [--parallel] [--live] [--test TESTS]
azdev test [-h] [--series] [--live] [--src-file SRC_FILE]
[--dest-file DEST_FILE] [--ci] [--discover]
[--profile PROFILE]
[tests [tests ...]]
```

To check the CLI and command modules for style errors:
```
check_style [-h] [--ci] [--pep8] [--pylint] [--module MODULES]
azdev style [-h] [--ci] [--pep8] [--pylint] [--module MODULES]
```

#### VS Code
Under construction...
#### Visual Studio Code
Click on the Debug icon in the Activity Bar on the side of Visual Studio Code, and select `Azdev Scripts` from the drop down menu. To execute `azdev` commands via Visual Studio Code, you will need to press the gear icon beside the drop down menu and modify the `args` field in `launch.json`. Make sure that any modification of `launch.json` is not included in your pull requests.

#### Visual Studio
Select `Test > Windows > Test Explorer` and click `Run All` in the Test Explorer pane.

0 comments on commit 5d46afc

Please sign in to comment.