Browse Source

add --modules to install modules

Romain Bignon 7 years ago
parent
commit
beecb1b189
2 changed files with 163 additions and 108 deletions
  1. 2
    0
      MANIFEST.in.modules
  2. 161
    108
      setup.py

+ 2
- 0
MANIFEST.in.modules View File

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

+ 161
- 108
setup.py View File

@@ -57,12 +57,166 @@ def build_qt():
57 57
          'all',
58 58
          'PYUIC=%s%s' % (pyuic4, ' WIN32=1' if sys.platform == 'win32' else '')])
59 59
 
60
+def install_weboob():
61
+    scripts = set(os.listdir('scripts'))
62
+    packages = set(find_packages(exclude=['modules']))
63
+
64
+    hildon_scripts = set(('masstransit',))
65
+    qt_scripts = set(('qboobmsg', 'qhavedate', 'qvideoob', 'weboob-config-qt', 'qwebcontentedit', 'qflatboob', 'qcineoob', 'qcookboob', 'qhandjoob'))
66
+
67
+    if not options.hildon:
68
+        scripts = scripts - hildon_scripts
69
+    if options.qt:
70
+        build_qt()
71
+    else:
72
+        scripts = scripts - qt_scripts
73
+
74
+    hildon_packages = set((
75
+        'weboob.applications.masstransit',
76
+    ))
77
+    qt_packages = set((
78
+        'weboob.applications.qboobmsg',
79
+        'weboob.applications.qboobmsg.ui',
80
+        'weboob.applications.qcineoob',
81
+        'weboob.applications.qcineoob.ui',
82
+        'weboob.applications.qcookboob',
83
+        'weboob.applications.qcookboob.ui',
84
+        'weboob.applications.qhandjoob',
85
+        'weboob.applications.qhandjoob.ui',
86
+        'weboob.applications.qhavedate',
87
+        'weboob.applications.qhavedate.ui',
88
+        'weboob.applications.qvideoob',
89
+        'weboob.applications.qvideoob.ui',
90
+        'weboob.applications.qweboobcfg',
91
+        'weboob.applications.qweboobcfg.ui',
92
+        'weboob.applications.qwebcontentedit',
93
+        'weboob.applications.qwebcontentedit.ui'
94
+        'weboob.applications.qflatboob',
95
+        'weboob.applications.qflatboob.ui'
96
+    ))
97
+
98
+    if not options.hildon:
99
+        packages = packages - hildon_packages
100
+    if not options.qt:
101
+        packages = packages - qt_packages
102
+
103
+    data_files = [
104
+        ('share/man/man1', glob.glob('man/*')),
105
+    ]
106
+    if options.xdg:
107
+        data_files.extend([
108
+            ('share/applications', glob.glob('desktop/*')),
109
+            ('share/icons/hicolor/64x64/apps', glob.glob('icons/*')),
110
+        ])
111
+
112
+
113
+    # Do not put PyQt, it does not work properly.
114
+    requirements = [
115
+        'lxml',
116
+        'feedparser',
117
+        'mechanize',
118
+        'gdata',
119
+        'python-dateutil',
120
+        'PyYAML',
121
+    ]
122
+    try:
123
+        import Image
124
+    except ImportError:
125
+        requirements.append('Pillow')
126
+    else:
127
+        if 'PILcompat' not in Image.__file__:
128
+            requirements.append('PIL')
129
+        else:
130
+            requirements.append('Pillow')
131
+
132
+    if sys.version_info[0] > 2:
133
+        print >>sys.stderr, 'Python 3 is not supported.'
134
+        sys.exit(1)
135
+    if sys.version_info[1] < 6:  # older than 2.6
136
+        print >>sys.stderr, 'Python older than 2.6 is not supported.'
137
+        sys.exit(1)
138
+
139
+    if not options.deps:
140
+        requirements = []
141
+
142
+    setup(
143
+        name='weboob',
144
+        version='0.h',
145
+        description='Weboob, Web Outside Of Browsers',
146
+        long_description=open('README').read(),
147
+        author='Romain Bignon',
148
+        author_email='weboob@weboob.org',
149
+        maintainer='Romain Bignon',
150
+        maintainer_email='romain@weboob.org',
151
+        url='http://weboob.org/',
152
+        license='GNU AGPL 3',
153
+        classifiers=[
154
+            'Environment :: Console',
155
+            'Environment :: X11 Applications :: Qt',
156
+            'License :: OSI Approved :: GNU Affero General Public License v3',
157
+            'Programming Language :: Python :: 2.6',
158
+            'Programming Language :: Python :: 2.7',
159
+            'Programming Language :: Python',
160
+            'Topic :: Communications :: Email',
161
+            'Topic :: Internet :: WWW/HTTP',
162
+        ],
163
+
164
+        packages=packages,
165
+        scripts=[os.path.join('scripts', script) for script in scripts],
166
+        data_files=data_files,
167
+
168
+        install_requires=requirements,
169
+    )
170
+
171
+def prepare_install_modules(func):
172
+    def inner(*args, **kwargs):
173
+        here = os.path.abspath(os.path.dirname(__file__))
174
+        try:
175
+            open(os.path.join(here, 'modules', '__init__.py'), 'w').close()
176
+            os.rename(os.path.join(here, 'MANIFEST.in'), os.path.join(here, 'MANIFEST.in.weboob'))
177
+            os.rename(os.path.join(here, 'MANIFEST.in.modules'), os.path.join(here, 'MANIFEST.in'))
178
+
179
+            return func(*args, **kwargs)
180
+        finally:
181
+            os.unlink(os.path.join(here, 'modules', '__init__.py'))
182
+            os.rename(os.path.join(here, 'MANIFEST.in'), os.path.join(here, 'MANIFEST.in.modules'))
183
+            os.rename(os.path.join(here, 'MANIFEST.in.weboob'), os.path.join(here, 'MANIFEST.in'))
184
+    return inner
185
+
186
+@prepare_install_modules
187
+def install_modules():
188
+    setup(
189
+        name='weboob-modules',
190
+        version='0.h',
191
+        description='Weboob modules',
192
+        long_description=open('README').read(),
193
+        author='Romain Bignon',
194
+        author_email='weboob@weboob.org',
195
+        maintainer='Romain Bignon',
196
+        maintainer_email='romain@weboob.org',
197
+        url='http://weboob.org/modules',
198
+        license='GNU AGPL 3',
199
+        classifiers=[
200
+            'Environment :: Console',
201
+            'Environment :: X11 Applications :: Qt',
202
+            'License :: OSI Approved :: GNU Affero General Public License v3',
203
+            'Programming Language :: Python :: 2.6',
204
+            'Programming Language :: Python :: 2.7',
205
+            'Programming Language :: Python',
206
+            'Topic :: Communications :: Email',
207
+            'Topic :: Internet :: WWW/HTTP',
208
+        ],
209
+        package_dir={'weboob_modules': 'modules'},
210
+        packages=['weboob_modules'],
211
+        include_package_data=True,
212
+    )
60 213
 
61 214
 class Options(object):
62 215
     hildon = False
63 216
     qt = True
64 217
     xdg = True
65 218
     deps = True
219
+    modules = False
66 220
 
67 221
 options = Options()
68 222
 
@@ -103,114 +257,13 @@ if '--nodeps' in args:
103 257
     options.deps = False
104 258
     args.remove('--nodeps')
105 259
 
106
-sys.argv = args
107
-
108
-scripts = set(os.listdir('scripts'))
109
-packages = set(find_packages())
260
+if '--modules' in args:
261
+    options.modules = True
262
+    args.remove('--modules')
110 263
 
111
-hildon_scripts = set(('masstransit',))
112
-qt_scripts = set(('qboobmsg', 'qhavedate', 'qvideoob', 'weboob-config-qt', 'qwebcontentedit', 'qflatboob', 'qcineoob', 'qcookboob', 'qhandjoob'))
264
+sys.argv = args
113 265
 
114
-if not options.hildon:
115
-    scripts = scripts - hildon_scripts
116
-if options.qt:
117
-    build_qt()
266
+if options.modules:
267
+    install_modules()
118 268
 else:
119
-    scripts = scripts - qt_scripts
120
-
121
-hildon_packages = set((
122
-    'weboob.applications.masstransit',
123
-))
124
-qt_packages = set((
125
-    'weboob.applications.qboobmsg',
126
-    'weboob.applications.qboobmsg.ui',
127
-    'weboob.applications.qcineoob',
128
-    'weboob.applications.qcineoob.ui',
129
-    'weboob.applications.qcookboob',
130
-    'weboob.applications.qcookboob.ui',
131
-    'weboob.applications.qhandjoob',
132
-    'weboob.applications.qhandjoob.ui',
133
-    'weboob.applications.qhavedate',
134
-    'weboob.applications.qhavedate.ui',
135
-    'weboob.applications.qvideoob',
136
-    'weboob.applications.qvideoob.ui',
137
-    'weboob.applications.qweboobcfg',
138
-    'weboob.applications.qweboobcfg.ui',
139
-    'weboob.applications.qwebcontentedit',
140
-    'weboob.applications.qwebcontentedit.ui'
141
-    'weboob.applications.qflatboob',
142
-    'weboob.applications.qflatboob.ui'
143
-))
144
-
145
-if not options.hildon:
146
-    packages = packages - hildon_packages
147
-if not options.qt:
148
-    packages = packages - qt_packages
149
-
150
-data_files = [
151
-    ('share/man/man1', glob.glob('man/*')),
152
-]
153
-if options.xdg:
154
-    data_files.extend([
155
-        ('share/applications', glob.glob('desktop/*')),
156
-        ('share/icons/hicolor/64x64/apps', glob.glob('icons/*')),
157
-    ])
158
-
159
-
160
-# Do not put PyQt, it does not work properly.
161
-requirements = [
162
-    'lxml',
163
-    'feedparser',
164
-    'mechanize',
165
-    'gdata',
166
-    'python-dateutil',
167
-    'PyYAML',
168
-]
169
-try:
170
-    import Image
171
-except ImportError:
172
-    requirements.append('Pillow')
173
-else:
174
-    if 'PILcompat' not in Image.__file__:
175
-        requirements.append('PIL')
176
-    else:
177
-        requirements.append('Pillow')
178
-
179
-if sys.version_info[0] > 2:
180
-    print >>sys.stderr, 'Python 3 is not supported.'
181
-    sys.exit(1)
182
-if sys.version_info[1] < 6:  # older than 2.6
183
-    print >>sys.stderr, 'Python older than 2.6 is not supported.'
184
-    sys.exit(1)
185
-
186
-if not options.deps:
187
-    requirements = []
188
-
189
-setup(
190
-    name='weboob',
191
-    version='0.h',
192
-    description='Weboob, Web Outside Of Browsers',
193
-    long_description=open('README').read(),
194
-    author='Romain Bignon',
195
-    author_email='weboob@weboob.org',
196
-    maintainer='Romain Bignon',
197
-    maintainer_email='romain@weboob.org',
198
-    url='http://weboob.org/',
199
-    license='GNU AGPL 3',
200
-    classifiers=[
201
-        'Environment :: Console',
202
-        'Environment :: X11 Applications :: Qt',
203
-        'License :: OSI Approved :: GNU Affero General Public License v3',
204
-        'Programming Language :: Python :: 2.6',
205
-        'Programming Language :: Python :: 2.7',
206
-        'Programming Language :: Python',
207
-        'Topic :: Communications :: Email',
208
-        'Topic :: Internet :: WWW/HTTP',
209
-    ],
210
-
211
-    packages=packages,
212
-    scripts=[os.path.join('scripts', script) for script in scripts],
213
-    data_files=data_files,
214
-
215
-    install_requires=requirements,
216
-)
269
+    install_weboob()