Skip to content

Commit 1fe7c60

Browse files
committed
Initial commit
0 parents  commit 1fe7c60

File tree

9 files changed

+379
-0
lines changed

9 files changed

+379
-0
lines changed

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
*.py[cod]
2+
3+
# C extensions
4+
*.so
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
eggs
12+
parts
13+
bin
14+
var
15+
sdist
16+
develop-eggs
17+
.installed.cfg
18+
lib
19+
lib64
20+
__pycache__
21+
22+
# Installer logs
23+
pip-log.txt
24+
25+
# Unit test / coverage reports
26+
.coverage
27+
.tox
28+
nosetests.xml
29+
30+
# Translations
31+
*.mo
32+
33+
# Mr Developer
34+
.mr.developer.cfg
35+
.project
36+
.pydevproject
37+
38+
# Temp files
39+
40+
*~
41+
42+
# Pipy codes
43+
44+
.pypirc

LICENCE.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
The MIT License (MIT)
3+
[OSI Approved License]
4+
5+
The MIT License (MIT)
6+
7+
Copyright (c) $YEAR $AUTHOR
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include *.txt
2+
recursive-include examples *.txt *.py

README.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
gizeh
2+
=================
3+
4+
5+
Installation
6+
--------------
7+
8+
gizeh can be installed by unzipping the source code in one directory and using this command: ::
9+
10+
(sudo) python setup.py install
11+
12+
You can also install it directly from the Python Package Index with this command: ::
13+
14+
(sudo) pip install gizeh
15+
16+
17+
Licence
18+
--------
19+
20+
See file LICENCE.txt in this folder
21+
22+
23+
Contribute
24+
-----------
25+
gizeh is an open-source software. Everyone is welcome to contribute !

ez_setup.py

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
2+
#!python
3+
"""Bootstrap setuptools installation
4+
5+
If you want to use setuptools in your package's setup.py, just include this
6+
file in the same directory with it, and add this to the top of your setup.py::
7+
8+
from ez_setup import use_setuptools
9+
use_setuptools()
10+
11+
If you want to require a specific version of setuptools, set a download
12+
mirror, or use an alternate download directory, you can do so by supplying
13+
the appropriate options to ``use_setuptools()``.
14+
15+
This file can also be run as a script to install or upgrade setuptools.
16+
"""
17+
import os
18+
import shutil
19+
import sys
20+
import tempfile
21+
import tarfile
22+
import optparse
23+
import subprocess
24+
25+
from distutils import log
26+
27+
try:
28+
from site import USER_SITE
29+
except ImportError:
30+
USER_SITE = None
31+
32+
DEFAULT_VERSION = "0.9.6"
33+
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
34+
35+
def _python_cmd(*args):
36+
args = (sys.executable,) + args
37+
return subprocess.call(args) == 0
38+
39+
def _install(tarball, install_args=()):
40+
# extracting the tarball
41+
tmpdir = tempfile.mkdtemp()
42+
log.warn('Extracting in %s', tmpdir)
43+
old_wd = os.getcwd()
44+
try:
45+
os.chdir(tmpdir)
46+
tar = tarfile.open(tarball)
47+
_extractall(tar)
48+
tar.close()
49+
50+
# going in the directory
51+
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
52+
os.chdir(subdir)
53+
log.warn('Now working in %s', subdir)
54+
55+
# installing
56+
log.warn('Installing Setuptools')
57+
if not _python_cmd('setup.py', 'install', *install_args):
58+
log.warn('Something went wrong during the installation.')
59+
log.warn('See the error message above.')
60+
# exitcode will be 2
61+
return 2
62+
finally:
63+
os.chdir(old_wd)
64+
shutil.rmtree(tmpdir)
65+
66+
67+
def _build_egg(egg, tarball, to_dir):
68+
# extracting the tarball
69+
tmpdir = tempfile.mkdtemp()
70+
log.warn('Extracting in %s', tmpdir)
71+
old_wd = os.getcwd()
72+
try:
73+
os.chdir(tmpdir)
74+
tar = tarfile.open(tarball)
75+
_extractall(tar)
76+
tar.close()
77+
78+
# going in the directory
79+
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
80+
os.chdir(subdir)
81+
log.warn('Now working in %s', subdir)
82+
83+
# building an egg
84+
log.warn('Building a Setuptools egg in %s', to_dir)
85+
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
86+
87+
finally:
88+
os.chdir(old_wd)
89+
shutil.rmtree(tmpdir)
90+
# returning the result
91+
log.warn(egg)
92+
if not os.path.exists(egg):
93+
raise IOError('Could not build the egg.')
94+
95+
96+
def _do_download(version, download_base, to_dir, download_delay):
97+
egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
98+
% (version, sys.version_info[0], sys.version_info[1]))
99+
if not os.path.exists(egg):
100+
tarball = download_setuptools(version, download_base,
101+
to_dir, download_delay)
102+
_build_egg(egg, tarball, to_dir)
103+
sys.path.insert(0, egg)
104+
import setuptools
105+
setuptools.bootstrap_install_from = egg
106+
107+
108+
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
109+
to_dir=os.curdir, download_delay=15):
110+
# making sure we use the absolute path
111+
to_dir = os.path.abspath(to_dir)
112+
was_imported = 'pkg_resources' in sys.modules or \
113+
'setuptools' in sys.modules
114+
try:
115+
import pkg_resources
116+
except ImportError:
117+
return _do_download(version, download_base, to_dir, download_delay)
118+
try:
119+
pkg_resources.require("setuptools>=" + version)
120+
return
121+
except pkg_resources.VersionConflict:
122+
e = sys.exc_info()[1]
123+
if was_imported:
124+
sys.stderr.write(
125+
"The required version of setuptools (>=%s) is not available,\n"
126+
"and can't be installed while this script is running. Please\n"
127+
"install a more recent version first, using\n"
128+
"'easy_install -U setuptools'."
129+
"\n\n(Currently using %r)\n" % (version, e.args[0]))
130+
sys.exit(2)
131+
else:
132+
del pkg_resources, sys.modules['pkg_resources'] # reload ok
133+
return _do_download(version, download_base, to_dir,
134+
download_delay)
135+
except pkg_resources.DistributionNotFound:
136+
return _do_download(version, download_base, to_dir,
137+
download_delay)
138+
139+
140+
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
141+
to_dir=os.curdir, delay=15):
142+
"""Download setuptools from a specified location and return its filename
143+
144+
`version` should be a valid setuptools version number that is available
145+
as an egg for download under the `download_base` URL (which should end
146+
with a '/'). `to_dir` is the directory where the egg will be downloaded.
147+
`delay` is the number of seconds to pause before an actual download
148+
attempt.
149+
"""
150+
# making sure we use the absolute path
151+
to_dir = os.path.abspath(to_dir)
152+
try:
153+
from urllib.request import urlopen
154+
except ImportError:
155+
from urllib2 import urlopen
156+
tgz_name = "setuptools-%s.tar.gz" % version
157+
url = download_base + tgz_name
158+
saveto = os.path.join(to_dir, tgz_name)
159+
src = dst = None
160+
if not os.path.exists(saveto): # Avoid repeated downloads
161+
try:
162+
log.warn("Downloading %s", url)
163+
src = urlopen(url)
164+
# Read/write all in one block, so we don't create a corrupt file
165+
# if the download is interrupted.
166+
data = src.read()
167+
dst = open(saveto, "wb")
168+
dst.write(data)
169+
finally:
170+
if src:
171+
src.close()
172+
if dst:
173+
dst.close()
174+
return os.path.realpath(saveto)
175+
176+
177+
def _extractall(self, path=".", members=None):
178+
"""Extract all members from the archive to the current working
179+
directory and set owner, modification time and permissions on
180+
directories afterwards. `path' specifies a different directory
181+
to extract to. `members' is optional and must be a subset of the
182+
list returned by getmembers().
183+
"""
184+
import copy
185+
import operator
186+
from tarfile import ExtractError
187+
directories = []
188+
189+
if members is None:
190+
members = self
191+
192+
for tarinfo in members:
193+
if tarinfo.isdir():
194+
# Extract directories with a safe mode.
195+
directories.append(tarinfo)
196+
tarinfo = copy.copy(tarinfo)
197+
tarinfo.mode = 448 # decimal for oct 0700
198+
self.extract(tarinfo, path)
199+
200+
# Reverse sort directories.
201+
if sys.version_info < (2, 4):
202+
def sorter(dir1, dir2):
203+
return cmp(dir1.name, dir2.name)
204+
directories.sort(sorter)
205+
directories.reverse()
206+
else:
207+
directories.sort(key=operator.attrgetter('name'), reverse=True)
208+
209+
# Set correct owner, mtime and filemode on directories.
210+
for tarinfo in directories:
211+
dirpath = os.path.join(path, tarinfo.name)
212+
try:
213+
self.chown(tarinfo, dirpath)
214+
self.utime(tarinfo, dirpath)
215+
self.chmod(tarinfo, dirpath)
216+
except ExtractError:
217+
e = sys.exc_info()[1]
218+
if self.errorlevel > 1:
219+
raise
220+
else:
221+
self._dbg(1, "tarfile: %s" % e)
222+
223+
224+
def _build_install_args(options):
225+
"""
226+
Build the arguments to 'python setup.py install' on the setuptools package
227+
"""
228+
install_args = []
229+
if options.user_install:
230+
if sys.version_info < (2, 6):
231+
log.warn("--user requires Python 2.6 or later")
232+
raise SystemExit(1)
233+
install_args.append('--user')
234+
return install_args
235+
236+
def _parse_args():
237+
"""
238+
Parse the command line for options
239+
"""
240+
parser = optparse.OptionParser()
241+
parser.add_option(
242+
'--user', dest='user_install', action='store_true', default=False,
243+
help='install in user site package (requires Python 2.6 or later)')
244+
parser.add_option(
245+
'--download-base', dest='download_base', metavar="URL",
246+
default=DEFAULT_URL,
247+
help='alternative URL from where to download the setuptools package')
248+
options, args = parser.parse_args()
249+
# positional arguments are ignored
250+
return options
251+
252+
def main(version=DEFAULT_VERSION):
253+
"""Install or upgrade setuptools and EasyInstall"""
254+
options = _parse_args()
255+
tarball = download_setuptools(download_base=options.download_base)
256+
return _install(tarball, _build_install_args(options))
257+
258+
if __name__ == '__main__':
259+
sys.exit(main())

gizeh/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
""" gizeh/__init__.py """
2+
3+
# __all__ = []
4+
5+
from .gizeh import *
6+
7+
from .version import __version__

gizeh/gizeh.py

Whitespace-only changes.

gizeh/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.1.0"

setup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import ez_setup
2+
ez_setup.use_setuptools()
3+
4+
from setuptools import setup, find_packages
5+
6+
exec(open('gizeh/version.py').read()) # loads __version__
7+
8+
setup(name='gizeh',
9+
version=__version__,
10+
author='Zulko',
11+
description='',
12+
long_description=open('README.rst').read(),
13+
license='see LICENSE.txt',
14+
keywords="",
15+
packages= find_packages(exclude='docs'))

0 commit comments

Comments
 (0)