diff options
author | Six <unknown> | 2010-12-11 18:01:32 -0500 |
---|---|---|
committer | Six <unknown> | 2010-12-11 18:01:32 -0500 |
commit | 09a34696d529e1686970df5cf1555e160fd0c8f3 (patch) | |
tree | 30e3a8049e64a565505ee4a05bee9ec592a4bc89 | |
parent | bb5163b54d30bdced46e6f75ddc1676f8c5fef5d (diff) | |
download | dodai-macsupport-09a34696d529e1686970df5cf1555e160fd0c8f3.tar.bz2 dodai-macsupport-09a34696d529e1686970df5cf1555e160fd0c8f3.tar.xz dodai-macsupport-09a34696d529e1686970df5cf1555e160fd0c8f3.zip |
reorg of files, added traditional setup.py and removed pavement files
-rw-r--r-- | MANIFEST.in | 2 | ||||
-rw-r--r-- | README | 24 | ||||
-rw-r--r-- | lib/dodai/__init__.py (renamed from dodai/__init__.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/__init__.py (renamed from dodai/config/__init__.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/databases/__init__.py (renamed from dodai/config/databases/__init__.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/databases/sa.py (renamed from dodai/config/databases/sa.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/files.py (renamed from dodai/config/files.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/log.py (renamed from dodai/config/log.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/option.py (renamed from dodai/config/option.py) | 0 | ||||
-rw-r--r-- | lib/dodai/config/sections.py (renamed from dodai/config/sections.py) | 0 | ||||
-rw-r--r-- | lib/dodai/db.py (renamed from dodai/db.py) | 0 | ||||
-rw-r--r-- | lib/dodai/exception.py (renamed from dodai/exception.py) | 0 | ||||
-rw-r--r-- | lib/dodai/tools/__init__.py (renamed from dodai/tools/__init__.py) | 0 | ||||
-rw-r--r-- | lib/dodai/tools/himo.py (renamed from dodai/tools/himo.py) | 0 | ||||
-rw-r--r-- | lib/dodai/tools/odict.py (renamed from dodai/tools/odict.py) | 0 | ||||
-rw-r--r-- | pavement.py | 116 | ||||
-rw-r--r-- | setup.py | 216 |
17 files changed, 220 insertions, 138 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 4e3618d..f40b39b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in | |||
@@ -1,5 +1,3 @@ | |||
1 | include setup.py | 1 | include setup.py |
2 | include pavement.py | ||
3 | include paver-minilib.zip | ||
4 | include LICENSE | 2 | include LICENSE |
5 | prune test | 3 | prune test |
@@ -1,10 +1,9 @@ | |||
1 | DODAI | 1 | DODAI |
2 | 2 | ||
3 | A Python module to help with writing command line scripts | 3 | Module code for quick easy access to parsed text based config file data |
4 | 4 | and configured database engines. All config file data is returned ordered | |
5 | This module is to be a foundation to your command line python | 5 | and transformed to unicode objects and database connections are returned as |
6 | scripts. This module provides for quick access to logger, configparser, | 6 | sqlalchemy or couchdb objects. |
7 | optionparse and databases via sqlalchemy. | ||
8 | 7 | ||
9 | 8 | ||
10 | INSTALLATION | 9 | INSTALLATION |
@@ -22,18 +21,3 @@ There are three ways to install dodai | |||
22 | tar zxvf dodai-* | 21 | tar zxvf dodai-* |
23 | cd dodai-* | 22 | cd dodai-* |
24 | python setup.py install | 23 | python setup.py install |
25 | |||
26 | 3. If you have Paver installed then download compressed file from | ||
27 | http://code.google.com/p/dodai/downloads/list | ||
28 | |||
29 | tar zxvf dodai-* | ||
30 | cd dodai-* | ||
31 | paver install | ||
32 | |||
33 | |||
34 | The installation will also install sqlalchemy. This installation will not | ||
35 | install the required system and python libs needed to get sqlalchemy to work | ||
36 | with your desired database. This includes things like: cx_Oracle, psycopg2, | ||
37 | pyodbc, mysql-python etc. For more information on installing these check out | ||
38 | the docs at http://code.google.com/p/dodai | ||
39 | |||
diff --git a/dodai/__init__.py b/lib/dodai/__init__.py index 55bb57d..55bb57d 100644 --- a/dodai/__init__.py +++ b/lib/dodai/__init__.py | |||
diff --git a/dodai/config/__init__.py b/lib/dodai/config/__init__.py index e849f8e..e849f8e 100644 --- a/dodai/config/__init__.py +++ b/lib/dodai/config/__init__.py | |||
diff --git a/dodai/config/databases/__init__.py b/lib/dodai/config/databases/__init__.py index c91e77f..c91e77f 100644 --- a/dodai/config/databases/__init__.py +++ b/lib/dodai/config/databases/__init__.py | |||
diff --git a/dodai/config/databases/sa.py b/lib/dodai/config/databases/sa.py index eaf35ea..eaf35ea 100644 --- a/dodai/config/databases/sa.py +++ b/lib/dodai/config/databases/sa.py | |||
diff --git a/dodai/config/files.py b/lib/dodai/config/files.py index a27e4a2..a27e4a2 100644 --- a/dodai/config/files.py +++ b/lib/dodai/config/files.py | |||
diff --git a/dodai/config/log.py b/lib/dodai/config/log.py index fdb5c93..fdb5c93 100644 --- a/dodai/config/log.py +++ b/lib/dodai/config/log.py | |||
diff --git a/dodai/config/option.py b/lib/dodai/config/option.py index 0561881..0561881 100644 --- a/dodai/config/option.py +++ b/lib/dodai/config/option.py | |||
diff --git a/dodai/config/sections.py b/lib/dodai/config/sections.py index d789a24..d789a24 100644 --- a/dodai/config/sections.py +++ b/lib/dodai/config/sections.py | |||
diff --git a/dodai/db.py b/lib/dodai/db.py index 5cbe605..5cbe605 100644 --- a/dodai/db.py +++ b/lib/dodai/db.py | |||
diff --git a/dodai/exception.py b/lib/dodai/exception.py index 23302c7..23302c7 100644 --- a/dodai/exception.py +++ b/lib/dodai/exception.py | |||
diff --git a/dodai/tools/__init__.py b/lib/dodai/tools/__init__.py index bcef547..bcef547 100644 --- a/dodai/tools/__init__.py +++ b/lib/dodai/tools/__init__.py | |||
diff --git a/dodai/tools/himo.py b/lib/dodai/tools/himo.py index f56eaf8..f56eaf8 100644 --- a/dodai/tools/himo.py +++ b/lib/dodai/tools/himo.py | |||
diff --git a/dodai/tools/odict.py b/lib/dodai/tools/odict.py index 2c8391d..2c8391d 100644 --- a/dodai/tools/odict.py +++ b/lib/dodai/tools/odict.py | |||
diff --git a/pavement.py b/pavement.py deleted file mode 100644 index b880183..0000000 --- a/pavement.py +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | # Copyright (C) 2010 Leonard Thomas | ||
2 | # | ||
3 | # This file is part of Dodai. | ||
4 | # | ||
5 | # Dodai is free software: you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation, either version 3 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # Dodai is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with Dodai. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | PACKAGE = 'dodai' | ||
19 | LICENSE='GPLv3' | ||
20 | VERSION = '0.3' | ||
21 | AUTHOR='Leonard Thomas' | ||
22 | AUTHOR_EMAIL='six@choushi.net' | ||
23 | URL='http://code.google.com/p/dodai' | ||
24 | DOWNLOAD_URL = 'http://code.google.com/p/dodai/downloads/list' | ||
25 | PY_VERSION_LOW = '2.6.0' | ||
26 | PY_VERSION_HIGH = '3.0.0' | ||
27 | PLATFORMS = ['Linux'] | ||
28 | SETUP_REQUIRES=['sqlalchemy', 'chardet'] | ||
29 | CLASSIFIERS = [ | ||
30 | 'Development Status :: 4 - Beta', | ||
31 | 'Environment :: Console', | ||
32 | 'Intended Audience :: Developers', | ||
33 | 'License :: OSI Approved :: GNU Affero General Public License v3', | ||
34 | 'Natural Language :: English', | ||
35 | 'Operating System :: POSIX', | ||
36 | 'Operating System :: POSIX :: Linux', | ||
37 | 'Programming Language :: Python', | ||
38 | 'Programming Language :: Python :: 2.6', | ||
39 | 'Topic :: Database', | ||
40 | 'Topic :: Software Development', | ||
41 | 'Topic :: Software Development :: Libraries', | ||
42 | 'Topic :: Software Development :: Libraries :: Application Frameworks', | ||
43 | 'Topic :: Software Development :: Libraries :: Python Modules',] | ||
44 | DESCRIPTION = 'Tools for writing python scripts' | ||
45 | LONG_DESCRIPTION = "This module is to be a foundation to your command line "\ | ||
46 | "python scripts. This module provides for quick access to logger, "\ | ||
47 | "configparser, optionparse and databases via sqlalchemy."\ | ||
48 | |||
49 | |||
50 | |||
51 | import sys | ||
52 | import platform | ||
53 | import paver | ||
54 | import paver.setuputils | ||
55 | from paver.easy import options | ||
56 | from paver.easy import Bunch | ||
57 | from paver.easy import task | ||
58 | from paver.easy import needs | ||
59 | from paver.misctasks import generate_setup | ||
60 | from paver.misctasks import minilib | ||
61 | from setuptools import setup | ||
62 | from setuptools import find_packages | ||
63 | |||
64 | #from paver.easy import * | ||
65 | #from paver.misctasks import generate_setup, minilib | ||
66 | #from setuptools import setup, find_packages | ||
67 | #import paver.setuputils | ||
68 | paver.setuputils.install_distutils_tasks() | ||
69 | |||
70 | options( | ||
71 | setup=Bunch( | ||
72 | name=PACKAGE, | ||
73 | version=VERSION, | ||
74 | zip_safe=False, | ||
75 | description=DESCRIPTION, | ||
76 | author=AUTHOR, | ||
77 | author_email=AUTHOR_EMAIL, | ||
78 | url=URL, | ||
79 | download_url=DOWNLOAD_URL, | ||
80 | packages=find_packages(), | ||
81 | classifiers=CLASSIFIERS, | ||
82 | long_description=LONG_DESCRIPTION, | ||
83 | license=LICENSE, | ||
84 | setup_requires=SETUP_REQUIRES, | ||
85 | install_requires=['sqlalchemy', 'chardet'], | ||
86 | platforms = PLATFORMS | ||
87 | |||
88 | )) | ||
89 | |||
90 | |||
91 | def is_valid_version(): | ||
92 | if sys.version >= PY_VERSION_LOW and sys.version < PY_VERSION_HIGH: | ||
93 | return True | ||
94 | else: | ||
95 | return False | ||
96 | |||
97 | def is_valid_platform(): | ||
98 | if platform.system() in PLATFORMS: | ||
99 | return True | ||
100 | else: | ||
101 | return False | ||
102 | |||
103 | @task | ||
104 | def build(): | ||
105 | if not is_valid_version(): | ||
106 | raise Exception('Invalid Python version') | ||
107 | if not is_valid_platform(): | ||
108 | error='{0} not install on: {1}'.format(PACKAGE, platform.system()) | ||
109 | raise Exception(error) | ||
110 | |||
111 | |||
112 | @task | ||
113 | @needs('build', 'generate_setup', 'minilib', 'setuptools.command.sdist') | ||
114 | def sdist(): | ||
115 | """Overrides sdist to make sure that our setup.py is generated.""" | ||
116 | pass | ||
diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7cae721 --- /dev/null +++ b/setup.py | |||
@@ -0,0 +1,216 @@ | |||
1 | # | ||
2 | # Copyright 2010 Leonard Thomas | ||
3 | # | ||
4 | # This file is part of Dodai. | ||
5 | # | ||
6 | # Dodai is free software: you can redistribute it and/or modify | ||
7 | # it under the terms of the GNU General Public License as published by | ||
8 | # the Free Software Foundation, either version 3 of the License, or | ||
9 | # (at your option) any later version. | ||
10 | # | ||
11 | # Dodai is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | # | ||
16 | # You should have received a copy of the GNU General Public License | ||
17 | # along with Dodai. If not, see <http://www.gnu.org/licenses/>. | ||
18 | |||
19 | import os | ||
20 | import sys | ||
21 | import platform | ||
22 | from setuptools import setup | ||
23 | from setuptools import find_packages | ||
24 | from ctypes.util import find_library | ||
25 | from ctypes.util import _findLib_ldconfig as find_library_ldconfig | ||
26 | from subprocess import Popen, PIPE | ||
27 | from copy import deepcopy | ||
28 | |||
29 | ARGS = { | ||
30 | 'name': 'dodai', | ||
31 | 'version': '0.4.1', | ||
32 | 'install_requires': [ | ||
33 | 'sqlalchemy', | ||
34 | 'chardet', | ||
35 | 'couchdb', | ||
36 | 'ordereddict', | ||
37 | 'psycopg2', | ||
38 | 'mysql-python', | ||
39 | 'cx_oracle' | ||
40 | ], | ||
41 | 'platforms': [ | ||
42 | 'Linux', | ||
43 | 'Darwin', | ||
44 | ], | ||
45 | 'author': 'Leonard Thomas', | ||
46 | 'author_email': 'six@choushi.net', | ||
47 | 'url': 'http://code.google.com/p/dodai', | ||
48 | 'download_url': 'http://code.google.com/p/dodai/downloads/list', | ||
49 | 'license': 'GPLv3', | ||
50 | 'classifiers': [ | ||
51 | 'Development Status :: 4 - Beta', | ||
52 | 'Intended Audience :: Developers', | ||
53 | 'License :: OSI Approved :: GNU Affero General Public License v3', | ||
54 | 'Natural Language :: English', | ||
55 | 'Operating System :: POSIX', | ||
56 | 'Operating System :: POSIX :: Linux', | ||
57 | 'Operating System :: MacOS', | ||
58 | 'Programming Language :: Python', | ||
59 | 'Programming Language :: Python :: 2.6', | ||
60 | 'Programming Language :: Python :: 2.7', | ||
61 | 'Topic :: Database', | ||
62 | 'Topic :: Software Development', | ||
63 | 'Topic :: Software Development :: Libraries', | ||
64 | 'Topic :: Software Development :: Libraries :: Python Modules', | ||
65 | ], | ||
66 | 'description': "Module code for quick easy access to parsed text based "\ | ||
67 | "config file data and configured database engines.", | ||
68 | 'long_description': "This module provides code for quick easy access to "\ | ||
69 | "parsed text based config file data and configured database "\ | ||
70 | "engines. All config file data is returned ordered and transformed "\ | ||
71 | "to unicode objects and database connections are returned as "\ | ||
72 | "sqlalchemy objects.", | ||
73 | 'entry_points': { | ||
74 | 'distutils.commands': [ | ||
75 | 'devstrap = dodai.build:devstrap', | ||
76 | ] | ||
77 | }, | ||
78 | 'zip_safe': False, | ||
79 | 'packages': find_packages('lib'), | ||
80 | 'package_dir': {'':'lib'}, | ||
81 | } | ||
82 | PYTHON_VERSION_LOW = '2.6' | ||
83 | PYTHON_VERSION_HIGH = '3.0' | ||
84 | |||
85 | class BaseLibCheck(object): | ||
86 | |||
87 | def _has_library(self, lib): | ||
88 | if find_library(lib): | ||
89 | return True | ||
90 | return False | ||
91 | |||
92 | def _which(self, name): | ||
93 | cmd = ['which', name] | ||
94 | return Popen(cmd, stdout=PIPE).communicate()[0] | ||
95 | |||
96 | |||
97 | class PostgressLibCheck(BaseLibCheck): | ||
98 | |||
99 | PACKAGE = 'psycopg2' | ||
100 | LIB = 'pq' | ||
101 | |||
102 | def __call__(self, package): | ||
103 | if package.lower().startswith(self.PACKAGE): | ||
104 | if self._has_library(self.LIB): | ||
105 | return True | ||
106 | return False | ||
107 | |||
108 | |||
109 | class MysqlLibCheck(BaseLibCheck): | ||
110 | |||
111 | PACKAGE = 'mysql-python' | ||
112 | LIB = 'mysqlpp' | ||
113 | |||
114 | def __call__(self, package): | ||
115 | if package.lower().startswith(self.PACKAGE): | ||
116 | if self._has_library(self.LIB): | ||
117 | if self._which('mysql_config'): | ||
118 | return True | ||
119 | return False | ||
120 | |||
121 | |||
122 | class OracleLibCheck(BaseLibCheck): | ||
123 | |||
124 | PACKAGE = 'cx_oracle' | ||
125 | LIB = 'clntsh' | ||
126 | |||
127 | def __call__(self, package): | ||
128 | if package.lower().startswith(self.PACKAGE): | ||
129 | if 'ORACLE_HOME' in os.environ: | ||
130 | if os.environ['ORACLE_HOME']: | ||
131 | return True | ||
132 | else: | ||
133 | if self._has_library(self.LIB): | ||
134 | self._set_oracle_home() | ||
135 | return True | ||
136 | return False | ||
137 | |||
138 | def _set_oracle_home(self): | ||
139 | path = find_library_ldconfig(self.LIB) | ||
140 | os.environ['ORACLE_HOME'] = os.path.dirname(path) | ||
141 | |||
142 | |||
143 | class OrderedDictLibCheck(BaseLibCheck): | ||
144 | |||
145 | PACKAGE = 'ordereddict' | ||
146 | |||
147 | def __call__(self, package): | ||
148 | if package.lower().startswith(self.PACKAGE): | ||
149 | if sys.version < '2.7': | ||
150 | return True | ||
151 | return False | ||
152 | |||
153 | |||
154 | class ArgparseLibCheck(BaseLibCheck): | ||
155 | |||
156 | PACKAGE = 'argparse' | ||
157 | |||
158 | def __call__(self, package): | ||
159 | if package.lower().startswith(self.PACKAGE): | ||
160 | if sys.version < '2.7': | ||
161 | return True | ||
162 | return False | ||
163 | |||
164 | |||
165 | class PassLibCheck(BaseLibCheck): | ||
166 | |||
167 | def __init__(self, chain): | ||
168 | self._packages = [] | ||
169 | for obj in chain: | ||
170 | self._packages.append(obj.PACKAGE.lower()) | ||
171 | |||
172 | def __call__(self, package): | ||
173 | if package.lower() not in self._packages: | ||
174 | return True | ||
175 | |||
176 | def get_install_requires(): | ||
177 | out = [] | ||
178 | chain = [ | ||
179 | PostgressLibCheck(), | ||
180 | MysqlLibCheck(), | ||
181 | OracleLibCheck(), | ||
182 | OrderedDictLibCheck(), | ||
183 | ArgparseLibCheck(), | ||
184 | ] | ||
185 | chain.append(PassLibCheck(chain)) | ||
186 | for package in ARGS['install_requires']: | ||
187 | for can_install in chain: | ||
188 | if can_install(package): | ||
189 | out.append(package) | ||
190 | return out | ||
191 | |||
192 | def valid_python_version(): | ||
193 | if sys.version < PYTHON_VERSION_LOW: | ||
194 | return False | ||
195 | if sys.version >= PYTHON_VERSION_HIGH: | ||
196 | return False | ||
197 | return True | ||
198 | |||
199 | def build_args(): | ||
200 | args = deepcopy(ARGS) | ||
201 | args['install_requires'] = get_install_requires() | ||
202 | return args | ||
203 | |||
204 | if not valid_python_version(): | ||
205 | message = """ | ||
206 | {package} is not able to install: Because the version of | ||
207 | Python that is being used, '{version}', is not compatable | ||
208 | with {package}. {package} will only install with Python | ||
209 | versions {low} through {high}\n | ||
210 | """.format(package=ARGS['name'].lower().capitalize(), | ||
211 | low=PYTHON_VERSION_LOW, high=PYTHON_VERSION_HIGH) | ||
212 | sys.stderr.write(message) | ||
213 | sys.exit(1) | ||
214 | else: | ||
215 | setup(**build_args()) | ||
216 | |||