File setup.py of Package failed_python-editdistance
from __future__ import annotations
import os
import platform
from setuptools import setup, Extension, find_packages
# Basic metadata (kept simple and consistent with the upstream package)
NAME = "editdistance"
VERSION = "0.6.0"
DESCRIPTION = "Fast edit distance (Levenshtein) library for Python"
# Detect architecture. On some exotic architectures (e.g. riscv64) the
# Python internal header 'longintrepr.h' may not be available on the
# system include path, causing the compiled extension build to fail.
# To maximize portability in those environments we skip building the
# C/C++ extension and install the pure-Python fallback.
_machine = platform.machine().lower() if platform.machine() else ""
_skip_ext_on_arch = _machine.startswith("riscv") or _machine.startswith("risc-v")
if _skip_ext_on_arch:
# Do not attempt to build C/C++ extension on architectures where it
# frequently fails due to missing internal Python headers.
ext_modules = []
else:
# Normal extension build for supported architectures
ext_modules = [
Extension(
"editdistance.bycython",
sources=[
"editdistance/bycython.cpp",
"editdistance/_editdistance.cpp"
],
include_dirs=["./editdistance"],
language="c++",
)
]
# Read long description if available
long_description = ""
if os.path.exists("README.md"):
try:
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
except Exception:
long_description = ""
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_packages(exclude=("tests",)),
include_package_data=True,
zip_safe=False,
ext_modules=ext_modules,
# Minimal classifiers to be harmless
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
],
)