Skip to main content

Create project layout from jinja2 templates.

Project description

Summary

Create project layout from jinja2 templates.

Installation

$ pip install make

or

$ pip install --user make

Usage

In general:

$ python -m make project source-path target-path

Where source-path can be a local path:

$ python -m make project examples/ini_features New-Project

A local zip file:

$ python -m make project examples/ini_features.zip New-Project

Zip file over http or https:

$ python -m make project -zp simple-master https://gitlab.com/fholmer/simple/-/archive/master/simple-master.zip New-Project

Short url for Github:

$ python -m make project gh:fholmer/simple New-Project

And Gitlab:

$ python -m make project gl:fholmer/simple New-Project

Sub dirs is also supported for Gitlab:

$ python -m make project gl:fholmer/templates/proj1 New-Project

Simple cookiecutter templates is also supported.

We will use a popular cookiecutter template in this example:

$ python -m make project gh:kragniz/cookiecutter-pypackage-minimal New-Project

How to make your own project template

The source-path have to contain a file named project.conf or project.json. Choose the format you prefer.

Format of project.conf:

[project]
name = App
package = {{project.name.lower().replace(' ','_').replace('-', '_')}}
include_tests = json::["none", "pytest"]
include_docs = json::["none", "sphinx", "mkdocs"]

# this is a comment.
# section or keys starting with _ is non-interactive variables

_test_dir = {{ 'tests' if project.include_tests != 'none' else '' }}

[_docs]
dir=
    {%%- if project.include_docs == 'sphinx' -%%}
    docs
    {%%- elif project.include_docs == 'mkdocs' -%%}
    docz
    {%%- else -%%}
    {%%- endif -%%}

The ini-format allows for multi line values, but % have to be escaped. Comments is allowed. Use the special prefix json:: to serialize subsequent text as json.

Format of project.json:

{
    "project": {

        "name": "App",
        "package": "{{project.name.lower().replace(' ','_').replace('-', '_')}}",
        "include_tests": ["none", "pytest"],
        "include_docs": ["none", "sphinx", "mkdocs"],
        "_test_dir": "{{ 'tests' if project.include_tests != 'none' else '' }}"
    },
    "_docs": {
        "dir": "{%- if project.include_docs == 'sphinx' -%}\ndocs\n{%- elif project.include_docs == 'mkdocs' -%}\ndocz\n{%- else -%}\n{%- endif -%}"
    }
}

The json-format do not have multi line but you can use multiple \n in one line.

The source directory could be something like this:

/My-Project-Template
  /{{project.name}}
    /{{_docs.dir}}
      conf.py
    /{{project._test_dir}}
    /{{project.package}}
      __init__.py
    setup.py
    LICENSE
    README.rst
  project.conf

{{project.name}}/setup.py may look something like this:

from setuptools import setup, find_packages
from {{ project.package }} import __version__ as app_version

setup(
    name="{{ project.name }}",
    version=app_version,
    packages=find_packages(include=['{{ project.package }}*']),
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

make-0.1.5-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file make-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: make-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for make-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 46428da62a9e2a92ff761e150187ae71b8f28c6b3d6a23c85a1d00c8c2e6d606
MD5 7047e5b48519a434e86ebd8d29c7553a
BLAKE2b-256 a2fa35519d12eab7a2a52f4aa715df2ca75df6352b567d3526bd482bd1ffbc8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page