setup.py 1.53 KB
Newer Older
Fize Jacques's avatar
Fize Jacques committed
1
import sys, os, shutil
Fize Jacques's avatar
Fize Jacques committed
2 3
from distutils.core import setup
from distutils.extension import Extension
Fize Jacques's avatar
Fize Jacques committed
4
import numpy as np
Fize Jacques's avatar
Fize Jacques committed
5
try:
6
    from Cython.Build import cythonize
Fize Jacques's avatar
Fize Jacques committed
7 8 9 10 11
    from Cython.Distutils import build_ext
except:
    print("You don't seem to have Cython installed. Please get a")
    print("copy from www.cython.org and install it")
    sys.exit(1)
Fize Jacques's avatar
Fize Jacques committed
12 13


14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
def scandir(dir, files=[]):
    for file in os.listdir(dir):
        path = os.path.join(dir, file)
        if os.path.isfile(path) and path.endswith(".pyx"):
            files.append(path.replace(os.path.sep, ".")[:-4])
        elif os.path.isdir(path):
            scandir(path, files)
    return files

# generate an Extension object from its dotted name
def makeExtension(extName):
    extPath = extName.replace(".", os.path.sep)+".pyx"
    return Extension(
        extName,
        [extPath],include_dirs=[np.get_include()],language='c++'
        )

# get the list of extensions
extNames = scandir("gmatch4py")

# and build up the set of Extension objects
extensions = cythonize([makeExtension(name) for name in extNames])
Fize Jacques's avatar
Fize Jacques committed
36 37

setup(
Fize Jacques's avatar
Fize Jacques committed
38
    name="GMatch4py",
Fize Jacques's avatar
Fize Jacques committed
39
    description="A module for graph matching",
Fize Jacques's avatar
Fize Jacques committed
40
    packages=["gmatch4py","gmatch4py.ged","gmatch4py.kernels"],
41
    ext_modules=extensions,
Fize Jacques's avatar
Fize Jacques committed
42
    cmdclass={'build_ext': build_ext},
Fize Jacques's avatar
Fize Jacques committed
43
    setup_requires=["numpy","networkx"],
44 45
    install_requires=["numpy","networkx"],
    version="0.1"
Fize Jacques's avatar
Fize Jacques committed
46
)
Fize Jacques's avatar
Fize Jacques committed
47
#Clean cpp and compiled file
Fize Jacques's avatar
Fize Jacques committed
48
f=True
Fize Jacques's avatar
Fize Jacques committed
49 50 51 52
if f:
    if os.path.exists("build"):
        shutil.rmtree("build")
    os.system("find . -name \*.c -delete ; find . -name \*.cpp -delete ;")