-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·79 lines (67 loc) · 2.61 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·79 lines (67 loc) · 2.61 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
#!/usr/bin/python3
import os
import sys
from setuptools import setup, find_packages, Extension
try:
from Cython.Build import cythonize
except ImportError:
cythonize = None
if 'sdist' in sys.argv and "CYTHONIZE" not in os.environ:
raise Exception("Please use supplied makefile to build the package.")
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
def no_cythonize(extensions, **_ignore):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in (".pyx", ".py"):
if extension.language == "c++":
ext = ".cpp"
else:
ext = ".c"
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions
extensions = [
Extension("wrapper", ["fatfs/wrapper.pyx", "fatfs/diskiocheck.c", "foreign/fatfs/source/ff.c", "foreign/fatfs/source/ffsystem.c", "foreign/fatfs/source/ffunicode.c"], include_dirs=["foreign/fatfs/source"]),
]
cythonize_env = bool(int(os.getenv("CYTHONIZE", 0)))
if cythonize_env and cythonize_env is None:
raise Exception("Cython needs to be installed for CYTHONIZE=1")
CYTHONIZE = cythonize_env and cythonize is not None
if CYTHONIZE:
compiler_directives = {"language_level": 3, "embedsignature": True}
extensions = cythonize(extensions, compiler_directives=compiler_directives)
else:
extensions = no_cythonize(extensions)
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name='fatfs',
version="0.1.2",
author="Ladislav Laska",
author_email="krakonos@krakonos.org",
description="A wrapper around ChaN's FatFS library for FAT filesystem manipulation.",
long_description=long_description,
long_description_content_type="text/markdown",
ext_package='fatfs',
ext_modules=extensions,
url="https://github.com/krakonos/fatfs-python",
#packages=['pyfatfs', 'pyfatfs.tests'],
packages=find_packages(),
setup_requires=['cython'],
zip_safe=False,
python_requires='>=3.8',
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Embedded Systems",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Filesystems",
],
)