| 1 |
from setuptools import setup, Extension |
| 2 |
try: |
| 3 |
from setuptools.command.bdist_wheel import bdist_wheel, get_abi_tag |
| 4 |
except ImportError: |
| 5 |
try: |
| 6 |
from wheel.bdist_wheel import bdist_wheel, get_abi_tag |
| 7 |
except ImportError: |
| 8 |
from wheel._bdist_wheel import bdist_wheel, get_abi_tag |
| 9 |
from os.path import join as pjoin |
| 10 |
import sys, os, sysconfig, re |
| 11 |
|
| 12 |
def make_la_info(): |
| 13 |
'''compute limited api and abi info''' |
| 14 |
global py_limited_kwds, cpstr |
| 15 |
cpstr = get_abi_tag() |
| 16 |
if cpstr.startswith("cp"): |
| 17 |
lav = '0x03070000' |
| 18 |
cpstr = 'cp37' |
| 19 |
if sys.platform == "darwin": |
| 20 |
machine = sysconfig.get_platform().split('-')[-1] |
| 21 |
if machine=='arm64' or os.environ.get('ARCHFLAGS','')=='-arch arm64': |
| 22 |
|
| 23 |
lav = '0x03080000' |
| 24 |
cpstr = 'cp38' |
| 25 |
py_limited_kwds = dict( |
| 26 |
define_macros=[("Py_LIMITED_API", lav)], |
| 27 |
py_limited_api=True, |
| 28 |
) |
| 29 |
else: |
| 30 |
py_limited_kwds = {} |
| 31 |
|
| 32 |
make_la_info() |
| 33 |
|
| 34 |
class bdist_wheel_abi3(bdist_wheel): |
| 35 |
def get_tag(self): |
| 36 |
python, abi, plat = super().get_tag() |
| 37 |
|
| 38 |
if python.startswith("cp"): |
| 39 |
abi = 'abi3' |
| 40 |
python = cpstr |
| 41 |
return python,abi,plat |
| 42 |
|
| 43 |
def getVersionFromCCode(fn): |
| 44 |
with open(fn,'r') as _: |
| 45 |
code = _.read() |
| 46 |
tag = re.search(r'^#define\s+VERSION\s+"([^"]*)"',code,re.M) |
| 47 |
return tag and tag.group(1) or '' |
| 48 |
|
| 49 |
setup( |
| 50 |
ext_modules=[ |
| 51 |
Extension( |
| 52 |
"_rl_accel", |
| 53 |
sources=[pjoin('src','_rl_accel.c')], |
| 54 |
**py_limited_kwds, |
| 55 |
) |
| 56 |
], |
| 57 |
name="rl_accel", |
| 58 |
version=getVersionFromCCode(pjoin('src','_rl_accel.c')), |
| 59 |
license="BSD license (see LICENSE.txt for details), Copyright (c) 2000-2022, ReportLab Inc.", |
| 60 |
description="Acclerator for ReportLab", |
| 61 |
long_description="""This is an accelerator module for the ReportLab Toolkit Open Source Python library for generating PDFs and graphics.""", |
| 62 |
author="Andy Robinson, Robin Becker, the ReportLab team and the community", |
| 63 |
author_email="[email protected]", |
| 64 |
url="http://www.reportlab.com/", |
| 65 |
packages=[], |
| 66 |
package_data = {}, |
| 67 |
classifiers = [ |
| 68 |
'Development Status :: 5 - Production/Stable', |
| 69 |
'Intended Audience :: Developers', |
| 70 |
'License :: OSI Approved :: BSD License', |
| 71 |
'Topic :: Printing', |
| 72 |
'Topic :: Text Processing :: Markup', |
| 73 |
'Programming Language :: Python :: 3', |
| 74 |
'Programming Language :: Python :: 3.7', |
| 75 |
'Programming Language :: Python :: 3.8', |
| 76 |
'Programming Language :: Python :: 3.9', |
| 77 |
'Programming Language :: Python :: 3.10', |
| 78 |
'Programming Language :: Python :: 3.11', |
| 79 |
], |
| 80 |
license_files = ['LICENSE.txt'], |
| 81 |
|
| 82 |
|
| 83 |
install_requires=[], |
| 84 |
python_requires='>=3.7,<4', |
| 85 |
extras_require={ |
| 86 |
}, |
| 87 |
cmdclass={"bdist_wheel": bdist_wheel_abi3}, |
| 88 |
) |