From 06a0133318baeb4fd95321865fd22fdc6c20c5ab Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 28 Aug 2011 12:36:23 +0100 Subject: [PATCH 1/2] Interpolate PREFIX at build stage, using prefix from options or install --- setup.py | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index 41f8b14..fcbf19c 100644 --- a/setup.py +++ b/setup.py @@ -11,38 +11,39 @@ from distutils.log import warn, info, error, fatal from distutils.dep_util import newer -# Get current Python version -python_version = platform.python_version_tuple() +PO_DIR = 'po' +MO_DIR = os.path.join('build', 'mo') -# Setup the default install prefix -prefix = sys.prefix +class BuildData(build): -# Check our python is version 2.6 or higher -if python_version[0] >= 2 and python_version[1] >= 6: - ## Set file location prefix accordingly - prefix = '/usr/local' + user_options = [ + ('prefix=', None, "installation prefix"), + ] -# Get the install prefix if one is specified from the command line -for arg in sys.argv: - if arg.startswith('--prefix='): - prefix = arg[9:] - prefix = os.path.expandvars(prefix) + def initialize_options(self): + build.initialize_options(self) + self.prefix = None -# Gen .in files with @PREFIX@ replaced -for filename in ['udev-discover']: - infile = open(filename + '.in', 'r') - data = infile.read().replace('@PREFIX@', prefix) - infile.close() + def finalize_options(self): + build.finalize_options(self) + if not self.prefix: + install = self.distribution.get_command_obj('install', False) + if install: + self.prefix = install.prefix + else: + self.prefix = sys.prefix - outfile = open(filename, 'w') - outfile.write(data) - outfile.close() + def run (self): + # Gen .in files with @PREFIX@ replaced + for filename in ['udev-discover']: + infile = open(filename + '.in', 'r') + data = infile.read().replace('@PREFIX@', self.prefix) + infile.close() -PO_DIR = 'po' -MO_DIR = os.path.join('build', 'mo') + outfile = open(filename, 'w') + outfile.write(data) + outfile.close() -class BuildData(build): - def run (self): build.run (self) for po in glob.glob (os.path.join (PO_DIR, '*.po')): From ddd2de6dbf14f3e1c4b64b227414e55e1d22651a Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 28 Aug 2011 13:05:30 +0100 Subject: [PATCH 2/2] Install application icon to share/icons --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index fcbf19c..b1d0058 100644 --- a/setup.py +++ b/setup.py @@ -128,5 +128,6 @@ def _find_mo_files (self): ('share/icons/hicolor/24x24/devices', glob.glob('data/icons/24x24/devices/*')), ('share/icons/hicolor/48x48/devices', glob.glob('data/icons/48x48/devices/*')), ('share/icons/hicolor/scalable/devices', glob.glob('data/icons/scalable/devices/*')), + ('share/icons/hicolor/scalable/apps', ['data/udev-discover.svg']), ], )