GithubHelp home page GithubHelp logo

springerle / py-generic-project Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 9.0 2.64 MB

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

Home Page: https://py-generic-project.readthedocs.io/

License: Creative Commons Zero v1.0 Universal

Python 73.37% Shell 26.63%
python cookiecutter automation invoke project-creation

py-generic-project's Introduction

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.

py-generic-project's People

Contributors

jhermann avatar themeier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

py-generic-project's Issues

Add support for license choices

At least GPL, Apache, BSD, and MIT.
Provide the license file (are the GitHub templates readily available?)
and replace the license notices in source files.
Needs a CC extension (computed values lookup from a “database” or file tree) to be feasible.

.env update

Make it download updated versions of itself from here, automatically or via an --update option.

Add Python3 support to .env script

  • Support the broken Ubuntu packages
  • Add a --py3 switch
--- github/gh-commander/.env    2015-03-31 15:15:41.941862917 +0200
+++ infra/vicontrol/.env    2015-04-09 15:48:01.906582244 +0200
@@ -54,11 +54,13 @@
         if $_venv_create || [[ $REPLY =~ ^[Yy]?$ ]]; then
-            /usr/bin/virtualenv ".venv/$_venv_name"
+            # Bootstrap a Py3.4 venv (even when using the broken Ubuntu packages)
+            /usr/bin/pyvenv-3.4 --without-pip ".venv/$_venv_name"
+            curl -skS "https://bootstrap.pypa.io/get-pip.py" | .venv/$_venv_name/bin/python -
             . ".venv/$_venv_name/bin/activate"
-            pip --log ".venv/pip-install.log" install -UI pip 2>&1 | $_venv_pip_log
-            pip --log ".venv/pip-install.log" install -UI "setuptools>=14.3" "wheel>=0.24.0" 2>&1 | $_venv_pip_log
-            pip --log ".venv/pip-install.log" install -r dev-requirements.txt 2>&1 | $_venv_pip_log
+            .venv/$_venv_name/bin/pip --log ".venv/pip-install.log" install -UI pip 2>&1 | $_venv_pip_log
+            .venv/$_venv_name/bin/pip --log ".venv/pip-install.log" install -UI "setuptools>=14.3" "wheel>=0.24.0" 2>&1 | $_venv_pip_log
+            .venv/$_venv_name/bin/pip --log ".venv/pip-install.log" install -r dev-requirements.txt 2>&1 | $_venv_pip_log
             if test -f setup.py; then
-                python setup.py develop -U 2>&1 | $_venv_pip_log
+                .venv/$_venv_name/bin/python setup.py develop -U 2>&1 | $_venv_pip_log
                 echo
-                python setup.py --name --version --author --author-email --license --description --url \
+                .venv/$_venv_name/bin/python setup.py --name --version --author --author-email --license --description --url \
                     | tr \\n \\0 | xargs -0 printf "%s %s by %s <%s> [%s]\\n%s\\n%s\\n" || :

Handle repo names containing hypens

For the package name, hyphens have to be mapped to underscores.
This should be supported by CC (compute the other field), might need a feature addition.
Might work with a J2 filter (and obfuscate the src paths further 😏).

setuptools version in .env

Pinning setuptools to a version < 36 in .env leads to issues when installing dependencies on debian- stretch (python 3.5.3)

  • pymongo 3.7.2 fails with something like this
    File "/usr/lib/python3.5/typing.py", line 837, in _valid_for_checkraise TypeError("Parameterized generics cannot be used with class "?
    or
Running pymongo-3.7.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vszjegjg/pymongo-3.7.2/egg-dist-tmp-i8l3vq1l
Traceback (most recent call last):
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 157, in save_modules
    yield saved
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 255, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 285, in run
    return func()
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 253, in runner
    _execfile(setup_script, ns)
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-vszjegjg/pymongo-3.7.2/setup.py", line 30, in <module>
    entry_points = {}
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/sphinx/cmd/build.py", line 25, in <module>
    from sphinx.application import Sphinx
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/sphinx/application.py", line 34, in <module>
    from sphinx.environment import BuildEnvironment
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/sphinx/environment/__init__.py", line 38, in <module>
    from sphinx.util.websupport import is_commentable
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/sphinx/util/websupport.py", line 11, in <module>
    from sphinxcontrib.websupport.utils import is_commentable  # NOQA
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/sphinxcontrib/websupport/__init__.py", line 15, in <module>
    from sphinxcontrib.websupport.core import WebSupport  # NOQA
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/sphinxcontrib/websupport/core.py", line 17, in <module>
    from jinja2 import Environment, FileSystemLoader
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/jinja2/environment.py", line 15, in <module>
    from jinja2 import nodes
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/jinja2/nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/jinja2/utils.py", line 486, in <module>
    MutableMapping.register(LRUCache)
  File "/usr/lib/python3.5/abc.py", line 158, in register
    if issubclass(subclass, cls):
  File "/usr/lib/python3.5/abc.py", line 226, in __subclasscheck__
    if issubclass(subclass, scls):
  File "/usr/lib/python3.5/abc.py", line 207, in __subclasscheck__
    ok = cls.__subclasshook__(subclass)
  File "/usr/lib/python3.5/typing.py", line 860, in __extrahook__
    if issubclass(subclass, scls):

^ ending in infinite recursion

  • jinja 2.0.0 fails with:
Processing pbr-5.1.1.tar.gz
Writing /tmp/easy_install-r9sxx8qr/pbr-5.1.1/setup.cfg
Running pbr-5.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-r9sxx8qr/pbr-5.1.1/egg-dist-tmp-8rsvu69x
Traceback (most recent call last):
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 157, in save_modules
    yield saved
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 255, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 285, in run
    return func()
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 253, in runner
    _execfile(setup_script, ns)
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-r9sxx8qr/pbr-5.1.1/setup.py", line 21, in <module>
    
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/pbr/util.py", line 258, in cfg_to_args
    kwargs = setup_cfg_to_setup_kwargs(config, script_args)
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/pbr/util.py", line 399, in setup_cfg_to_setup_kwargs
    cmd = cls(dist)
  File "/builds/project-0/.venv/project-0/lib/python3.5/site-packages/setuptools/__init__.py", line 127, in __init__
    _Command.__init__(self, dist)
  File "/usr/lib/python3.5/distutils/cmd.py", line 57, in __init__
    raise TypeError("dist must be a Distribution instance")
TypeError: dist must be a Distribution instance

Both install without any problems when i remove the <36 from https://github.com/Springerle/py-generic-project/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/.env#L170

Add feature options

  • Allow selection of features (like 'cli_stub')
  • Remove any empty or 1-line files left over in a post-creation hook

invoke dependencies

generated a new project with this template, when running . .env --develop --yes -v this message is printed

rituals 0.3.0.dev0 has requirement invoke<0.15.0,>=0.11, but you'll have invoke 1.2.0 which is incompatible.

Test plumbing

Add src/test and some sample test on the package metadata.

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.