This repository was archived by the owner on Mar 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
89 lines (79 loc) · 3.72 KB
/
Copy pathsetup.py
File metadata and controls
89 lines (79 loc) · 3.72 KB
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
import configparser
import os.path
import multiprocessing
import sys
from setuptools import setup, Extension
from Cython.Build import cythonize
ROOT_PATH = os.path.dirname(os.path.expanduser(os.path.expanduser(os.path.abspath(__file__))))
REQUIREMENTS = os.path.join(ROOT_PATH, 'requirements.txt')
SOURCE_PATH = os.path.join(ROOT_PATH, 'djangoProject')
CONFIG_FILE = os.path.join(ROOT_PATH, 'setup.cfg')
config = configparser.ConfigParser()
config.read(CONFIG_FILE)
PKG_NAME = config['metadata']['name']
PKG_VERSION = config['metadata']['version']
PKG_LICENSE = config['metadata']['license']
PKG_AUTHOR = config['metadata']['author']
PKG_CONTACT = config['metadata']['contact']
PKG_DESCRIPTION = config['metadata']['description']
PKG_SITE = config['metadata']['site']
# PKG_DOCS = config['metadata']['docs']
PKG_DOCS="https://github.com/AnyLog-co/documentation/blob/master/northbound%20connectors/remote_cli.md"
PKG_SOURCE = config['metadata']['source']
ANYLOG_MODULES = [] # anylog python files
REQUIREMENT_PACKAGES = [] # pip packages to install (based on requirements.txt)
EXTENSIONS = [] # python file paths in format anylog_node.cmd.user_cmd instead of anylog_node/cmd/user_cmd.py
PACKAGE_DATA = [os.path.join(SOURCE_PATH, 'templates', '*.html'),
# os.path.join(SOURCE_PATH, 'static', 'css', '*.*'),
os.path.join(SOURCE_PATH, 'static', '*', '*.*'),
]
WORKERS = max(1, multiprocessing.cpu_count() // 2)
# https://cython.readthedocs.io/en/latest/src/reference/compilation.html#compiler-directives
COMPILER_DIRECTIVES={
# Specifies the language level of the generated Python code (default - 2)
"language_level": sys.version_info.major,
# Enables or disables bounds checking for array indexing and slicing (default - True)
"boundscheck": True,
# Enables or disables checking for integer overflow during arithmetic operations (default - True)
"wraparound": True,
# Enables or disables C-style division behavior for integer division [rounding towards 0] (default - False)
"cdivision": True,
# Enables or disables runtime checks for NoneType (default - True)
"nonecheck": False,
# Cython will embed the Cython function signature in the generated C code. (default - False)
"embedsignature": True,
# generation of a Python binding for the compiled C code (defaultt - False)
"binding": False,
# runtime checks for initialized memory access (default - True)
"initializedcheck": True,
# Specifies the default C string type to use (default - unicode)
"c_string_type": "unicode",
# Specifies the default encoding to use for C strings (default - ascii)
"c_string_encoding": "ascii"
}
for dirname in os.listdir(SOURCE_PATH):
dir_path = os.path.join(SOURCE_PATH, dirname)
if os.path.isdir(dir_path):
for filename in os.listdir(dir_path):
file_path = os.path.join(dir_path, filename)
if os.path.isfile(file_path) and filename.endswith('.py'):
ANYLOG_MODULES.append(file_path)
elif os.path.isfile(dir_path) and dir_path.endswith('.py'):
ANYLOG_MODULES.append(dir_path)
for file_path in ANYLOG_MODULES:
if not file_path.endswith("__init__.py"):
if os.name == "nt":
ext_name = file_path.rsplit('.', 1)[0].replace("\\", '.').split(".Remote-CLI.")[-1]
else:
ext_name = file_path.rsplit('.', 1)[0].replace(os.path.sep, '.').split(".Remote-CLI.")[-1]
ext = Extension(ext_name, [file_path])
EXTENSIONS.append(ext)
setup(
name=PKG_NAME,
version=PKG_VERSION,
author=PKG_AUTHOR,
author_email=PKG_CONTACT,
description=PKG_DESCRIPTION,
ext_modules=cythonize(EXTENSIONS, compiler_directives=COMPILER_DIRECTIVES),
package_data={'djangoProject': PACKAGE_DATA}
)