File setup.py of Package failed_python-jellyfish
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Setup script for jellyfish.
This modified setup.py disables building the C extension module
for Python 3.12 where the C extension is known to be incompatible
in this packaging environment. For other Python versions the C
extension is built as usual.
"""
import sys
from setuptools import setup, Extension, find_packages
from os import path
here = path.abspath(path.dirname(__file__))
# Read long description if available
long_description = ""
readme = path.join(here, "README.rst")
if path.exists(readme):
with open(readme, encoding="utf-8") as f:
long_description = f.read()
# Common metadata (kept minimal and compatible with the original package)
NAME = "jellyfish"
VERSION = "0.8.2"
# C extension sources (original cjellyfish extension)
cjellyfish_sources = [
"cjellyfish/jellyfishmodule.c",
"cjellyfish/damerau_levenshtein.c",
"cjellyfish/hamming.c",
"cjellyfish/jaro.c",
"cjellyfish/levenshtein.c",
"cjellyfish/metaphone.c",
"cjellyfish/mra.c",
"cjellyfish/nysiis.c",
"cjellyfish/porter.c",
"cjellyfish/soundex.c",
]
# Decide whether to build the C extension.
# Workaround: do not build the compiled cjellyfish extension for Python 3.12
# because the bundled C wrapper in this source tree is incompatible in that
# interpreter ABI/context. In that case provide a pure-Python fallback
# module (jellyfish/cjellyfish.py) which delegates to jellyfish._jellyfish.
build_c_extension = True
if sys.version_info[0] == 3 and sys.version_info[1] == 12:
build_c_extension = False
ext_modules = []
if build_c_extension:
ext_modules = [
Extension(
"jellyfish.cjellyfish",
sources=cjellyfish_sources,
include_dirs=["cjellyfish"],
)
]
setup(
name=NAME,
version=VERSION,
description="Approximate and Phonetic matching in Python",
long_description=long_description,
packages=find_packages(exclude=("tests", "testdata")),
include_package_data=True,
ext_modules=ext_modules,
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
author="Alexandre Viau and contributors",
license="MIT",
)