-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpython-package
More file actions
executable file
·150 lines (129 loc) · 3.35 KB
/
python-package
File metadata and controls
executable file
·150 lines (129 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
PROJECTNAME="Project"
AUTHOR="Chris Perivolaropoulos"
EMAIL="darksaga2006@gmail.com"
DESCRIPTION="Description of $PROJECTNAME"
GITHUB="none"
USERNAME="fakedrake"
HELP_MESSAGE="Create a very simple python package in the current directory.
OPTIONS:
--name <string> Package name (eg MyPackage)
--author <string> Package author (eg \"$AUTHOR\", this is also the default)
--email <string> Author email
--description <string> Package description
--user <string> Username of github
--github <string> Github short path in the form \"$USERNAME/$PROJECTNAME\". 'none' to not use github.
--help: This message
"
VIRTUALENV_CMD=virtualenv2
for i in $@; do
case $1 in
"--name")
shift
PROJECTNAME=$1;;
"--user")
shift
USERNAME=$1;;
"--author")
shift
AUTHOR=$1;;
"--email")
shift
EMAIL=$1;;
"--description")
shift
DESCRIPTION=$1;;
"--github")
shift
GITHUB=$1;;
"--help")
echo "$HELP_MESSAGE"
exit 0;;
esac
shift
done
if [ $GITHUB = "guess" ]; then
GITHUB="$USERNAME/$PROJECTNAME"
fi
echo -e "Name:\t\t $PROJECTNAME"
echo -e "User Name:\t $USERNAME"
echo -e "Author:\t\t $AUTHOR"
echo -e "e-mail:\t\t $EMAIL"
echo -e "Description:\t $DESCRIPTION"
echo -e "Github:\t\t $GITHUB"
if [[ "$GITHUB" != "none" ]]; then
echo -e "ATTENTION: It is advised that you create the remote github repo before creating the project so I know where to make the initial commit."
fi
echo "Is everything in order?[Y/n]"
read yon
if [ "$yon" != "" ] && [ "${yon:0:1}" != "y" ] && [ "${yon:0:1}" != "Y" ]; then
echo "Ok rerun the command. No changes made."
exit 0
fi
LPNAME=`echo $PROJECTNAME | tr '[A-Z]' '[a-z]'`
SETUP="
import os
from setuptools import setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = \"$PROJECTNAME\",
version = \"0.0.1\",
author = \"$AUTHOR\",
author_email = \"$EMAIL\",
description = (\"$DESCRIPTION\"),
license = \"GPL\",
keywords = \"\",
url = \"http://packages.python.org/$PROJECTNAME\",
packages=['$LPNAME', '$LPNAME.test'],
install_requires=[],
tests_require=['nose'],
long_description=read('README.org'),
test_suite='$LPNAME.test',
classifiers=[
\"Programming Language :: Python :: 2.7\",
\"License :: OSI Approved :: GNU General Public License v2 (GPLv2)\"
],
)"
mkdir $PROJECTNAME
cd $PROJECTNAME
$VIRTUALENV_CMD --no-site-packages .
bin/pip install ipdb
mkdir $LPNAME
touch $LPNAME/__init__.py
mkdir $LPNAME/test/
touch $LPNAME/test/__init__.py
README="* $PROJECTNAME
$DESCRIPTION
"
MANIFEST="
include *txt
recursive-include $LPNAME *.py *.txt
recursive-include $LPNAME/test *.py *.txt
prune bin"
GITIGNORE="
*.pyc
bin/
lib/
local/
build/
share/
include/
*.egg-info
*.egg
"
echo "$MANIFEST" > MANIFEST.in
echo "$SETUP" > setup.py
echo "$GITIGNORE" > .gitignore
echo "$README" > README.org
git init
git add setup.py MANIFEST.in README.org $LPNAME/__init__.py $LPNAME/test/__init__.py .gitignore
git commit -a -m "Initial commit"
if [ $GITHUB != "none" ]; then
git remote add origin git@github.com:$GITHUB
git push -u origin master
fi