-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup_binary.py
More file actions
67 lines (57 loc) · 2.3 KB
/
setup_binary.py
File metadata and controls
67 lines (57 loc) · 2.3 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
# ruff: noqa: T201
"""Setup script for building the binary extension of python-redux."""
import os
import sys
from pathlib import Path
from setuptools import Extension, setup
# Add root to path to import version
root = Path(__file__).parent
sys.path.insert(0, str(root))
try:
from version import get_version
version = get_version()
except ImportError:
# If version.py or dependencies fail, fallback or fail.
# In CI, dependencies should be installed.
print('Warning: Could not import get_version from version.py')
version = '0.0.0.dev0'
def get_extensions() -> list[Extension]:
"""Dynamically find all C extensions in the redux/ and redux_pytest/ directories."""
extensions: list[Extension] = []
# Find all .c files in redux/ and redux_pytest/
for directory in ['redux', 'redux_pytest']:
for path in (root / directory).rglob('*.c'):
# Construct module name: redux/store.c -> redux.store
# relatives_to root
rel_path = path.relative_to(root)
module_name = str(rel_path.with_suffix('')).replace(os.sep, '.')
extensions.append(Extension(module_name, [str(rel_path)]))
return extensions
setup(
name='python-redux',
version=version,
description='Redux implementation for Python (Binary Extension)',
long_description=(root / 'README.md').read_text(encoding='utf-8'),
long_description_content_type='text/markdown',
ext_modules=get_extensions(),
include_package_data=True,
author='Sassan Haradji',
author_email='me@sassanh.com',
url='https://github.com/sassanh/python-redux/',
project_urls={
'Homepage': 'https://github.com/sassanh/python-redux/',
'Repository': 'https://github.com/sassanh/python-redux/',
'Documentation': 'https://github.com/sassanh/python-redux/',
'Changelog': 'https://github.com/sassanh/python-redux/blob/main/CHANGELOG.md',
},
license='Apache-2.0',
keywords=['python', 'store', 'redux', 'reactive', 'autorun', 'view'],
classifiers=[
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Programming Language :: Python :: 3 :: Only',
],
python_requires='>=3.11',
)