[go: up one dir, main page]

File: setup.py

package info (click to toggle)
rl-accel 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 156 kB
  • sloc: ansic: 1,199; python: 101; makefile: 6
file content (88 lines) | stat: -rw-r--r-- 3,116 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from setuptools import setup, Extension
try:
    from setuptools.command.bdist_wheel import bdist_wheel, get_abi_tag
except ImportError:
    try:
        from wheel.bdist_wheel import bdist_wheel, get_abi_tag
    except ImportError:
        from wheel._bdist_wheel import bdist_wheel, get_abi_tag
from os.path import join as pjoin
import sys, os, sysconfig, re

def make_la_info():
    '''compute limited api and abi info'''
    global py_limited_kwds, cpstr
    cpstr = get_abi_tag()
    if cpstr.startswith("cp"):
        lav = '0x03070000'
        cpstr = 'cp37'
        if sys.platform == "darwin":
            machine = sysconfig.get_platform().split('-')[-1]
            if machine=='arm64' or os.environ.get('ARCHFLAGS','')=='-arch arm64':
                #according to cibuildwheel/github M1 supports pythons >= 3.8
                lav = '0x03080000'
                cpstr = 'cp38'
        py_limited_kwds = dict(
                                define_macros=[("Py_LIMITED_API", lav)],
                                py_limited_api=True,
                                )
    else:
        py_limited_kwds = {}

make_la_info()

class bdist_wheel_abi3(bdist_wheel):
    def get_tag(self):
        python, abi, plat = super().get_tag()

        if python.startswith("cp"):
            abi = 'abi3'
            python = cpstr
        return python,abi,plat

def getVersionFromCCode(fn):
    with open(fn,'r') as _:
        code = _.read()
    tag = re.search(r'^#define\s+VERSION\s+"([^"]*)"',code,re.M)
    return tag and tag.group(1) or ''

setup(
    ext_modules=[
        Extension(
            "_rl_accel",
            sources=[pjoin('src','_rl_accel.c')],
            **py_limited_kwds,
        )
    ],
    name="rl_accel",
    version=getVersionFromCCode(pjoin('src','_rl_accel.c')),
    license="BSD license (see LICENSE.txt for details), Copyright (c) 2000-2022, ReportLab Inc.",
    description="Acclerator for ReportLab",
    long_description="""This is an accelerator module for the ReportLab Toolkit Open Source Python library for generating PDFs and graphics.""",
    author="Andy Robinson, Robin Becker, the ReportLab team and the community",
    author_email="reportlab-users@lists2.reportlab.com",
    url="http://www.reportlab.com/",
    packages=[],
    package_data = {},
    classifiers = [
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: BSD License',
        'Topic :: Printing',
        'Topic :: Text Processing :: Markup',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Programming Language :: Python :: 3.10',
        'Programming Language :: Python :: 3.11',
        ],
    license_files = ['LICENSE.txt'],
            
    #this probably only works for setuptools, but distutils seems to ignore it
    install_requires=[],
    python_requires='>=3.7,<4',
    extras_require={
        },
    cmdclass={"bdist_wheel": bdist_wheel_abi3},
)