From e5b7572d99fd4aa194c3d856e52d2952efa23131 Mon Sep 17 00:00:00 2001 From: Elvin Sindrilaru Date: Fri, 24 Jul 2015 10:12:24 +0200 Subject: [PATCH] Python: Add setup file to create sdist package for PyPI The new setup_pypi.py file can be used to generate the sdist package for the XRootD python bindings. This should be used only wen creating the package for distribution in PyPI. --- bindings/python/MANIFEST.in | 7 +++++ bindings/python/setup_pypi.py | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 bindings/python/MANIFEST.in create mode 100644 bindings/python/setup_pypi.py diff --git a/bindings/python/MANIFEST.in b/bindings/python/MANIFEST.in new file mode 100644 index 00000000000..4c7c7a982d5 --- /dev/null +++ b/bindings/python/MANIFEST.in @@ -0,0 +1,7 @@ +include README.rst +include VERSION_INFO +include genversion.sh +recursive-include tests * +recursive-include examples *.py +recursive-include docs * +recursive-include src * diff --git a/bindings/python/setup_pypi.py b/bindings/python/setup_pypi.py new file mode 100644 index 00000000000..5b70160546a --- /dev/null +++ b/bindings/python/setup_pypi.py @@ -0,0 +1,58 @@ +from distutils.core import setup, Extension +from distutils import sysconfig +from os import getenv, walk, path, path, getcwd, chdir +import subprocess + +# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++. +cfg_vars = sysconfig.get_config_vars() +opt = cfg_vars["OPT"] +cfg_vars["OPT"] = " ".join( flag for flag in opt.split() if flag != '-Wstrict-prototypes' ) + + +sources = list() +depends = list() + +for dirname, dirnames, filenames in walk('src'): + for filename in filenames: + if filename.endswith('.cc'): + sources.append(path.join(dirname, filename)) + elif filename.endswith('.hh'): + depends.append(path.join(dirname, filename)) + +xrdlibdir = getenv( 'XRD_LIBDIR' ) or '/usr/lib' +xrdincdir = getenv( 'XRD_INCDIR' ) or '/usr/include/xrootd' + +# Get package version +topdir = path.dirname(path.dirname(getcwd())) +p = subprocess.Popen(['./genversion.sh', '--print-only'], stdout=subprocess.PIPE, cwd=topdir) +version, err = p.communicate() +version = version.strip() + +print 'XRootD library dir: ', xrdlibdir +print 'XRootD include dir: ', xrdincdir +print 'Version: ', version + +setup( name = 'pyxrootd', + version = version, + author = 'XRootD Developers', + author_email = 'xrootd-dev@slac.stanford.edu', + url = 'http://xrootd.org', + license = 'LGPLv3+', + description = "XRootD Python bindings", + long_description = "XRootD Python bindings", + packages = ['pyxrootd', 'XRootD', 'XRootD.client'], + package_dir = {'pyxrootd' : 'src', + 'XRootD' : 'libs', + 'XRootD.client': 'libs/client'}, + ext_modules = [ + Extension( + 'pyxrootd.client', + sources = sources, + depends = depends, + libraries = ['XrdCl', 'XrdUtils', 'dl'], + extra_compile_args = ['-g'], + include_dirs = [xrdincdir], + library_dirs = [xrdlibdir] + ) + ] + )