Commit d29bcc7f by Czémán Arnold

Rework build pipe, add setup.py

parent e21fed0a
*.pyc
*.py
*.sw[pon]
*.o
*.cxx
*.so
*.a
libocci.egg-info
restclient-cpp
build
dist
CPP=g++
CC=gcc
AR=ar
CFLAGS=-fPIC -Ofast
CPPFLAGS=-fPIC --std=c++11 -Ofast
CPPFLAGS=-fPIC --std=c++11 -Ofast -Irestclient-cpp/include
LDFLAGS=--shared
LIBS=-lrestclient-cpp
LIBS=-lrestclient-cpp -lcurl
SONAME=_occi.so
SOURCES=occilib.cpp
SWIG=swig
SWIG_INTERFACES=occilib.i
WRAPPER_SOURCES=occilib_wrap.cxx
WRAPPER_SOURCES=occilib_wrap.cpp
WRAPPER_INCLUDES=`pkg-config python --cflags`
default: test
RESTCLIENT_CPP_URL=https://github.com/fuximo/restclient-cpp.git
RESTCLIENT_CPP_TAG=master
compile:
$(CPP) $(CPPFLAGS) -c $(SOURCES)
test: compile
$(CPP) $(CPPFLAGS) -o test test.cpp *.o $(LIBS)
default: python
python:
$(SWIG) -python -c++ $(SWIG_INTERFACES)
$(CPP) $(CPPFLAGS) -c $(WRAPPER_SOURCES) $(WRAPPER_INCLUDES)
$(CPP) $(LDFLAGS) -o $(SONAME) occilib_wrap.o $(LIBS)
python setup.py build
restclient-cpp:
git clone --depth=1 $(RESTCLIENT_CPP_URL) -b $(RESTCLIENT_CPP_TAG)
bash gen_restclient-cpp_version.sh $(RESTCLIENT_CPP_TAG)
build-restclient-cpp: restclient-cpp
cd restclient-cpp ; \
$(CPP) $(CPPFLAGS) -c source/*.cc -Iinclude
$(AR) rcs librestclient-cpp.a restclient-cpp/*.o
deps: build-restclient-cpp
clean:
rm -f *.o
rm -f $(WRAPPER_SOURCES)
rm -f $(SONAME)
rm -f occi.py
rm -Rf build
mrproper: clean clean_deps
rm -Rf dist libocci.egg-info
mrproper: clean
rm -f occi.py occi.pyc
rm -f _occi.so
clean_deps:
rm -Rf restclient-cpp
rm -f librestclient-cpp.a
cat > restclient-cpp/include/restclient-cpp/version.h <<EOF
#ifndef INCLUDE_RESTCLIENT_CPP_VERSION_H_
#define INCLUDE_RESTCLIENT_CPP_VERSION_H_
#define RESTCLIENT_VERSION "${1}"
#endif // INCLUDE_RESTCLIENT_CPP_VERSION_H_
EOF
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
# Always prefer setuptools over distutils
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
from subprocess import check_call
import sys
_occi = Extension('_occi',
sources=['occilib.i'],
include_dirs=['restclient-cpp/include'],
library_dirs=['.'],
swig_opts=['-c++'],
extra_compile_args=['-std=c++11', '-Ofast'],
libraries=['restclient-cpp', 'curl']
)
class Build(build_ext):
def run(self):
check_call(['make', 'deps'])
build_ext.run(self)
setup(
name='libocci',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='1.0.0',
description='OCCI client library for CIRCLE cloud',
# The project's main homepage.
url='https://git.ik.bme.hu/circle/libocci',
# Author details
author='BME IK',
author_email='cloud@ik.bme.hu',
# Choose your license
license='GPLv3',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 5 - Production/Stable',
# Indicate who your project is intended for
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.3',
# 'Programming Language :: Python :: 3.4',
# 'Programming Language :: Python :: 3.5',
],
# What does your project relate to?
keywords='libocci occi OCCI CIRCLE cloud',
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
# packages=find_packages(exclude=['contrib', 'docs', 'tests']),
# Alternatively, if you want to distribute just a my_module.py, uncomment
# this:
py_modules=["occi"],
ext_modules=[_occi],
cmdclass={'build_ext': Build},
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment