Show More
@@ -17,9 +17,10 b' Parts of this code were taken from Cython.inline.' | |||||
17 |
|
17 | |||
18 | from __future__ import print_function |
|
18 | from __future__ import print_function | |
19 |
|
19 | |||
20 | import io |
|
|||
21 | import os, sys |
|
|||
22 | import imp |
|
20 | import imp | |
|
21 | import io | |||
|
22 | import os | |||
|
23 | import sys | |||
23 |
|
24 | |||
24 | try: |
|
25 | try: | |
25 | import hashlib |
|
26 | import hashlib | |
@@ -157,8 +158,7 b' class CythonMagics(Magics):' | |||||
157 | quiet = True |
|
158 | quiet = True | |
158 | key = code, sys.version_info, sys.executable, Cython.__version__ |
|
159 | key = code, sys.version_info, sys.executable, Cython.__version__ | |
159 | module_name = "_cython_magic_" + hashlib.md5(str(key).encode('utf-8')).hexdigest() |
|
160 | module_name = "_cython_magic_" + hashlib.md5(str(key).encode('utf-8')).hexdigest() | |
160 | so_ext = [ ext for ext,_,mod_type in imp.get_suffixes() if mod_type == imp.C_EXTENSION ][0] |
|
161 | module_path = os.path.join(lib_dir, module_name+self.so_ext) | |
161 | module_path = os.path.join(lib_dir, module_name+so_ext) |
|
|||
162 |
|
162 | |||
163 | if args.annotate: |
|
163 | if args.annotate: | |
164 | args.force = True |
|
164 | args.force = True | |
@@ -183,15 +183,7 b' class CythonMagics(Magics):' | |||||
183 | extra_link_args = args.link_args, |
|
183 | extra_link_args = args.link_args, | |
184 | libraries = args.lib, |
|
184 | libraries = args.lib, | |
185 | ) |
|
185 | ) | |
186 |
|
|
186 | build_extension = self._get_build_extension() | |
187 | config_files = dist.find_config_files() |
|
|||
188 | try: |
|
|||
189 | config_files.remove('setup.cfg') |
|
|||
190 | except ValueError: |
|
|||
191 | pass |
|
|||
192 | dist.parse_config_files(config_files) |
|
|||
193 | build_extension = build_ext(dist) |
|
|||
194 | build_extension.finalize_options() |
|
|||
195 | try: |
|
187 | try: | |
196 | build_extension.extensions = cythonize([extension], quiet=quiet, |
|
188 | build_extension.extensions = cythonize([extension], quiet=quiet, | |
197 | annotate=args.annotate, force=args.force) |
|
189 | annotate=args.annotate, force=args.force) | |
@@ -221,6 +213,27 b' class CythonMagics(Magics):' | |||||
221 | else: |
|
213 | else: | |
222 | return display.HTML(annotated_html) |
|
214 | return display.HTML(annotated_html) | |
223 |
|
215 | |||
|
216 | @property | |||
|
217 | def so_ext(self): | |||
|
218 | """The extension suffix for compiled modules.""" | |||
|
219 | try: | |||
|
220 | return self._so_ext | |||
|
221 | except AttributeError: | |||
|
222 | self._so_ext = self._get_build_extension().get_ext_filename('') | |||
|
223 | return self._so_ext | |||
|
224 | ||||
|
225 | def _get_build_extension(self): | |||
|
226 | dist = Distribution() | |||
|
227 | config_files = dist.find_config_files() | |||
|
228 | try: | |||
|
229 | config_files.remove('setup.cfg') | |||
|
230 | except ValueError: | |||
|
231 | pass | |||
|
232 | dist.parse_config_files(config_files) | |||
|
233 | build_extension = build_ext(dist) | |||
|
234 | build_extension.finalize_options() | |||
|
235 | return build_extension | |||
|
236 | ||||
224 | _loaded = False |
|
237 | _loaded = False | |
225 |
|
238 | |||
226 | def load_ipython_extension(ip): |
|
239 | def load_ipython_extension(ip): |
General Comments 0
You need to be logged in to leave comments.
Login now