gpodder/setup.py

207 lines
6.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python
#
# gPodder - A media aggregator and podcast client
2012-01-09 21:19:24 +01:00
# Copyright (c) 2005-2012 Thomas Perl and the gPodder Team
#
# gPodder is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# gPodder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import glob
import os
import re
import sys
from distutils.core import setup
installing = ('install' in sys.argv)
# Read the metadata from gPodder's __init__ module (doesn't need importing)
main_module = open('src/gpodder/__init__.py').read()
metadata = dict(re.findall("__([a-z_]+)__\s*=\s*'([^']+)'", main_module))
author, email = re.match(r'^(.*) <(.*)>$', metadata['author']).groups()
class MissingFile(BaseException): pass
def info(message, item=None):
print '=>', message, item if item is not None else ''
def find_data_files(uis, scripts):
# Support for installing only a subset of translations
linguas = os.environ.get('LINGUAS', None)
if linguas is not None:
linguas = linguas.split()
info('Selected languages (from $LINGUAS):', linguas)
for dirpath, dirnames, filenames in os.walk('share'):
if not filenames:
continue
# Skip data folders if we don't want the corresponding UI
share_gpodder_ui = os.path.join('share', 'gpodder', 'ui')
if uis is not None and dirpath.startswith(share_gpodder_ui):
dirparts = dirpath.split(os.sep)
if not any(part in uis for part in dirparts):
info('Skipping folder:', dirpath)
continue
# Skip translations if $LINGUAS is set
share_locale = os.path.join('share', 'locale')
if linguas is not None and dirpath.startswith(share_locale):
_, _, language, _ = dirpath.split('/', 3)
if language not in linguas:
info('Skipping translation:', language)
continue
# Skip share/icons if we don't have any UIs that requires them
skip_folder = False
uis_requiring_freedesktop = ('gtk', 'qml')
freedesktop_folders = ('icons', 'dbus-1', 'applications')
for folder in freedesktop_folders:
share_folder = os.path.join('share', folder)
if dirpath.startswith(share_folder) and uis is not None:
if not any(ui in uis_requiring_freedesktop for ui in uis):
info('Skipping freedesktop.org folder:', dirpath)
skip_folder = True
break
if skip_folder:
continue
# Skip manpages if their scripts are not going to be installed
share_man = os.path.join('share', 'man')
if dirpath.startswith(share_man):
def have_script(filename):
if not filename.endswith('.1'):
return True
basename, _ = os.path.splitext(filename)
result = any(os.path.basename(s) == basename for s in scripts)
if not result:
info('Skipping file without script:', filename)
return result
filenames = filter(have_script, filenames)
def convert_filename(filename):
filename = os.path.join(dirpath, filename)
# Skip header files generated by "make messages"
if filename.endswith('.h'):
return None
# Skip .in files, but check if their target exist
if filename.endswith('.in'):
filename = filename[:-3]
if not os.path.exists(filename) and installing:
raise MissingFile(filename)
return None
return filename
filenames = filter(None, map(convert_filename, filenames))
if filenames:
yield (dirpath, filenames)
def find_packages(uis):
src_gpodder = os.path.join('src', 'gpodder')
for dirpath, dirnames, filenames in os.walk(src_gpodder):
if '__init__.py' not in filenames:
continue
skip = False
dirparts = dirpath.split(os.sep)
dirparts.pop(0)
package = '.'.join(dirparts)
# Find all parts of the package name ending in "ui"
ui_parts = filter(lambda p: p.endswith('ui'), dirparts)
if uis is not None and ui_parts:
# Strip the trailing "ui", e.g. "gtkui" -> "gtk"
folder_uis = map(lambda p: p[:-2], ui_parts)
for folder_ui in folder_uis:
if folder_ui not in uis:
info('Skipping package:', package)
skip = True
break
if not skip:
yield package
def find_scripts(uis):
# Functions for scripts to check if they should be installed
file_checks = {
'gpo': lambda uis: 'cli' in uis,
'gpodder': lambda uis: any(x in uis for x in ('qml', 'gtk')),
}
for dirpath, dirnames, filenames in os.walk('bin'):
for filename in filenames:
# If we have a set of uis, check if we can skip this file
if uis is not None and filename in file_checks:
if not file_checks[filename](uis):
info('Skipping script:', filename)
continue
yield os.path.join(dirpath, filename)
# Recognized UIs: gtk, qml, web (default: install all UIs)
uis = os.environ.get('GPODDER_INSTALL_UIS', None)
if uis is not None:
uis = uis.split()
# The CLI depends on the Web UI to be available
if 'cli' in uis and 'web' not in uis:
info('Adding Web UI as dependency of CLI')
uis.append('web')
info('Selected UIs (from $GPODDER_INSTALL_UIS):', uis)
try:
packages = list(sorted(find_packages(uis)))
scripts = list(sorted(find_scripts(uis)))
data_files = list(sorted(find_data_files(uis, scripts)))
except MissingFile, mf:
print >>sys.stderr, """
Missing file: %s
If you want to install, use "make install" instead of using
setup.py directly. See the README file for more information.
""" % mf.message
sys.exit(1)
Sun, 06 Apr 2008 02:05:34 +0200 <thp@perli.net> Initial upstream support for the Maemo platform (Nokia Internet Tablets) * bin/gpodder: Add "--maemo/-m" option to enable running as a Maemo application (this is only useful on Nokia Internet Tablets or in the Maemo SDK environment); determine interface type and set the correct variables on startup (gpodder.interface) * data/gpodder.glade: Increase the default size of some widgets to better fit the screens on Maemo (it won't do any harm on the "big" Desktop screen * data/icons/26/gpodder.png: Added * data/icons/40/gpodder.png: Added * data/maemo/gpodder.desktop: Added * Makefile: Help2man variable; new "make mtest" target that runs gPodder in Maemo scratchbox (probably useless for all other things); update the command descriptions; don't run the "generators" target from the "install" target; don't run "gen_graphics" from the "generators" target, but make it depend on the 24-pixel logo, which itself depends on the 22-pixel logo; this way, all should work out well when trying to install on systems without ImageMagick installed; remove *.pyo files on "make clean" * setup.py: Support for build targets; use "TARGET=maemo" to enable Maemo-specific installation options and files * src/gpodder/config.py: Increase the WRITE_TO_DISK_TIMEOUT to 60 seconds, so we don't unnecessarily stress memory cards (on ITs); modify default path variables on Maemo (/media/mmc2) * src/gpodder/gui.py: Maemo-specific changes; clean-up the main window a bit and make message and confirmation dialogs Hildon-compatible * src/gpodder/__init__.py: Add enums for interface types: CLI, GUI and MAEMO; remove the "interface_is_gui" variable and replace with "interface", which is now used to determine where we are running * src/gpodder/libgpodder.py: Use /media/mmc2/gpodder/ as configuration folder on Maemo; use Nokia's Media player to playback files on Maemo * src/gpodder/libpodcasts.py: Icon name changes (Maemo-specific) * src/gpodder/trayicon.py: Maemo support; swap popup menu on Maemo; Add support for hildon banners instead of pynotify on Maemo * src/gpodder/util.py: Icon name changes (Maemo-specific); use new gpodder.interface variable in idle_add git-svn-id: svn://svn.berlios.de/gpodder/trunk@654 b0d088ad-0a06-0410-aad2-9ed5178a7e87
2008-04-06 02:19:03 +02:00
setup(
name = 'gpodder',
version = metadata['version'],
description = metadata['tagline'],
license = metadata['license'],
url = metadata['url'],
author = author,
author_email = email,
package_dir = {'': 'src'},
packages = packages,
scripts = scripts,
data_files = data_files,
)