forked from pisilinux/piksemel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·82 lines (73 loc) · 1.97 KB
/
setup.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2006 TUBITAK/UEKAE, 2019 Safa Arıman, 2020 Erdem Ersoy
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. Please read the COPYING file.
#
import sys
import os
import glob
import shutil
import subprocess
from distutils.core import setup, Extension
from distutils.command.install import install
version = '2.0a1'
distfiles = """
README.md
setup.py
src/iksemel.c
src/iksemel.h
src/pyiks.c
tests/*.py
"""
if 'sdist' in sys.argv:
distdir = "piksemel-%s" % version
filelist = []
for t in distfiles.split():
filelist.extend(glob.glob(t))
if os.path.exists(distdir):
shutil.rmtree(distdir)
os.mkdir(distdir)
for file_ in filelist:
cum = distdir[:]
for d in os.path.dirname(file_).split('/'):
dn = os.path.join(cum, d)
cum = dn[:]
if not os.path.exists(dn):
os.mkdir(dn)
shutil.copy(file_, os.path.join(distdir, file_))
subprocess.run(["tar", "czf", "piksemel-" + version + ".tar.gz", distdir])
shutil.rmtree(distdir)
sys.exit(0)
elif 'test' in sys.argv:
fail = 0
for test in os.listdir("tests"):
if test.endswith(".py"):
if 0 != subprocess.call(["tests/" + test]):
fail += 1
print(test, "failed!")
if not fail:
print("all tests passed :)")
sys.exit(0)
sys.exit(1)
class Install(install):
def run(self):
install.run(self)
setup(
name='piksemel',
version=version,
ext_modules=[
Extension(
'piksemel',
sources=['src/iksemel.c', 'src/pyiks.c'],
extra_compile_args=["-fvisibility=default"]
)
],
cmdclass={
'install': Install
}
)