43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import os
|
|
from setuptools import setup, Extension
|
|
from Cython.Build import cythonize
|
|
|
|
def find_pyx_files(directory):
|
|
"""Finds all .py files to compile, ignoring __init__.py and docs."""
|
|
paths = []
|
|
for root, dirs, files in os.walk(directory):
|
|
# Skip the docs folder
|
|
if 'docs' in dirs:
|
|
dirs.remove('docs')
|
|
|
|
for file in files:
|
|
# if file.endswith(".py") and file != "__init__.py":
|
|
if file.endswith(".py"):
|
|
paths.append(os.path.join(root, file))
|
|
return paths
|
|
|
|
# Define the files to compile
|
|
source_files = find_pyx_files("mxpic")
|
|
|
|
# Create extensions
|
|
extensions = [
|
|
Extension(
|
|
name=file.replace(os.sep, ".")[:-3], # e.g., mxpic.components.mzm
|
|
sources=[file],
|
|
)
|
|
for file in source_files
|
|
]
|
|
|
|
setup(
|
|
name="mxpic",
|
|
version="1.0.0",
|
|
# Tell setuptools to include all .pyi files across all sub-folders
|
|
package_data={
|
|
"mxpic": ["*.pyi", "**/*.pyi"],
|
|
},
|
|
include_package_data=True,
|
|
ext_modules=cythonize(
|
|
extensions,
|
|
compiler_directives={'language_level': "3"}
|
|
),
|
|
) |