Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Cleanups b4 alpha release merge; move dependency checks to sub module
Browse files Browse the repository at this point in the history
- __init__.py: Remove list of packages, add package and data dir attrs
- postgresql.py: Add dependency check
- json.py: Add dependency check
- flow.dot: Move into docs dir
- run_tests: Move into scripts dir, a little smarter on finding path
- setup.py: Don't keep hard coded lists of files, other cleanups
  • Loading branch information
jmcfarlane committed Aug 9, 2008
1 parent 816b3d2 commit 4669288
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 81 deletions.
20 changes: 3 additions & 17 deletions chula/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,8 @@
Chula is an MVC style framework that works by routing web requests
thru mod_python to native Python objects"""

__VERSION__ = '0.0.4-alpha01'
__VERSION__ = '0.0.4-alpha02'
version = __VERSION__

__all__ = ['cache',
'collection',
'config',
'data',
'db',
'ecalendar',
'error',
'example',
'guid',
'json',
'memcache',
'pager',
'passwd',
'regex',
'session',
'webservice']
package_dir = 'chula'
data_dir = 'sql'
3 changes: 2 additions & 1 deletion chula/db/engines/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import re

from chula import error

try:
import psycopg2
from psycopg2 import extensions, extras
except:
raise error.MissingDependencyError('Psycopg2')

from chula import error
from chula.db.engines import engine

class DataStore(engine.Engine):
Expand Down
8 changes: 7 additions & 1 deletion chula/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
Wrapper to make it easy to switch from one json library to another
"""

from chula import error


USE='simplejson'

if USE == 'simplejson':
import simplejson
try:
import simplejson
except:
raise error.MissingDependencyError('Simplejson')
decode = simplejson.loads
encode = simplejson.dumps

Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions mqueue_test.py

This file was deleted.

19 changes: 15 additions & 4 deletions run_tests → scripts/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import os
import re
import sys

import chula

def get_tests(path):
"""
Creates and returns a list of all tests in a directory tree
List items are tuples of the form (Path, Filename)
"""
tests = []
path = path.rstrip('/')
tree = os.walk(path)
tree = os.walk(path.rstrip(os.sep))
regex = re.compile(r'^.*/test(_[a-z]+)?$')
#regex = re.compile(r'^[^\.]*/test(_[a-z]+)?$')
for directory in tree:
if not re.match(regex, directory[0]) is None:
for file in directory[2]:
Expand Down Expand Up @@ -61,7 +61,18 @@ if __name__ == "__main__":
path = argv[0]
except IndexError, ex:
path = os.getcwd()


# Compensate for the fact that the scripts directory is
# parallel to the source directory
if not path.endswith(chula.package_dir.capitalize()):
path = path.split(os.sep)[:-1]
path.append(chula.package_dir)
path = os.sep.join(path)

#print 'Path used:', path
#sys.exit(1)

# Run the tests
tests = get_tests(path)
run_tests(tests)

92 changes: 48 additions & 44 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

from distutils.command.install import INSTALL_SCHEMES
from distutils.core import setup
import os
import sys

import chula
from chula import error

# Check for dependencies
if 'install' in sys.argv:
if sys.version_info < (2, 5):
raise error.MissingDependencyError('Python-2.5 or higher')

# Attributes
download_url = 'http://rockfloat.com/chula/chula-%s.tar.gz' % chula.version
classifiers = """
Development Status :: 3 - Beta
Intended Audience :: Developers
Expand All @@ -29,50 +44,39 @@
Operating System :: Unix
"""

import sys

from distutils.core import setup

import chula

# Check for dependencies
if 'install' in sys.argv:
from chula import error

if sys.version_info < (2, 5):
raise error.MissingDependencyError('Python-2.5 or higher')

# Simplejson
try:
import simplejson
except:
raise error.MissingDependencyError('Simplejson')

# Psycopg
try:
import psycopg2
except:
raise error.MissingDependencyError('Psycopg2')

# Data files
sql_session = ['sql/session/reload', 'sql/session/schema.sql']
sql_test = ['sql/test/reload', 'sql/test/schema.sql']
data_files = []
for basedir, dirs, files in os.walk(chula.data_dir):
if basedir.count(os.sep) > 0:
files = [os.path.join(basedir, file) for file in files]
basedir = os.path.join(chula.package_dir, basedir)
data_files.append((basedir, files))

# Packages
packages = []
for basedir, dirs, files in os.walk(chula.package_dir):
if '__init__.py' in files:
packages.append(basedir.replace(os.sep, '.'))

version = chula.version
setup(author='John McFarlane',
author_email='john.mcfarlane@rockfloat.com',
classifiers=filter(None, classifiers.split("\n")),
data_files=[('share/chula/sql/session', sql_session),
('share/chula/sql/test', sql_test)],
description=chula.__doc__.split('\n')[0],
long_description='\n'.join(chula.__doc__.split('\n')[2:]),
download_url = "http://rockfloat.com/chula/chula-%s.tar.gz" % version,
license='GPL',
maintainer="John McFarlane",
name='chula',
package_dir={'chula':'chula'},
packages=['chula', 'chula.test', 'chula.www'],
platforms = ["any"],
url='http://rockfloat.com/projects/chula/',
version=version)
# Tell distutils to put the data_files in platform-specific installation
# locations. See here for an explanation:
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
# Credit: Django
for scheme in INSTALL_SCHEMES.values():
scheme['data'] = scheme['purelib']

setup(
author = 'John McFarlane',
author_email = 'john.mcfarlane@rockfloat.com',
classifiers = filter(None, classifiers.split("\n")),
data_files = data_files,
description = chula.__doc__.split('\n')[0],
long_description = '\n'.join(chula.__doc__.split('\n')[2:]),
download_url = download_url,
license = 'GPL',
maintainer = "John McFarlane",
name = 'Chula',
packages = packages,
url='http://rockfloat.com/projects/chula/',
version = chula.version
)

0 comments on commit 4669288

Please sign in to comment.