-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
163 lines (138 loc) · 6.44 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import os, sys
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.txt')).read()
NEWS = open(os.path.join(here, 'NEWS.txt')).read()
install_requires = [
# List your project dependencies here.
# For more details, see:
# http://packages.python.org/distribute/setuptools.html#declaring-dependencies
'pygoo>=0.1.4',
'guessit>=0.5.4',
'subliminal>=0.6.2',
'mako>=0.7',
'lxml',
'feedparser',
'guess-language>=0.2',
'pyramid',
'pyramid_debugtoolbar',
'waitress',
'appdirs>=1.2',
'pillow'
]
datafiles_exts = [ '*.png', '*.svg', '*.mako', '*.css', '*.html', '*.js' ]
args = dict(name = 'smewt',
version = '0.4-dev',
description = 'Smewt - a smart media manager.',
long_description = README + '\n\n' + NEWS,
classifiers = [ # FIXME: Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
keywords = 'smewt pygoo media manager video collection web pyramid pylons',
author = 'Nicolas Wack, Ricard Marxer',
author_email = '[email protected]',
url = 'http://www.smewt.com/',
license = 'GPLv3',
packages = find_packages(exclude = [ 'ez_setup', 'examples', 'tests', 'utils' ]),
#package_data = dict((package, datafiles_exts) for package in find_packages()),
include_package_data = True,
zip_safe=False,
scripts = [ 'bin/smewg' ],
install_requires = install_requires,
tests_require=install_requires,
test_suite="smewt",
entry_points="""\
[paste.app_factory]
main = smewt:main
""",
)
if sys.platform == 'linux2':
from setuptools.command.install import install
import subprocess
class SmewtInstall(install):
def run(self):
install.run(self)
print 'Processing triggers for menu...'
subprocess.call(['xdg-desktop-menu', 'install', 'packaging/linux/falafelton-smewt.desktop'])
subprocess.call(['xdg-icon-resource', 'install', '--size', '128', 'static/images/falafelton-smewt_128x128.png', 'falafelton-smewt'])
if os.path.exists('/usr/bin/update-menus'):
# Debian
subprocess.call(['update-menus'])
elif os.path.exists('/usr/bin/update-desktop-database'):
# Ubuntu
subprocess.call(['update-desktop-database'])
# only try install icon and menu entry if we are root
# (ie: do not do it when we install stuff in a virtualenv)
if os.geteuid() == 0:
args.update(dict(cmdclass = { 'install': SmewtInstall }))
if sys.platform == 'darwin':
# py2app data
OPTIONS = { 'argv_emulation': True,
'iconfile': 'static/images/smewt.icns',
'packages': [ 'smewt', 'mako', 'lxml', 'guessit' ],
'frameworks': [ '/Developer/Applications/Qt/plugins/iconengines/libqsvgicon.dylib' ],
'includes': [ 'sip', 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4.QtNetwork', 'PyQt4.QtWebKit', 'PyQt4.QtXml', 'PyQt4.QtSvg', 'ntpath' ],
'excludes': [ 'PyQt4.QtDesigner', 'PyQt4.QtOpenGL', 'PyQt4.QtScript',
'PyQt4.QtSql', 'PyQt4.QtTest' ] # 'PyQt4.phonon'
}
args.update(dict(# for py2app
name = 'Smewt',
app = [ 'bin/smewg.py' ],
options = { 'py2app': OPTIONS,
'plist': dict(CFBundleIdentifier = 'com.smewt.Smewt')
},
setup_requires = [ 'py2app' ]
))
if sys.platform == 'win32':
import py2exe
import glob
from os.path import join
allfiles = []
for package in find_packages():
datafiles = []
root_path = package.replace('.', '\\')
for pattern in datafiles_exts:
datafiles += glob.glob(join(root_path, pattern))
if datafiles:
allfiles.append((root_path, datafiles))
# also add qt plugins
allfiles.append(('iconengines', glob.glob('C:\\Python27\\Lib\\site-packages\\PyQt4\\plugins\\iconengines\\*')))
allfiles.append(('imageformats', glob.glob('C:\\Python27\\Lib\\site-packages\\PyQt4\\plugins\\imageformats\\*')))
# add the open.exe utility program
allfiles.append(('.', [ 'packaging\\win32\\open.exe' ]))
from py2exe.build_exe import py2exe as build_exe
import guessit
class SmewtMediaCollector(build_exe):
"""Extension that copies smewt missing data."""
def copy_extensions(self, extensions):
"""Copy the missing extensions."""
build_exe.copy_extensions(self, extensions)
# Create the media subdir where the
# Python files are collected.
media = 'guessit' # os.path.join('guessit')
full = os.path.join(self.collect_dir, media)
if not os.path.exists(full):
self.mkpath(full)
# Copy the media files to the collection dir.
# Also add the copied file to the list of compiled
# files so it will be included in zipfile.
for f in glob.glob(guessit.__path__[0] + '/*.txt'):
name = os.path.basename(f)
self.copy_file(f, os.path.join(full, name))
self.compiled_files.append(os.path.join(media, name))
args.update(dict(windows = ['bin/smewg'],
cmdclass = { 'py2exe': SmewtMediaCollector },
data_files = allfiles,
options = { 'py2exe': { 'dll_excludes': 'MSVCP90.dll',
'includes': [ 'sip',
'PyQt4.QtNetwork',
'mako', # FIXME: necessary?
'lxml', 'lxml._elementpath'
],
'packages': [ 'BeautifulSoup' ]
}}))
setup(**args)