setup.py template builder
The point of this project is to make a bash script (unix os) that constructs the basic structure of a python package. Also each file needs to contain general guidelines for distributing python code.
To use template builder:
Save the bash script to a file (I am saving it as template.sh) making sure to add the file extension .sh.
# give user permissions to the file
chmod 755 template.sh
# The script takes two positional arguments
# ./template.sh package_name module_name
# Example
./template.sh PythonTools pytool
Example file structure:
.
├── PythonTools
│ ├── bin
│ │ ├── script1.py
│ │ └── script2.py
│ ├── CHANGES.txt
│ ├── docs
│ │ ├── history.txt
│ │ └── notes.txt
│ ├── extra_files
│ │ ├── ef1.txt
│ │ └── ef2.txt
│ ├── LICENSE.txt
│ ├── MANIFEST.in
│ ├── pytools
│ │ ├── data
│ │ │ └── data.txt
│ │ ├── __init__.py
│ │ ├── pytools.py
│ │ └── test
│ │ ├── __init__.py
│ │ ├── test_method1.py
│ │ └── test_method2.py
│ ├── README.md
│ └── setup.py
└── template.sh
Code (template.sh):
#!/bin/bash
# Create file structure
mkdir $1
mkdir $1/$2
mkdir $1/$2/test
mkdir $1/$2/data
touch "$1/$2/data/data.txt"
touch "$1/$2/__init__.py"
touch "$1/$2/$2.py"
touch "$1/$2/test/__init__.py"
touch "$1/$2/test/test_method1.py"
touch "$1/$2/test/test_method2.py"
touch "$1/LICENSE.txt"
touch "$1/CHANGES.txt"
touch "$1/MANIFEST.in"
touch "$1/setup.py"
touch "$1/README.md"
mkdir $1/bin
touch "$1/bin/script1.py"
touch "$1/bin/script2.py"
mkdir $1/docs
touch "$1/docs/history.txt"
touch "$1/docs/notes.txt"
mkdir "$1/extra_files"
touch "$1/extra_files/ef1.txt"
touch "$1/extra_files/ef2.txt"
# populate files
# README.md
echo "
===========
$1
===========
$1 provides such and such and so and so. You might find
it most useful for tasks involving <x> and also <y>. Typical usage
often looks like this::
#!/usr/bin/env python
from $1 import $2
if $2.has_method():
print 'Your method is doing stuff: ', $2.has_method()
A Section: $1
=============
Lists look like this:
* First
* Second. Can be multiple lines
but must be indented properly.
A Sub-Section $2
----------------
Numbered lists look like you'd expect:
1. hi there
2. must be going
Urls are http://like.this and links can be
written like this <http://www.example.com/foo/bar>." > $1/README.md
# CHANGES.txt
echo "v< version_number >, < date >, < notes >" > $1/CHANGES.txt
# MANIFEST.in
echo "
include *.txt
include *.md
include docs *.md
recursive-include docs *.md" > $1/MANIFEST.in
# setup.py
echo "from setuptools import setup, find_packages
setup(
name = '$1',
version = '0.0.1',
packages = find_packages(),
description = 'Useful description',
long_description=open(README.md, 'r').readlines(),
scripts = ['bin/script1.py', 'bin/script2.py'],
# installed or upgraded on the target machine
install_requires = ['',''],
include_package_data = True,
package_data = {
# include *.txt or *.rst files:
'': ['*.txt', '*.rst'],
# include *.msg files:
'': ['*.msg'],
# include subdirectory containing example datasets:
'$2': ['$2/data/*.txt'],
data_files = [('extra_files', ['extra_files/ef1.txt', 'extra_files/ef2.txt'])],
},
# metadata for PyPi
author = 'your name',
author_email = '[email protected]',
maintainer = 'maintainers name',
maintainer_email = '[email protected]',
license = 'PSF, GPL or MIT',
keywords = ['keyword1', 'keyword2' ],
url = 'url.com',
# could also include classifiers, etc.
)" > $1/setup.py