Skip to content

Commit

Permalink
Merge pull request #2 from ecatmur/master
Browse files Browse the repository at this point in the history
[m][install] Interpolate PREFIX at build stage, using prefix from options or install
  • Loading branch information
fontanon committed Aug 28, 2011
2 parents 78adde1 + ddd2de6 commit 097d233
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions setup.py
Expand Up @@ -11,38 +11,39 @@
from distutils.log import warn, info, error, fatal from distutils.log import warn, info, error, fatal
from distutils.dep_util import newer from distutils.dep_util import newer


# Get current Python version PO_DIR = 'po'
python_version = platform.python_version_tuple() MO_DIR = os.path.join('build', 'mo')


# Setup the default install prefix class BuildData(build):
prefix = sys.prefix


# Check our python is version 2.6 or higher user_options = [
if python_version[0] >= 2 and python_version[1] >= 6: ('prefix=', None, "installation prefix"),
## Set file location prefix accordingly ]
prefix = '/usr/local'


# Get the install prefix if one is specified from the command line def initialize_options(self):
for arg in sys.argv: build.initialize_options(self)
if arg.startswith('--prefix='): self.prefix = None
prefix = arg[9:]
prefix = os.path.expandvars(prefix)


# Gen .in files with @PREFIX@ replaced def finalize_options(self):
for filename in ['udev-discover']: build.finalize_options(self)
infile = open(filename + '.in', 'r') if not self.prefix:
data = infile.read().replace('@PREFIX@', prefix) install = self.distribution.get_command_obj('install', False)
infile.close() if install:
self.prefix = install.prefix
else:
self.prefix = sys.prefix


outfile = open(filename, 'w') def run (self):
outfile.write(data) # Gen .in files with @PREFIX@ replaced
outfile.close() for filename in ['udev-discover']:
infile = open(filename + '.in', 'r')
data = infile.read().replace('@PREFIX@', self.prefix)
infile.close()


PO_DIR = 'po' outfile = open(filename, 'w')
MO_DIR = os.path.join('build', 'mo') outfile.write(data)
outfile.close()


class BuildData(build):
def run (self):
build.run (self) build.run (self)


for po in glob.glob (os.path.join (PO_DIR, '*.po')): for po in glob.glob (os.path.join (PO_DIR, '*.po')):
Expand Down Expand Up @@ -127,5 +128,6 @@ def _find_mo_files (self):
('share/icons/hicolor/24x24/devices', glob.glob('data/icons/24x24/devices/*')), ('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/48x48/devices', glob.glob('data/icons/48x48/devices/*')),
('share/icons/hicolor/scalable/devices', glob.glob('data/icons/scalable/devices/*')), ('share/icons/hicolor/scalable/devices', glob.glob('data/icons/scalable/devices/*')),
('share/icons/hicolor/scalable/apps', ['data/udev-discover.svg']),
], ],
) )

0 comments on commit 097d233

Please sign in to comment.