Skip to content

Commit

Permalink
Python: Add setup file to create sdist package for PyPI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
esindril committed Jul 24, 2015
1 parent 498483b commit e5b7572
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 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 *
58 changes: 58 additions & 0 deletions 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]
)
]
)

0 comments on commit e5b7572

Please sign in to comment.