summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Ramachandran2015-04-06 21:18:38 +0530
committerPrabhu Ramachandran2015-04-06 21:18:38 +0530
commit43f161eb0558b42f00e749d4e086e5e443b52ac3 (patch)
treebb98f092f77ec01fb64bedef9cdcef39fc0c4e4b
parent998fcd1b81b23ff99e311212e23e3af884bec534 (diff)
parenta7b1f5d74ed7a0cf2e7e6f0e2bd6f3707fb20c6c (diff)
downloadsees-43f161eb0558b42f00e749d4e086e5e443b52ac3.tar.gz
sees-43f161eb0558b42f00e749d4e086e5e443b52ac3.tar.bz2
sees-43f161eb0558b42f00e749d4e086e5e443b52ac3.zip
Merge pull request #10 from prabhuramachandran/venv_pip_setup
Add slides on virtualenv, packaging, CI etc.
-rwxr-xr-xslides/devtools/build.sh5
-rw-r--r--slides/devtools/code/my_project/README.md4
-rw-r--r--slides/devtools/code/my_project/sees/__init__.py0
-rw-r--r--slides/devtools/code/my_project/sees/hello.py3
-rw-r--r--slides/devtools/code/my_project/setup.py10
-rw-r--r--slides/devtools/presentation.rst287
6 files changed, 309 insertions, 0 deletions
diff --git a/slides/devtools/build.sh b/slides/devtools/build.sh
new file mode 100755
index 0000000..9d626d7
--- /dev/null
+++ b/slides/devtools/build.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+rst2s5.py --theme=small-white presentation.rst presentation.html
+
+
diff --git a/slides/devtools/code/my_project/README.md b/slides/devtools/code/my_project/README.md
new file mode 100644
index 0000000..f651da4
--- /dev/null
+++ b/slides/devtools/code/my_project/README.md
@@ -0,0 +1,4 @@
+Simple demo project.
+
+Primarily used to demonstrate writing the simplest setup.py.
+
diff --git a/slides/devtools/code/my_project/sees/__init__.py b/slides/devtools/code/my_project/sees/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/slides/devtools/code/my_project/sees/__init__.py
diff --git a/slides/devtools/code/my_project/sees/hello.py b/slides/devtools/code/my_project/sees/hello.py
new file mode 100644
index 0000000..32dda4e
--- /dev/null
+++ b/slides/devtools/code/my_project/sees/hello.py
@@ -0,0 +1,3 @@
+def hello():
+ return "Hello world, welcome to SEES"
+
diff --git a/slides/devtools/code/my_project/setup.py b/slides/devtools/code/my_project/setup.py
new file mode 100644
index 0000000..be4ce06
--- /dev/null
+++ b/slides/devtools/code/my_project/setup.py
@@ -0,0 +1,10 @@
+from setuptools import setup, find_packages
+
+setup(
+ name="sees",
+ version="0.1",
+ description="Utility code for SEES course",
+ author="FOSSEE developers",
+ author_email="python@fossee.in",
+ packages=find_packages(),
+)
diff --git a/slides/devtools/presentation.rst b/slides/devtools/presentation.rst
new file mode 100644
index 0000000..0f6f7cc
--- /dev/null
+++ b/slides/devtools/presentation.rst
@@ -0,0 +1,287 @@
+=============================================
+Virtualenv, Packaging and Useful Tools
+=============================================
+
+.. class:: center
+
+ March 30, 2015
+
+ Department of Aerospace Engineering,
+ IIT Bombay
+
+ :Author: Prabhu Ramachandran
+
+
+
+Agenda
+=========
+
+- Introduction to virtual env and its use
+
+- Python packaging
+ - What are Packages?
+ - Distributing Packages
+ - PyPI
+
+- Hosting documentation
+
+- Continuous integration
+
+- Test coverage
+
+Preamble: what's a package?
+=============================
+
+A collection of Python modules organized into a hierarchy::
+
+ $ tree jedi
+ jedi/
+ ├── __init__.py
+ ├── api.py
+ ├── builtin.py
+ ...
+ ├── debug.py
+ ├── refactoring.py
+ └── settings.py
+
+
+
+Virtualenvs
+=============
+
+A self-contained virtual Python environment which **you** control!
+
+- Requires a "system" Python distribution
+
+
+Motivation
+===========
+
+- Need to install Python packages
+- No root access
+- Don’t want to mess up system
+- Create “isolated” environment
+
+Virtualenv
+============
+
+- www.virtualenv.org
+- pypi.python.org/pypi/virtualenv
+- Either install virtualenv
+- Or use the `virtualenv.py`_
+
+.. code:: shell
+
+ $ easy_install virtualenv
+
+Or download tarball and::
+
+ $ python setup.py install [--prefix=/usr/local]
+
+.. _`virtualenv.py`: http://github.com/pypa/virtualenv/tree/master/virtualenv.py
+
+
+Environments
+=============
+
+.. code:: shell
+
+ $ python virtualenv.py --help
+
+ $ python virtualenv.py ENV
+
+ $ virtualenv --system-site-packages ENV
+
+- ``ENV`` is a directory name of your choice
+- Self-contained universe
+- Can inherit system packages
+- Look in ``ENV/bin`` (or ``ENV\Scripts``)
+- Look in ``ENV/lib`` (or ``ENV\Lib``)
+
+Activation
+============
+
+.. code:: shell
+
+ # Activation (Linux/Mac OSX)
+ $ source ENV/bin/activate
+
+ $ ENV\Scripts\activate.bat
+
+ # Deactivate
+ (ENV)$ deactivate
+
+Usage
+=======
+
+.. code:: shell
+
+ (ENV)$ deactivate
+ $ python virtualenv.py ANOTHER
+ (ANOTHER)$ source ANOTHER/bin/activate
+ (ANOTHER)$ pip install PKG
+ # installs in ANOTHER
+
+ (ANOTHER)$ deactivate
+ $ source ENV/bin/activate
+
+ # To remove ANOTHER
+ $ rm -rf ANOTHER
+
+Easy and convenient!
+
+Python Packages
+=================
+
+- Organized hierarchy of modules
+- Can include data
+- Documentation
+- Installation and distribution
+
+Installing packages
+====================
+
+.. code:: shell
+
+ $ pip install requests
+
+ $ pip list
+
+ $ pip uninstall requests
+
+Making your own
+==================
+
+Let us look at a simple package
+
+.. code:: shell
+
+ $ tree my_project
+ my_project/
+ ├── README.md
+ └── sees
+ ├── __init__.py
+ └── hello.py
+
+Packaging the package
+=======================
+
+- We want to "install" this
+- Want others to install it
+- Want to share it
+
+- Make sure you have ``setuptools`` available
+
+.. code:: shell
+
+ $ python -c "import setuptools"
+
+No import error means you are good!
+
+Writing a ``setup.py``
+========================
+
+Create ``setup.py``
+
+.. code:: python
+
+ from setuptools import setup, find_packages
+
+ setup(
+ name="sees",
+ version="0.1",
+ description="Utility code for SEES course",
+ author="FOSSEE developers",
+ author_email="python@fossee.in",
+ packages=find_packages(),
+ )
+
+Using it
+==========
+
+.. code:: shell
+
+ $ python setup.py --help
+ $ python setup.py sdist
+ $ python setup.py develop
+ $ python setup.py install
+
+More on distutils
+======================
+
+- Many more options
+- Support to compile extensions
+- Including package data
+- See `setuptools documentation`_
+- See `distutils documentation`_.
+
+.. _setuptools documentation: http://pythonhosted.org//setuptools/
+.. _distutils documentation: https://docs.python.org/2/distutils/index.html#distutils-index
+
+Distributing and PyPI
+=========================
+
+- Register on http://pypi.python.org
+
+.. code:: shell
+
+ $ python setup.py register
+
+- Create a ``~/.pypirc``
+
+::
+
+ [pypirc]
+ servers = pypi
+ [server-login]
+ username:your_awesome_username
+ password:your_awesome_password
+
+Hosting Documentation
+======================
+
+- Bitbucket/Github
+
+- Better: http://www.readthedocs.org
+ - http://read-the-docs.readthedocs.org/
+
+
+Continuous integration
+========================
+
+- Run tests automatically
+
+ - On each commit
+ - For each PR
+ - For all branches
+
+- Potentially on multiple platforms
+
+Continuous integration
+========================
+
+- Jenkins/Hudson
+
+- Travis-ci.org
+
+- Drone.io
+
+- Shippable.com
+
+- Appveyor
+
+
+Travis-CI example
+===================
+
+- Uses a YAML file for config
+- Most others are similar
+- Look at some examples
+
+
+Additional Reading
+===================
+
+Very nice document with examples:
+
+https://pythonhosted.org/an_example_pypi_project/index.html