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