#!/usr/bin/env python
from distutils.core import setup
from distutils.dist import DistributionMetadata
import sys
import os
# Hoping this will temporarly change the language to English for my unit tests
# to pass. And get the thing to install - then the user can set LC_ALL to
# whatever they wish once it has been installed.
# XXX .... no idea if this will work!
os.environ['LC_ALL']='C'
# The package source code directory
package_dir='lib'
# Import the package
package=__import__(package_dir)
# Populate the setup_args based on what's available
# on this system
setup_args={
'package_dir' : {package.__name__: package_dir},
'packages' : [package.__name__],
}
for name in DistributionMetadata._METHOD_BASENAMES:
key='__%s__' % name
if package.__dict__.has_key(key):
setup_args[name]=package.__dict__[key]
# Make sure the distribution gets the correct name
setup_args['name']=package.__dist_name__
# Find locale files:
setup_args[ "data_files" ] = []
def po_find( result, dirname, fnames ):
files = []
for f in fnames:
p = os.path.join( dirname, f )
if os.path.isfile( p ) and f.endswith( ".mo" ):
files.append( p )
if files:
result.append( ( dirname, files ) )
# po_find()
os.path.walk( "share/locale", po_find, setup_args[ "data_files" ] )
# Run unit test cases
# NB. This now includes a bold attempt to run unit tests on all systems
# (ie. including Windows).
if os.name == 'posix' or True:
os.chdir('lib')
err=os.system('python -c "import grab, customizedparser, re2, timezone"') # XXX Specific to this package
os.chdir('..')
if err:
debug_info=setup_args.copy()
debug_info.update(
{'os_name': os.name,
'sys_platform': sys.platform,
'sys_version_info': sys.version_info,
'sys_version': sys.version,
'bugreport_url': package.__bugreport_url__,
}
)
sys.stderr.write("""
ERROR: %(name)s failed to install on your system.
os_name = %(os_name)s
sys_platform = %(sys_platform)s
sys_version_info = %(sys_version_info)s
sys_version = %(sys_version)s
Please submit a bug report including details of your system
and the failed test cases shown above to:
%(bugreport_url)s
""" % debug_info)
sys.exit(1)
# Now finally, run the setup() using the setup_args
setup(**setup_args)
|