Skip to content

Commit 0b795c0

Browse files
committed
Adds "Deploying a Script" to guide docs
The new section discusses how to use virtualenvwrapper to control dronekit versioning and deal with deployment. It does not address Windows because virtualenvwrapper does not easily work on Windows. A later commit can address usage on Windows using only virtualenv.
1 parent 33584e9 commit 0b795c0

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

docs/guide/deploying-scripts.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. _deploying-scripts:
2+
3+
==================
4+
Deploying a Script
5+
==================
6+
7+
Because DroneKit-Python is still under heavy development, you may find it beneficial to control which version you are using and have a plan for deployment.
8+
9+
This section includes some tips for using `virtualenvwrapper <https://virtualenvwrapper.readthedocs.org/en/latest/>`_ (an extension of `virtualenv <https://virtualenv.readthedocs.org/en/latest/>`_) to manage versioning and deployment.
10+
11+
12+
13+
Installing virtualenvwrapper
14+
============================
15+
16+
First, please follow the instructions for installing DroneKit-Python on your platform of choice under the section :ref:`getting_started_installing_dronekit` in :ref:`get-started`:
17+
18+
* :ref:`getting_started_installing_dronekit_linux`
19+
* :ref:`getting_started_installing_dronekit_mac`
20+
21+
.. note::
22+
23+
virtualenvwrapper uses functionality specific to bash, a shell commonly used in Linux and Mac. To follow this guide on Windows you can use `cygwin <https://www.cygwin.com/>`_ or `look here for more information <http://stackoverflow.com/questions/2615968/installing-virtualenvwrapper-on-windows>`_.
24+
25+
After you have installed **pip** you can install virtualenvwrapper and its dependencies.
26+
27+
.. code-block:: bash
28+
29+
sudo pip install virtualenvwrapper
30+
31+
Then, place
32+
33+
.. code-block:: bash
34+
35+
source $(which virtualenvwrapper.sh)
36+
37+
into your shell startup file (most commonly **.bashrc**).
38+
39+
40+
41+
Working with virtualenvwrapper
42+
==============================
43+
44+
Next, you will want to create a new virtual environment:
45+
46+
.. code:: bash
47+
48+
mkvirtualenv my-dronekit-project
49+
50+
This will create a new virtual environment and activate it.
51+
52+
Next, you will want to install **dronekit** into your new virtual environment.
53+
54+
.. code:: bash
55+
56+
pip install dronekit
57+
58+
If you need to install anything else, you can use ``pip install`` as usual.
59+
60+
.. tip::
61+
62+
No ``sudo`` is required because the virtual environment is installed in your home directory and only effects instances of bash under your control.
63+
64+
When you are done working with your virtual environment, you can deactivate it to switch back to the global python environment with
65+
66+
.. code:: bash
67+
68+
deactive
69+
70+
To work on it again use
71+
72+
.. code:: bash
73+
74+
workon my-dronekit-project
75+
76+
.. note::
77+
78+
You will need to use ``workon my-dronekit-project`` on each instance of bash you wish to run your code in.
79+
80+
81+
82+
Deployment and Version Control
83+
==============================
84+
85+
At any point you can write a list of every library you have installed along with its version to file by using
86+
87+
.. code:: bash
88+
89+
pip freeze > requirements.txt
90+
91+
Later, you can tell **pip** to install those libraries at the versions listed with
92+
93+
.. code:: bash
94+
95+
pip install -r requirements.txt
96+
97+
By using multiple virtual environments you can easily test new versions of DroneKit without the risk of breaking your project. You can also tie a **requirements.txt** to each release of your project to guarantee the appropriate version of DroneKit and any other libraries are installed, and to speed up deployment. If you use version control, you can keep requirements.txt under your version control to make it easy to install the software appropriate to any given commit.

docs/guide/getting_started.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The remaining dependencies are installed when you get DroneKit-Python from the p
5555
If you are planning to run *DroneKit* on a :ref:`companion computer <supported-companion-computers>`, make sure that the
5656
computer runs a variant of Linux that support Python and can install Python packages from the internet.
5757

58+
.. _getting_started_installing_dronekit_mac:
5859

5960
Installing DroneKit on Mac OSX
6061
------------------------------

docs/guide/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ The guide contains how-to documentation for using the DroneKit-Python API. These
1717
copter/guided_mode
1818
Missions <auto_mode>
1919
debugging
20-
mavlink_messages
20+
mavlink_messages
21+
deploying-scripts

0 commit comments

Comments
 (0)