Skip to content

Commit

Permalink
docs: Advise on virtual environment usage
Browse files Browse the repository at this point in the history
Advise to use Tox rather than pipenv virtual environment.
  • Loading branch information
jainvikas8 authored and Patater committed Oct 12, 2020
1 parent 2a87da2 commit 08f8b67
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contribution Guide

Mbed OS is an open source project and we really appreciate your contributions to the tools. We are committed to
Mbed OS is an open source project and we really appreciate your contributions to the tools. We are committed to
fostering a welcoming community, please see our Code of Conduct, which can be found here:

- [Code of Conduct](./CODE_OF_CONDUCT.md)
Expand Down Expand Up @@ -63,13 +63,13 @@ The `pre-commit` tool allows developers to easily install git hook scripts which
must pass in our CI before a PR is merged. Using commit hooks ensures you can't commit code which violates our style
and maintainability requirements.

To install the commit hooks for the repository, run:
To install the commit hooks for the repository (assuming you have activated your development environment as described in [the development guide](./DEVELOPMENT.md)), run:

```bash
$ pipenv install --dev
$ pipenv shell
$ pre-commit install
```
Our code checks and unit tests will now run automatically every time you try to `git commit` to the repository.
Our code checks will now run automatically every time you try to `git commit` to the repository.

If you prefer not to install the hook scripts, you can use
```bash
$ pre-commit run
Expand Down
28 changes: 10 additions & 18 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Development and Testing

For development and testing purposes, it is essential to use a virtual environment. It is recommended that `pipenv >= 2018.11.26` is used.
For development and testing purposes, it is essential to use a virtual environment.

## Setup Python and Pipenv
## Setup Python and tox

`mbed-tools` is compatible with Python 3.6 or later.

Expand All @@ -16,16 +16,16 @@ Below are links to guides for correctly setting up a development ready version o

On Windows we have also found the [Python Launcher for Windows](https://docs.python.org/3/using/windows.html) to be a reasonable alternative.

After you have set up your Python 3 installation, install pipenv (the `--user` flag is important **never use `sudo` to install Python packages!**)
After you have set up your Python 3 installation, install tox (the `--user` flag is important **never use `sudo` to install Python packages!**)

```bash
pip install --user pipenv
python(3) -m pip install --user tox
```

Check that pipenv is in the binary path
Check that tox is in the binary path

```bash
pipenv --version
tox --version
```

If not, find the user base binary directory
Expand All @@ -49,25 +49,17 @@ Clone the `mbed-tools` GitHub repository
git clone git@github.com:ARMmbed/mbed-tools.git
```

Setup Pipenv to use Python 3 and install package development dependencies:
Set up the development environment using tox (tox will create a development environment at mbed-tools/.venv):

```bash
cd mbed-tools/
pipenv --three
pipenv install --dev --skip-lock
tox -e dev
source .venv/bin/activate
```

You may omit the `--skip-lock` flag. Note creating the `Pipfile.lock` can take a long time!

## Unit Tests, Code Formatting and Static Analysis

Shell into the virtual environment you have just created:

```bash
pipenv shell
```

Run `pre-commit` to run unit tests and static code analysis checks:
After you have activated your development environment, run `pre-commit` to run unit tests and static code analysis checks:

```bash
pre-commit run --all-files
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The version scheme used follows [PEP440](https://www.python.org/dev/peps/pep-044

- `<major>.<minor>.<patch>`

Beta releases are used to give early access to new functionality, for testing and to get feedback on experimental
Beta releases are used to give early access to new functionality, for testing and to get feedback on experimental
features. As such these releases may not be stable and should not be used for production. Additionally any interfaces
introduced in a beta release may be removed or changed without notice. For **beta** releases the version will look as
follows:
Expand All @@ -48,8 +48,7 @@ follows:

## Installation

It is recommended that a virtual environment such as [Pipenv](https://github.com/pypa/pipenv/blob/master/README.md) is
used for all installations to avoid Python dependency conflicts.
We recommend installing `mbed-tools` in a Python virtual environment to avoid dependency conflicts.

To install the most recent production quality release use:

Expand Down
2 changes: 1 addition & 1 deletion docs/howto/mbed-tools-howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You'll still need Mbed CLI for older versions of Mbed OS. You can install both t

Mbed Tools is Python based, so you can install it with pip.

**Tip:** We recommend using a virtual environment such as [Pipenv](https://github.com/pypa/pipenv/blob/master/README.md) to avoid Python dependency conflicts.
**Tip:** We recommend using a virtual environment to avoid Python dependency conflicts.

## Prerequisite

Expand Down
1 change: 1 addition & 0 deletions news/202010091700.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Advise on using Tox rather than pipenv virtual environment

0 comments on commit 08f8b67

Please sign in to comment.