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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/usr/bin/env python
#
# Copyright @ CERN, 2015
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
import re
import shutil
import sys
import distutils.command.build_ext as _build_ext
import distutils.spawn
import distutils.dir_util
from glob import glob
from subprocess import check_call
from setuptools import Extension, setup
# Change this for a post release
# (i.e there are changes in the setup.py or MANIFEST.in but no version change)
POST_RELEASE = None
def get_version():
ver_components = dict()
if POST_RELEASE:
ver_components['VERSION_RELEASE'] = POST_RELEASE
with open('CMakeLists.txt') as cmake:
for line in cmake:
line = line.strip()
if line.startswith('set') and line.endswith(')'):
result = re.search(r'^set\s*\((\S+)\s(\S+)[\s\)]', line)
varname, varval = result.group(1), result.group(2)
if varname.startswith('VERSION_'):
ver_components[varname] = varval
if len(ver_components) == 0:
raise ValueError('Could not find the version')
version = "%(VERSION_MAJOR)s.%(VERSION_MINOR)s.%(VERSION_PATCH)s"
if POST_RELEASE:
version += ".post%(VERSION_RELEASE)s"
return version % ver_components
def long_description():
try:
import pypandoc
return pypandoc.convert_file('README.md', 'rst')
except(IOError, ImportError):
return open('README.md').read()
def validate():
if distutils.spawn.find_executable('cmake') is None:
print('Missing CMake executable')
sys.exit(-1)
def _run_make(build_dir, lib_path):
validate()
# prepare paths
full_lib_path = os.path.dirname(os.path.abspath(lib_path))
source_dir = os.path.abspath(os.path.dirname(__file__))
# ensure involved directories exist
if not os.path.exists(build_dir):
os.makedirs(build_dir)
if not os.path.exists(full_lib_path):
os.makedirs(full_lib_path)
# Run the cmake and make commands
check_call(['cmake', '-DSKIP_TESTS=TRUE', source_dir], cwd=build_dir)
check_call(['make'], cwd=build_dir)
# install
shutil.copy(os.path.join(build_dir, 'src/python3/gfal2.so'), full_lib_path)
class build_ext(_build_ext.build_ext):
def run(self):
_run_make(self.build_temp, self.get_ext_fullpath('gfal2'))
setup(
name='gfal2-python',
version=get_version(),
description='Python3 bindings for Gfal2',
long_description=long_description(),
long_description_content_type='text/markdown',
requires=[],
install_requires=[],
url='https://dmc.web.cern.ch/',
download_url='https://gitlab.cern.ch/dmc/gfal2-bindings',
author='DMC Devel',
author_email='dmc-devel@cern.ch',
maintainer_email='dmc-devel@cern.ch',
license='Apache 2',
keywords='gfal2, grid, dmc, data management clients',
platforms=['GNU/Linux'],
classifiers=[
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: Apache Software License",
"Development Status :: 5 - Production/Stable",
"Operating System :: Unix",
"Programming Language :: C"
],
cmdclass={'build_ext': build_ext},
zip_safe=False,
packages=[],
ext_modules=[
Extension('gfal2', sources=glob("src/*.cpp"))
]
)
|