gpodder/setup.py

215 lines
7.2 KiB
Python
Raw Permalink Normal View History

2016-11-21 23:49:06 +01:00
#!/usr/bin/env python3
#
# gPodder - A media aggregator and podcast client
2018-01-28 19:39:53 +01:00
# Copyright (c) 2005-2018 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 os
import re
import sys
from distutils.core import setup
installing = ('install' in sys.argv and '--help' not in sys.argv)
# distutils depends on setup.py being executed from the same dir.
# Most of our custom commands work either way, but this makes
# it work in all cases.
os.chdir(os.path.dirname(os.path.realpath(__file__)))
# Read the metadata from gPodder's __init__ module (doesn't need importing)
main_module = open('src/gpodder/__init__.py', 'r', encoding='utf-8').read()
2018-05-28 20:27:23 +02:00
metadata = dict(re.findall("__([a-z_]+)__\\s*=\\s*'([^']+)'", main_module))
author, email = re.match(r'^(.*) <(.*)>$', metadata['author']).groups()
2018-05-28 20:27:23 +02:00
class MissingFile(BaseException):
pass
def info(message, item=None):
2016-11-21 23:48:47 +01:00
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):
2012-02-23 21:22:54 +01:00
_, _, language, _ = dirpath.split(os.sep, 3)
if language not in linguas:
info('Skipping translation:', language)
continue
2012-02-23 21:22:54 +01:00
# Skip desktop stuff if we don't have any UIs requiring it
skip_folder = False
2016-02-03 19:54:33 +01:00
uis_requiring_freedesktop = ('gtk',)
2018-12-28 10:34:49 +01:00
freedesktop_folders = ('applications', 'dbus-1', 'icons', 'metainfo')
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:
2012-02-23 21:22:54 +01:00
info('Skipping manpage without script:', filename)
return result
2016-11-21 23:48:47 +01:00
filenames = list(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]
2012-02-23 21:22:54 +01:00
if installing and not os.path.exists(filename):
raise MissingFile(filename)
return None
return filename
2016-11-21 23:48:47 +01:00
filenames = [_f for _f in map(convert_filename, filenames) if _f]
if filenames:
# Some distros/ports install manpages into $PREFIX/man instead
# of $PREFIX/share/man (e.g. FreeBSD). To allow this, we strip
# the "share/" part if the variable GPODDER_MANPATH_NO_SHARE is
# set to any value in the environment.
if dirpath.startswith(share_man):
if 'GPODDER_MANPATH_NO_SHARE' in os.environ:
dirpath = dirpath.replace(share_man, 'man')
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)
2012-02-23 21:22:54 +01:00
# Extract all parts of the package name ending in "ui"
2016-11-21 23:48:47 +01:00
ui_parts = [p for p in dirparts if p.endswith('ui')]
if uis is not None and ui_parts:
# Strip the trailing "ui", e.g. "gtkui" -> "gtk"
2016-11-21 23:48:47 +01:00
folder_uis = [p[:-2] for p in 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,
2016-02-03 19:54:33 +01:00
'gpodder': lambda uis: any(ui in uis for ui in ('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)
2016-02-03 20:25:25 +01:00
# Recognized UIs: cli, gtk (default: install all UIs)
uis = os.environ.get('GPODDER_INSTALL_UIS', None)
if uis is not None:
uis = uis.split()
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)))
2016-11-21 23:48:47 +01:00
except MissingFile as mf:
print("""
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, file=sys.stderr)
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(
2021-06-08 19:51:51 +02:00
name='gpodder-adaptive',
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,
)