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
|
# setup.py script for pyparted
# Copyright (C) 2011-2013 Red Hat, Inc.
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author(s): David Cantrell <dcantrell@redhat.com>
# Alex Skinner <alex@lx.lc>
#
# pylint: skip-file
import subprocess
import glob
import os
import platform
import sys
from distutils.ccompiler import new_compiler
from distutils.errors import CompileError
from distutils.errors import LinkError
from distutils.core import setup
from distutils.core import Extension
pyparted_version = '3.10.7'
python_version = sys.version_info
need_libparted_version = '2.3'
need_python_version = (2, 7)
if python_version < need_python_version:
raise RuntimeError("pyparted requires Python version %d.%d or higher"
% need_python_version)
# Recipe from:
# http://code.activestate.com/recipes/502261-python-distutils-pkg-config/
def pkgconfig(*packages, **kwargs):
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
for token in subprocess.check_output(["pkg-config", "--libs", "--cflags"] + list(packages)).decode('utf-8').split():
kwargs.setdefault(flag_map.get(token[:2]), []).append(token[2:])
return kwargs
def check_mod_version(module, version):
modversion = subprocess.check_output(["pkg-config", "--modversion", module])
if not float(modversion) >= float(version):
sys.stderr.write("*** Minimum required %s version: %s, found: %s\n" % (module, version, modversion,))
sys.exit(1)
return
check_mod_version('libparted', need_libparted_version)
# This list is in the format necessary for the define_macros parameter
# for an Extension() module definition. See:
# http://docs.python.org/distutils/setupscript.html#preprocessor-options
features = [('PYPARTED_VERSION', "\"%s\"" % pyparted_version)]
setup(name='pyparted',
version=pyparted_version,
author='pyparted Development Team',
author_email='pyparted-devel@redhat.com',
url='https://fedorahosted.org/pyparted/',
description='Python bindings for GNU parted',
license='GPLv2+',
packages=['parted'],
package_dir={'parted': 'src/parted'},
ext_modules=[Extension('_ped',
sorted(glob.glob(os.path.join('src', '*.c'))),
define_macros=features,
**pkgconfig('libparted',
include_dirs=['include']))
])
|