Giter VIP home page Giter VIP logo

cookiecutter-pylibrary's Introduction

cookiecutter-pylibrary

Cookiecutter template for a Python python library.

Notes:

Features

This is an "all inclusive" sort of template.

  • BSD 2-clause license.
  • Tox and Pytest for testing Python 2.6, 2.7, 3.3, PyPy etc. [1]
  • Support for creating a tests matrix out of dependencies and python versions. [1]
  • Travis-CI and AppVeyor for continuous testing.
  • Coveralls for coverage tracking (using Tox).
  • Documentation with Sphinx, ready for ReadTheDocs.
  • Configurations for:
  • Support for C extensions (including coverage measurement for the C code).
  • Packaging and code quality checks. This template comes with a tox environment (check) that will:
    • Check if your README.rst is valid.
    • Check if the MANIFEST.in has any issues.
    • Run flake8 (a combo of PEP8, pyflakes and McCabe checks)

Requirements

Projects using this template have these minimal dependencies:

  • Cookiecutter - just for creating the project
  • Tox - for running the tests
  • Setuptools - for building the package, wheels etc. Now-days Setuptools is widely available, it shouldn't pose a problem :)

To get quickly started on a new system, just install setuptools and then install pip. That's the bare minimum to required install Tox and Cookiecutter. To install them, just run this in your shell or command prompt:

pip install tox cookiecutter

Usage

This template is more involved than the regular cookiecutter-pypackage.

First generate your project:

cookiecutter gh:CacconeLabYale/cookiecutter-pylibrary

You will be asked for these fields:

project_name Verbose project name, used in headings (docs, readme, etc).
repo_name Repository name on github.
package_name Python package name (whatever you would import).
distribution_name PyPI distribution name (what you would pip install).

The testing (tox.ini and .travis.yml) configuration is generated from templates. For your convenience there's an initial bootstrap tox.ini, to get the initial generation going just run:

tox

You can later regenerate tox.ini and .travis.yml by running:

tox -e configure

After this you can create the initial repository (make sure you create an empty Github project):

git init .
git add .
git commit -m "Initial skel."
git remote add origin [email protected]:ionelmc/python-nameless.git
git push -u origin master

Then:

Developing the project

To run all the tests, just run:

tox

To see all the tox environments:

tox --listenvs

To only build the docs:

tox -e docs

To build and verify that the built package is proper and other code QA checks:

tox -e check

Releasing the project

Before releasing your package on PyPI you should have all the tox environments passing.

To make a release of the project on PyPI, the most simple usage is:

python setup.py release

(release is aliased to register clean sdist bdist_wheel upload, see setup.cfg).

If you care about security you can do secure uploads to PyPI using twine.

Questions & answers

There's no Makefile?

Sorry, no Makefile yet. The Tox environments stand for whatever you'd have in a Makefile.

Not Exactly What You Want?

No way, this is the best. ๐Ÿ˜œ

[1](1, 2, 3)

In case you don't fancy having a test matrix generator script there's a simpler variant of this template that:

  • Doesn't have a generator script (no bootstrap.py).
  • Doesn't use Pytest. Just bare unittest.

If you have criticism or suggestions please open up an Issue or Pull Request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.