-
Notifications
You must be signed in to change notification settings - Fork 19
Development Environment Setup
This is a guide for setting up an environment for effectively contributing to the nexpose-client-python library. If you just want to use the library for automating or interacting with Nexpose, we recommend you follow one of the getting started guides: Ubuntu, Windows, macOS.
You'll need at least one version of Python installed on your system in order to effectively work with the project. Generally Linux and macOS users will already have a Python version installed. Depending on the Linux distribution or macOS version, the default Python installation could be version 2.5, 2.6, or 2.7. Windows users will need to download and install Python for Windows.
Currently Python 2.6 and 2.7 are supported, and Python 3 support is coming soon which will include versions 3.4, 3.5, and 3.6.
You can check your installed Python version with the python --version command. You can also use python2 --version and python3 --version as python is generally linked to either python2 or python3, but not both.
Shortcuts:
Newer versions of Ubuntu Linux should have both Python 2.7 and a 3.x version installed out of the box. You may still need some additional packages installed.
For Python 2.x:
sudo apt-get update
sudo apt-get install python-pip python-virtualenv python-dev libxml2-dev libxslt1-dev
For Python 3.x, install these additional packages:
sudo apt-get install python3 python3-pip build-dep python3-lxml
Using a tool like pyenv you can install and manage many different versions of Python. Combined with penv-virtualenv it's a convenient way to keep your Python projects isolated. You can install it with pyenv-installer.
Install from Github:
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
After restarting your shell with exec "$SHELL" or opening a new terminal, you can now install some Python versions:
pyenv install 2.7.13
pyenv install 3.6.3
Use pyenv install -l to list available versions to be installed.
Finally, create some virtualenvs for development:
pyenv virtualenv 2.7.13 nexpose-py27
pyenv virtualenv 3.6.3 nexpose-py36
To use a virtualenv, activate it with pyenv activate nexpose-py27.
macOS should have a fairly recent version of Python installed, such as 2.7.10. This should be sufficient for the most part. Using Virtualenv to isolate project dependencies will be helpful, and can be installed with either pip or Homebrew
Using a tool like pyenv you can install and manage many different versions of Python. Combined with penv-virtualenv it's a convenient way to keep your Python projects isolated. You can install it with Homebrew (recommended) or pyenv-installer.
Using Homebrew:
brew update
brew install pyenv pyenv-virtualenv
Next, add pyenv init to your shell:
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
Replace .bash_profile with .zshenv or .zshrc if you use the zsh shell. For other shells, choose the appropriate profile/env/rc file.
After restarting your shell with exec "$SHELL" or opening a new terminal, you can now install some Python versions:
pyenv install 2.7.13
pyenv install 3.6.3
Use pyenv install -l to list available versions to be installed.
Finally, create some virtualenvs for development:
pyenv virtualenv 2.7.13 nexpose-py27
pyenv virtualenv 3.6.3 nexpose-py36
To use a virtualenv, activate it with pyenv activate nexpose-py27.
Download and install Python 2.7 for Windows from the official Python website. Optionally you can also install the latest Python 3 version. Having both installed side-by-side is supported and the Python 3 installer provides a Python launcher application to help manage your Python versions. See the official guide for more information.
-
Fork the repository.
-
Create a directory somewhere to use as a workspace
-
Clone your fork:
git clone https://github.com/<youruser>/nexpose-client-python.git <path/to/workspace>` -
Create a Python Virtualenv and then activate it
With pyenv:
pyenv virtualenv 2.7.13 nexpose-py27 activate nexpose-py27Without pyenv:
virtualenv nexpose-python source nexpose-python/bin/activate -
Install project dependencies
pip install -r requirements.txt pip install -r requirements_dev.txt
Give it a test run to make sure everything is working for you:
py.test -v tests
There are plenty of programming-focused text editors and Python-focused IDEs to choose from. Here are some suggestions if you don't already have one:
| Name | Type | Setup Guide |
|---|---|---|
| Visual Studio Code | Text Editor | |
| Atom | Text Editor | |
| Sublime Text | Text Editor | |
| PyCharm | IDE | |
| WingIDE | IDE | |
| PyScripter | IDE |