add --modules to install modules

This commit is contained in:
Romain Bignon 2013-08-18 16:38:51 +02:00
commit beecb1b189
2 changed files with 163 additions and 108 deletions

2
MANIFEST.in.modules Normal file
View file

@ -0,0 +1,2 @@
recursive-include modules *.py
recursive-include modules *.png

151
setup.py
View file

@ -57,56 +57,9 @@ def build_qt():
'all',
'PYUIC=%s%s' % (pyuic4, ' WIN32=1' if sys.platform == 'win32' else '')])
class Options(object):
hildon = False
qt = True
xdg = True
deps = True
options = Options()
args = list(sys.argv)
if '--hildon' in args and '--no-hildon' in args:
print >>sys.stderr, '--hildon and --no-hildon options are incompatible'
sys.exit(1)
if '--qt' in args and '--no-qt' in args:
print >>sys.stderr, '--qt and --no-qt options are incompatible'
sys.exit(1)
if '--xdg' in args and '--no-xdg' in args:
print >>sys.stderr, '--xdg and --no-xdg options are incompatible'
sys.exit(1)
if '--hildon' in args or os.environ.get('HILDON') == 'true':
options.hildon = True
if '--hildon' in args:
args.remove('--hildon')
elif '--no-hildon' in args:
options.hildon = False
args.remove('--no-hildon')
if '--qt' in args:
options.qt = True
args.remove('--qt')
elif '--no-qt' in args:
options.qt = False
args.remove('--no-qt')
if '--xdg' in args:
options.xdg = True
args.remove('--xdg')
elif '--no-xdg' in args:
options.xdg = False
args.remove('--no-xdg')
if '--nodeps' in args:
options.deps = False
args.remove('--nodeps')
sys.argv = args
def install_weboob():
scripts = set(os.listdir('scripts'))
packages = set(find_packages())
packages = set(find_packages(exclude=['modules']))
hildon_scripts = set(('masstransit',))
qt_scripts = set(('qboobmsg', 'qhavedate', 'qvideoob', 'weboob-config-qt', 'qwebcontentedit', 'qflatboob', 'qcineoob', 'qcookboob', 'qhandjoob'))
@ -214,3 +167,103 @@ setup(
install_requires=requirements,
)
def prepare_install_modules(func):
def inner(*args, **kwargs):
here = os.path.abspath(os.path.dirname(__file__))
try:
open(os.path.join(here, 'modules', '__init__.py'), 'w').close()
os.rename(os.path.join(here, 'MANIFEST.in'), os.path.join(here, 'MANIFEST.in.weboob'))
os.rename(os.path.join(here, 'MANIFEST.in.modules'), os.path.join(here, 'MANIFEST.in'))
return func(*args, **kwargs)
finally:
os.unlink(os.path.join(here, 'modules', '__init__.py'))
os.rename(os.path.join(here, 'MANIFEST.in'), os.path.join(here, 'MANIFEST.in.modules'))
os.rename(os.path.join(here, 'MANIFEST.in.weboob'), os.path.join(here, 'MANIFEST.in'))
return inner
@prepare_install_modules
def install_modules():
setup(
name='weboob-modules',
version='0.h',
description='Weboob modules',
long_description=open('README').read(),
author='Romain Bignon',
author_email='weboob@weboob.org',
maintainer='Romain Bignon',
maintainer_email='romain@weboob.org',
url='http://weboob.org/modules',
license='GNU AGPL 3',
classifiers=[
'Environment :: Console',
'Environment :: X11 Applications :: Qt',
'License :: OSI Approved :: GNU Affero General Public License v3',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python',
'Topic :: Communications :: Email',
'Topic :: Internet :: WWW/HTTP',
],
package_dir={'weboob_modules': 'modules'},
packages=['weboob_modules'],
include_package_data=True,
)
class Options(object):
hildon = False
qt = True
xdg = True
deps = True
modules = False
options = Options()
args = list(sys.argv)
if '--hildon' in args and '--no-hildon' in args:
print >>sys.stderr, '--hildon and --no-hildon options are incompatible'
sys.exit(1)
if '--qt' in args and '--no-qt' in args:
print >>sys.stderr, '--qt and --no-qt options are incompatible'
sys.exit(1)
if '--xdg' in args and '--no-xdg' in args:
print >>sys.stderr, '--xdg and --no-xdg options are incompatible'
sys.exit(1)
if '--hildon' in args or os.environ.get('HILDON') == 'true':
options.hildon = True
if '--hildon' in args:
args.remove('--hildon')
elif '--no-hildon' in args:
options.hildon = False
args.remove('--no-hildon')
if '--qt' in args:
options.qt = True
args.remove('--qt')
elif '--no-qt' in args:
options.qt = False
args.remove('--no-qt')
if '--xdg' in args:
options.xdg = True
args.remove('--xdg')
elif '--no-xdg' in args:
options.xdg = False
args.remove('--no-xdg')
if '--nodeps' in args:
options.deps = False
args.remove('--nodeps')
if '--modules' in args:
options.modules = True
args.remove('--modules')
sys.argv = args
if options.modules:
install_modules()
else:
install_weboob()