Skip to content

Commit aad1219

Browse files
authored
Merge pull request #580 from fdiasdev/contributing-using-virtualenv
Add Env setup documentation in CONTRIBUTING
2 parents 91ff185 + ab09f9f commit aad1219

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

CONTRIBUTING.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,37 @@ $ git push origin [name_of_your_new_branch]
180180

181181

182182
### Setting up for cmd2 development
183-
For doing cmd2 development, you actually do NOT want to have cmd2 installed as a Python package.
184-
So if you have previously installed cmd2, make sure to uninstall it:
183+
For doing cmd2 development, it is recommended you create a virutal environment using Conda or Virtualenv and install the package from the source.
184+
185+
#### Create a new environment for cmd2 using Conda
185186
```sh
186-
$ pip uninstall cmd2
187+
$ conda create -n cmd2_py36 python=3.6
188+
$ conda activate cmd2
187189
```
188190

189-
Assuming you cloned the repository to `~/src/cmd2`:
191+
#### Create a new environment for cmd using Virtualenv
192+
We recommend that you use [pyenv](https://github.com/pyenv/pyenv) to manage your installed python versions.
193+
194+
```sh
195+
# Check pyenv versions installed
196+
pyenv versions
197+
198+
# Install python version defined
199+
pyenv install 3.6.3
200+
```
201+
With the Python version installed, you can set the virutalenv properly.
202+
190203
```sh
191204
$ cd ~/src/cmd2
192-
$ pip install -e .
205+
$ virtualenv -p $(pyenv root)/versions/3.6.3/ cmd_py36
206+
$ source ~/src/cmd2/bin/activate
193207
```
194-
will install cmd2 in [editable mode](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs).
208+
209+
Assuming you cloned the repository to `~/src/cmd2` you can install cmd2 in
210+
[editable mode](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs).
195211
Changes to the source code are immediately available when the python interpreter
196212
imports `cmd2`, there is no need to re-install the module after every change. This
197-
command will also install all of the runtime dependencies for `cmd2`.
198-
199-
Next you should install all the modules used for development of `cmd2`:
213+
command will also install all of the runtime dependencies for `cmd2` and modules used for development of `cmd2`:
200214
```sh
201215
$ cd ~/src/cmd2
202216
$ pip install -e .[dev]
@@ -229,11 +243,17 @@ have a look at `tasks.py`.
229243
Now you can check if everything is installed and working:
230244
```sh
231245
$ cd ~src/cmd2
246+
$ invoke pytest
247+
```
248+
249+
If the tests are executed it means that dependencies and project are installed succesfully.
250+
251+
You can also run the example app and see a prompt that says "(Cmd)" running the command:
252+
```sh
232253
$ python examples/example.py
233254
```
234255

235-
If the example app loads, you should see a prompt that says "(Cmd)". You can
236-
type `help` to get help or `quit` to quit. If you see that, then congratulations
256+
You can type `help` to get help or `quit` to quit. If you see that, then congratulations
237257
– you're all set. Otherwise, refer to the cmd2 [installation instructions](https://cmd2.readthedocs.io/en/latest/install.html#installing).
238258
There also might be an error in the console of your Bash / terminal / command line
239259
that will help identify the problem.

0 commit comments

Comments
 (0)