/py-generic-project

:cookie: A cookiecutter template that creates a basic Python setuptools project, which can be later on augmented with various optional accessories.

Primary LanguagePythonCreative Commons Zero v1.0 UniversalCC0-1.0

py-generic-project

Logo

A cookiecutter template that creates a basic Python setuptools project, which can be later on augmented with various optional accessories. See the demo for getting a 1ˢᵗ impression on how this Cookiecutter template can be used, including screenshots of the terminal session.

LogoGroupsMIT+CC0 licensedTravis CIGitHub IssuesGitHub Release

Features

The resulting project uses rituals and invoke for task automation, and setuptools for building and distributing the project. A provided autoenv script takes care of creating a fully boot-strapped virtualenv or venv – it can also be called manually if you don't want to install autoenv.

Other integrated tools are pylint for code quality checking, pytest for testing support, and a Travis CI configuration.

📚 Get to know all the details on Read The Docs.

Reapplying to an Existing Project

To update your project from the current version of the template, you can re-create it with the original inputs and merge the changes with your repository, as outlined below.

First, convert the cookiecutter.json file to a .cookiecutterrc one by calling this command:

python3 -c \
    "import sys,json,yaml; d=json.load(sys.stdin); yaml.dump(d, sys.stdout)" \
    <cookiecutter.json

The resulting output can be added to a copy of your ~/.cookiecutterrc, and then used in a new cookiecutter call:

cp ~/.cookiecutterrc .
vi .cookiecutterrc  # see above
cookiecutter --no-input --config-file .cookiecutterrc «project-template»

You now have a current copy of your project in a sub-directory of your workdir. Make sure you have everything committed and no local pending changes, then call:

cp -rp «project-name»/{.??*,*} .
git diff

Now comes the labor-intensive part, checking all the changes and integrating them. You can make that a bit easier by using git:

git checkout -b cookiecutter v0
cp -rp «project-name»/{.??*,*} .
git commit -m "cookiecutter template update"
git checkout master
git merge cookiecutter

This is assuming you have committed the original unchanged template and marked it with the v0 tag. Now you need to resolve all the conflicts you get (and you normally get plenty) – still a lot of work, but a little better.

Split Licensing

Since the files contained in the {{cookiecutter.repo_name}} archetype itself will comprise the foundation of your project, they're unlicensed using the “Creative Commons Zero v1.0 Universal” license. All other files outside the {{cookiecutter.repo_name}} directory are MIT-licensed – this effectively means you only have to attribute this project if you re-use all or parts of the contained templating mechanics and documentation.

  • Project License for the project.
  • Template License for the template proper (everything in {{cookiecutter.repo_name}}), unless specified otherwise within the file itself.

References

Similar Archetypes

Related Tools

See also the full list at Cookiecutter's README.