-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
52 lines (45 loc) · 1.45 KB
/
setup.py
File metadata and controls
52 lines (45 loc) · 1.45 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
import os
from setuptools import setup, Extension
from distutils.command.build_ext import build_ext as build_ext_setuptools
C_SOURCES = []
directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
with os.scandir('tinydot/lib') as it:
for entry in it:
if entry.is_file() and not entry.name.startswith('.') and not entry.name.endswith('.h'):
C_SOURCES.append(entry.path)
class CTypesExtension(Extension): pass
class build_ext(build_ext_setuptools):
def build_extension(self, ext):
self._ctypes = isinstance(ext, CTypesExtension)
return super().build_extension(ext)
def get_export_symbols(self, ext):
if self._ctypes:
return ext.export_symbols
return super().get_export_symbols(ext)
def get_ext_filename(self, ext_name):
if self._ctypes:
print('get_ext_filename', ext_name)
return f'{ext_name}.so'
return super().get_ext_filename(ext_name)
setup(
name='tinydot',
version='0.1.0',
description='Tiny linear algebra library',
author='Kacper Krylowicz',
license='MIT',
long_description=long_description,
long_description_content_type='text/markdown',
packages=['tinydot'],
install_requires=[],
python_requires='>=3.8',
extras_require={
'testing': [
'pytest'
],
},
include_package_data=True,
ext_modules=[CTypesExtension('tinydot_lib', C_SOURCES)],
cmdclass={'build_ext': build_ext},
)