Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting up a pypi package

Setting up a python package

This will include:

  1. Travis CI integration
  2. Codecov integration
  3. run tests using pytest and tox

Step 1. Cookiecutter

cookiecutter https://github.com/audreyr/cookiecutter-pypackage.git

Step 2. Create GitHub repo

git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/user-name/repo-name.git
git push -u origin master

Step 3. Run Travis pypi Setup

travis_pypi_setup.py

Step 4. Customize tox

  1. Add flake8 settings
  2. Add codecov and pytest-cov to requirements_dev.txt

Your tox.ini file should look like this:

[tox]
envlist = py26, py27, py33, py34, py35, flake8

[flake8]
max-line-length = 125

[testenv:flake8]
basepython=python
deps=flake8
commands=flake8 package-name

[testenv]
passenv =
    CI
    TRAVIS
    TRAVIS_*
setenv =
    PYTHONPATH = {toxinidir}:{toxinidir}/package-name
deps =
    -r{toxinidir}/requirements_dev.txt
commands =
    pip install -U pip
    py.test --basetemp={envtmpdir} --cov={toxinidir}/package-name --verbose
    codecov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment