On Jan 10, Davide Alberani <davide.alber...@gmail.com> wrote:
> I think I've sorted out how to manage external packages (optional)
> dependencies.
At least, I've figured how to give the user the ability to switch
off unwanted dependencies and features.
I'm not too sure this is the right way to use setuptools...
In the attachment, the new version.
If there are no complains or hints, I'll check it out today or
tomorrow.
--
Davide Alberani <davide.alber...@gmail.com> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/
#!/usr/bin/env python
import ez_setup
ez_setup.use_setuptools()
import setuptools
# version of the software; in SVN this represents the _next_ release.
# setuptools will automatically add 'dev-rREVISION'.
version = '4.0'
home_page = 'http://imdbpy.sf.net/'
long_desc = """IMDbPY is a Python package useful to retrieve and
manage the data of the IMDb movie database about movies, people,
characters and companies.
Platform-independent and written in pure Python (and few C lines),
it can retrieve data from both the IMDb's web server and a local copy
of the whole database.
IMDbPY package can be very easily used by programmers and developers
to provide access to the IMDb's data to their programs.
Some simple example scripts - useful for the end users - are included
in this package; other IMDbPY-based programs are available at the
home page: %s
""" % home_page
dwnl_url = 'http://imdbpy.sf.net/?page=download'
classifiers = """\
Development Status :: 5 - Production/Stable
Environment :: Console
Environment :: Web Environment
Environment :: Handhelds/PDA's
Intended Audience :: Developers
Intended Audience :: End Users/Desktop
License :: OSI Approved :: GNU General Public License (GPL)
Natural Language :: English
Programming Language :: Python
Programming Language :: C
Operating System :: OS Independent
Topic :: Database :: Front-Ends
Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
Topic :: Software Development :: Libraries :: Python Modules
"""
keywords = ['imdb', 'movie', 'people', 'database', 'cinema', 'film', 'person',
'cast', 'actor', 'actress', 'director', 'sql', 'character',
'company', 'svn', 'package', 'plain text data files']
cutils = setuptools.Extension('imdb.parser.common.cutils',
['imdb/parser/common/cutils.c'])
scripts = ['./bin/get_first_movie.py',
'./bin/get_movie.py', './bin/search_movie.py',
'./bin/get_first_person.py', './bin/get_person.py',
'./bin/search_person.py', './bin/get_character.py',
'./bin/get_first_character.py', './bin/get_company.py',
'./bin/search_character.py', './bin/search_company.py',
'./bin/get_first_company.py']
# XXX: I'm not sure that 'etc' is a good idea. Making it an absolute
# path seem a recipe for a disaster (with bdist_egg, at least).
data_files = [('doc', [f for f in setuptools.findall('docs')
if '.svn' not in f]), ('etc', ['docs/imdbpy.cfg'])]
# Defining these 'features', it's possible to run commands like:
# python ./setup.py --without-sql --without-local bdist
# having (in this example) imdb.parser.sql, imdb.parser.local (and
# their shared code in imdb.parser.common) removed.
featCutils = setuptools.dist.Feature('compile the C module', standard=True,
ext_modules=[cutils])
featCommon = setuptools.dist.Feature('common code for "sql" and "local"',
standard=False, remove='imdb.parser.common')
localScripts = ['./bin/characters4local.py', './bin/companies4local.py',
'./bin/misc-companies4local.py', './bin/mpaa4local.py']
featLocal = setuptools.dist.Feature('access to local mkdb data', standard=True,
require_features='common', remove='imdb.parser.local',
scripts=localScripts)
featLxml = setuptools.dist.Feature('add lxml dependency', standard=True,
install_requires=['lxml'])
# XXX: it seems there's no way to specify that we needs EITHER
# SQLObject OR SQLAlchemy.
featSQLObject = setuptools.dist.Feature('add SQLObject dependency',
standard=False, install_requires=['SQLObject'])
featSQLAlchemy = setuptools.dist.Feature('add SQLAlchemy dependency',
standard=False, install_requires=['SQLAlchemy '])
sqlScripts = ['./bin/imdbpy2sql.py']
featSQL = setuptools.dist.Feature('access to SQL databases', standard=True,
require_features=['common', 'sqlobject', 'sqlalchemy'],
remove='imdb.parser.sql', scripts=sqlScripts)
features = {
'common': featCommon,
'cutils': featCutils,
'sql': featSQL,
'local': featLocal,
'lxml': featLxml,
'sqlobject': featSQLObject,
'sqlalchemy': featSQLAlchemy
}
params = {
# Meta-information.
'name': 'IMDbPY',
'version': version,
'description': 'Python package to access the IMDb\'s database',
'long_description': long_desc,
'author': 'Davide Alberani',
'author_email': 'd...@erlug.linux.it',
'contact': 'IMDbPY-devel mailing list',
'contact_email': 'imdbpy-devel@lists.sourceforge.net',
'maintainer': 'Davide Alberani',
'maintainer_email': 'd...@erlug.linux.it',
'license': 'GPL',
'platforms': 'any',
'keywords': keywords,
'classifiers': filter(None, classifiers.split("\n")),
#'zip_safe': True, # XXX: I guess...
# Download URLs.
'url': home_page,
'download_url': dwnl_url,
# Scripts.
'scripts': scripts,
# Documentation files.
'data_files': data_files,
# C extensions.
#'ext_modules': [cutils],
# Requirements.
#'install_requires': install_requires,
#'extras_require': extras_require,
'features': features,
# Packages.
'packages': setuptools.find_packages()
}
ERR_MSG = """
====================================================================
ERROR
=====
Looks like we're unable to fetch or install some dependencies,
or to compile the C module.
The best solution, is to resolve these dependencies (maybe you're
not connected to Internet?) or install a C compiler.
You may, however, go on without some optional pieces of IMDbPY;
try re-running this script with the corresponding optional argument:
--without-lxml exclude lxml ( speeds up 'http' )
--without-cutils don't compile the C module (speeds up 'local/sql')
--without-sqlobject exclude SQLObject ( you need at least one of )
--without-sqlalchemy exclude SQLAlchemy ( SQLObject or SQLAlchemy, if )
( you want to access a local )
( SQL database )
The following arguments exclude altogether some features of IMDbPY,
in case you don't need them (if both are specified, the cutils C module
is not compiled, either):
--without-local no access to local (mkdb generated) data.
--without-sql no access to SQL databases (implies both
--without-sqlobject and --without-sqlalchemy)
Example:
python ./setup.py --without-lxml --without-local --without-sql install
The caught exception, is re-raise below:
"""
try:
setuptools.setup(**params)
except SystemExit:
print ERR_MSG
raise
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Imdbpy-devel mailing list
Imdbpy-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-devel