Skip to content

Commit

Permalink
setup: do not use deprecated and removed 'Feature' feature
Browse files Browse the repository at this point in the history
Emulate it using environment variables instead. $GENSHI_BUILD_SPEEDUP is
checked for existence and parsed as an integer boolean, with invalid
values defaulting (loudly) to 0.

Fixes edgewall#36
  • Loading branch information
eli-schwartz committed Mar 3, 2021
1 parent 88e2966 commit 3fa6315
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
from glob import glob
import os
try:
from setuptools import setup, Extension, Feature
from setuptools import setup, Extension
from setuptools.command.bdist_egg import bdist_egg
except ImportError:
from distutils.core import setup, Extension
Feature = None
bdist_egg = None
import sys

Expand Down Expand Up @@ -64,20 +63,21 @@ def _unavailable(self, exc):
print(exc)


if Feature:
# Optional C extension module for speeding up Genshi:
# Not activated by default on:
# - PyPy (where it harms performance)
# - CPython >= 3.3 (the new Unicode C API is not supported yet)
speedups = Feature(
"optional C speed-enhancements",
standard = not is_pypy,
ext_modules = [
Extension('genshi._speedups', ['genshi/_speedups.c']),
],
)
else:
speedups = None
# Optional C extension module for speeding up Genshi
speedups = Extension('genshi._speedups', ['genshi/_speedups.c'])
ext_modules = []
# Not activated by default on:
# - PyPy (where it harms performance)
try:
_speedup_enable_default = 0 if is_pypy else 1
_speedup_enabled = int(os.getenv('GENSHI_BUILD_SPEEDUP', _speedup_enable_default))
except ValueError:
import warnings
warnings.warn('GENSHI_BUILD_SPEEDUP was defined to something other than 0 or 1; defaulting to not build...')
_speedup_enabled = False

if _speedup_enabled:
ext_modules = [speedups]


# Setuptools need some help figuring out if the egg is "zip_safe" or not
Expand Down Expand Up @@ -149,14 +149,14 @@ def zip_safe(self):
entry_points = """
[babel.extractors]
genshi = genshi.filters.i18n:extract[i18n]
[python.templating.engines]
genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin]
""",

features = {'speedups': speedups},
ext_modules = ext_modules,
cmdclass = cmdclass,

**extra
Expand Down

0 comments on commit 3fa6315

Please sign in to comment.