Last active
October 1, 2015 09:53
-
-
Save theSage21/c46edc7eea812bc5e410 to your computer and use it in GitHub Desktop.
Start new python projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
echo Creating directory | |
mkdir $1 | |
# copy standard project stuff | |
echo Copying License | |
lic=$1/LICENSE | |
this_year=`date | gawk '{print $6}'` | |
echo "The MIT License (MIT) | |
Copyright (c) $this_year Arjoonn Sharma | |
" >> $lic | |
echo " | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE." >> $lic | |
# Python gitignore | |
echo Copying gitignore | |
cp ./gitignore/Python.gitignore ./$1/.gitignore | |
cd $1 | |
# create package structure | |
mkdir tests docs | |
mkdir $1 | |
cd $1 | |
echo "__version__ = (0, 0, 1)" > __init__.py | |
cd .. | |
# Virtualenv | |
echo Creating Virtualenv | |
virtualenv -p python$2 env | |
source env/bin/activate | |
echo "-r requirements.txt | |
# testing | |
pytest==2.7.2 | |
pytest-pythonpath==0.7 | |
pytest-cov==2.1.0" > requirements-dev.txt | |
touch requirements.txt | |
# install dependencies | |
echo Installing dependencies | |
pip install -r requirements-dev.txt | |
# create setup file | |
echo " | |
from setuptools import setup | |
import $1 | |
version = '.'.join(map(str, $1.__version__)) | |
long_desc = ''' | |
$1 | |
''' | |
setup(name='$1', | |
version=version, | |
description='$1', | |
long_description=long_desc, | |
url='https://github.com/theSage21/$1', | |
author='Arjoonn Sharma', | |
author_email='Arjoonn Sharma', | |
license='MIT', | |
packages=['$1'], | |
zip_safe=False, | |
include_package_data=True, | |
classifiers=['Development Status :: 4 - Beta', | |
'Intended Audience :: Developers', | |
'License :: OSI Approved :: MIT License', | |
'Programming Language :: Python :: 3.4', | |
], | |
keywords='$1'.split(' '), | |
entry_points={'console_scripts': ['$1=$1.cli:main']}, | |
) | |
" > setup.py | |
# Create standard stuff | |
echo Making README.md | |
echo "$1 | |
====" > README.md | |
echo Requirements are being noted | |
echo Making setup.cfg | |
echo '[pytest] | |
python_paths = . | |
norecursedirs = .tox .git | |
[flake8] | |
max-line-length = 122 | |
exclude = .tox,.git, docs,env,venv | |
[metadata] | |
description-file = README.md' > setup.cfg | |
echo Making coverage rc | |
echo "[run] | |
source = $1 | |
[report] | |
# Regexes for lines to exclude from consideration | |
exclude_lines = | |
# Have to re-enable the standard pragma | |
pragma: no cover | |
# Don't complain about missing debug-only code: | |
def __repr__ | |
if self\.debug | |
# Don't complain if tests don't hit defensive assertion code: | |
raise AssertionError | |
raise NotImplementedError | |
# Don't complain if non-runnable code isn't run: | |
if 0: | |
if __name__ == .__main__.: | |
ignore_errors = True | |
[html] | |
directory = coverage_html_report | |
" > .coveragerc | |
# Git | |
echo Gitting the project | |
git init | |
git add -Av | |
git commit -m 'Initial setup commit by new_project.sh' | |
git checkout -b development | |
git checkout master | |
git checkout -b release | |
git checkout development |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment