Setup New Python Project with pyscaffold

Setup New Python Project with pyscaffold

This guide shows you how to setup a new Python project. This package can then be uploaded to PyPI to make it available to everyone.

The examples used in this guide were run and tested on Ubuntu 14.04 with Python 3.4.0. If you're using a different platform you may have to tweak the instructions accordingly.

This guide was possible thanks to How to Setup a new Python Project.

Install Prerequisites

[user@host ~/sandbox]$ sudo aptitude install python3.4-dev git build-essential curl

Make sure to configure git, including but not limited to, user.name and user.email global settings.

Create virtualenv

The first thing you'll do is create a virtualenv and activate it.

There's a bug in Ubuntu (and Debian) pyvenv fails due to mising ensurepip module. A workaround is to create a venv without pip and then install it in the venv later.

[user@host ~/sandbox]$ pyvenv-3.4 --without-pip virtenv

[user@host ~/sandbox]$ source virtenv/bin/activate

Now the workaround of installing pip. Hopefully this bug will be fixed soon.

(virtenv)[user@host ~/sandbox]$ curl -O https://bootstrap.pypa.io/get-pip.py

(virtenv)[user@host ~/sandbox]$ python get-pip.py

Setup New Python Project

Install the versioneer package as it makes it easier to manage the version numbers of your project when used with git.

(virtenv)[user@host ~/sandbox]$ pip install versioneer

Install the pyscaffold package as it makes it easier to setup a new Python project. It creates the necessary directories and files, even getting git in action to initialize a repository.

(virtenv)[user@host ~/sandbox]$ pip install pyscaffold

(virtenv)[user@host ~/sandbox]$ putup -l 'mit' datod

Edit setup.py and provide the customizable information in it.

You're on your way ...