Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/setuptools/extension.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import re | |
2 import functools | |
3 import distutils.core | |
4 import distutils.errors | |
5 import distutils.extension | |
6 | |
7 from .monkey import get_unpatched | |
8 | |
9 | |
10 def _have_cython(): | |
11 """ | |
12 Return True if Cython can be imported. | |
13 """ | |
14 cython_impl = 'Cython.Distutils.build_ext' | |
15 try: | |
16 # from (cython_impl) import build_ext | |
17 __import__(cython_impl, fromlist=['build_ext']).build_ext | |
18 return True | |
19 except Exception: | |
20 pass | |
21 return False | |
22 | |
23 | |
24 # for compatibility | |
25 have_pyrex = _have_cython | |
26 | |
27 _Extension = get_unpatched(distutils.core.Extension) | |
28 | |
29 | |
30 class Extension(_Extension): | |
31 """Extension that uses '.c' files in place of '.pyx' files""" | |
32 | |
33 def __init__(self, name, sources, *args, **kw): | |
34 # The *args is needed for compatibility as calls may use positional | |
35 # arguments. py_limited_api may be set only via keyword. | |
36 self.py_limited_api = kw.pop("py_limited_api", False) | |
37 _Extension.__init__(self, name, sources, *args, **kw) | |
38 | |
39 def _convert_pyx_sources_to_lang(self): | |
40 """ | |
41 Replace sources with .pyx extensions to sources with the target | |
42 language extension. This mechanism allows language authors to supply | |
43 pre-converted sources but to prefer the .pyx sources. | |
44 """ | |
45 if _have_cython(): | |
46 # the build has Cython, so allow it to compile the .pyx files | |
47 return | |
48 lang = self.language or '' | |
49 target_ext = '.cpp' if lang.lower() == 'c++' else '.c' | |
50 sub = functools.partial(re.sub, '.pyx$', target_ext) | |
51 self.sources = list(map(sub, self.sources)) | |
52 | |
53 | |
54 class Library(Extension): | |
55 """Just like a regular Extension, but built as a library instead""" |