-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·119 lines (100 loc) · 4.17 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
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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import shlex
import subprocess
from setuptools import Extension, setup
# try:
# from Cython.Build import cythonize
# USE_CYTHON = True
# except ImportError:
USE_CYTHON = False # use cython -2 ccc/cl.pyx instead
########################
# read local resources #
########################
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md'), mode='rt', encoding='utf-8') as f:
long_description = f.read()
version = {}
with open(os.path.join(here, 'ccc', 'version.py'), mode='rt', encoding='utf-8') as f:
exec(f.read(), version)
##############
# cwb-config #
##############
# - version
cwb_version = subprocess.run(shlex.split("cwb-config -v"), capture_output=True).stdout.decode().strip()
# - cqp binaries
cwb_bindir = subprocess.run(shlex.split("cwb-config --bindir"), capture_output=True).stdout.decode().strip()
# - effective registry directory or directories:
cwb_registry = subprocess.run(shlex.split("cwb-config -r"), capture_output=True).stdout.decode().strip()
# - libdir (CL library)
cwb_libdir = subprocess.run(shlex.split("cwb-config --libdir"), capture_output=True).stdout.decode().strip()
# - incdir (C header)
cwb_incdir = subprocess.run(shlex.split("cwb-config --incdir"), capture_output=True).stdout.decode().strip()
# - compiler flags for linking against CL library
cwb_compiler_flags = subprocess.run(shlex.split("cwb-config -I"), capture_output=True).stdout.decode().strip()
# - linker flags for linking against CL library
cwb_linker_flags = subprocess.run(shlex.split("cwb-config -L"), capture_output=True).stdout.decode().strip()
####################################
# define (and compile) C-extension #
####################################
# ensure compatibility with CWB v3.4.36 and below
if int(cwb_version.split(".")[0]) == 3 and int(cwb_version.split(".")[1]) == 4 and int(cwb_version.split(".")[2]) < 37:
cwb_linker_flags = "-L/usr/local/lib -lcl -lm -lpcre -lglib-2.0"
# define include directories, library directories, and library names
libraries = [t[2:] for t in shlex.split(cwb_linker_flags) if t.startswith("-l")]
inc_dirs = [cwb_incdir] + [t[2:] for t in shlex.split(cwb_compiler_flags) if t.startswith("-I")]
lib_dirs = [cwb_libdir] + [t[2:] for t in shlex.split(cwb_linker_flags) if t.startswith("-L")]
ccc_cl = Extension(
name="ccc.cl",
sources=['ccc/cl' + ('.pyx' if USE_CYTHON else '.c')],
include_dirs=inc_dirs, # list of directories to search for C/C++ header files
library_dirs=lib_dirs, # list of directories to search for C/C++ libraries at link time
libraries=libraries # list of library names (not filenames or paths) to link against
)
# cythonize?
extensions = [ccc_cl]
if USE_CYTHON:
from Cython.Build import cythonize
extensions = cythonize(extensions)
#################
# actual set-up #
#################
setup(
name="cwb-ccc",
version=version["__version__"],
description="CWB wrapper to extract concordances and score frequency lists",
license='GNU General Public License v3 or later (GPLv3+)',
long_description=long_description,
long_description_content_type="text/markdown",
author="Philipp Heinrich",
author_email="[email protected]",
url="https://github.com/ausgerechnet/cwb-ccc",
packages=[
'ccc'
],
ext_modules=extensions,
python_requires='>=3.8.0',
install_requires=[
"numpy>=1.24.0,<2.0",
"numexpr>=2.8.6,<3.0",
"bottleneck==1.4.0",
"pandas>=2.0,<3.0",
"association-measures>=0.3.0,<0.4",
"unidecode>=1.3.8,<2.0",
"pyyaml>=6.0.1,<7.0",
"trieregex>=1.0.0,<1.1"
],
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Development Status :: 4 - Beta",
"Operating System :: Unix",
"Programming Language :: Python :: 3",
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Cython'
],
)