Skip to content

Commit

Permalink
Merged in cbillington/runviewer/cython (pull request labscript-suite#21)
Browse files Browse the repository at this point in the history
Port resample to Cython

Approved-by: Jan Werkmann <[email protected]>
  • Loading branch information
chrisjbillington committed Mar 27, 2018
2 parents d8fd8ce + 57f23d0 commit 776f704
Show file tree
Hide file tree
Showing 27 changed files with 194 additions and 292 deletions.
49 changes: 14 additions & 35 deletions resample/__init__.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
from __future__ import division, unicode_literals, print_function, absolute_import
from labscript_utils import PY2
from __future__ import print_function, unicode_literals, division, absolute_import
from labscript_utils import PY2, check_version
if PY2:
str = unicode
import os
import platform
import shutil
import importlib
import sys

# This sub-package is a proxy for the extensension file that abstracts the platform.
# Here we check what platform we are on and we import the appropriate extension from
# yet another sub-package, of which there is one for each supported platform.
# Then we pull out the resample function from that extension into this packages namespace
# so that importers see it here without having to know what platform we are on.
# Importers can simply do: 'from runviewer.resample import resample' to get the resample function.
try:
import autocython
except ImportError:
msg = ('autocython required, installable via pip')
raise RuntimeError(msg)

if __name__ == '__main__':
raise RuntimeError('Due to funny import rules, this file can\'t be run as __main__.' +
'please do \'import runmanager.resample\' from elsewhere to run it.')
check_version('autocython', '1.1', '2.0')
from autocython import ensure_extensions_compiled, import_extension

arch, _ = platform.architecture()
os_platform = sys.platform
if arch == '32bit' and os_platform == 'win32':
plat_name = 'win32'
file_name = 'resample.pyd'
elif arch == '64bit' and os_platform == 'win32':
plat_name = 'win64' if PY2 else 'win64Py3'
file_name = 'resample.pyd'
elif arch == '64bit' and (os_platform == "linux" or os_platform == "linux2"):
plat_name = 'linux64' if PY2 else 'linux64Py3'
file_name = 'resample.so'
elif arch == '64bit' and os_platform == "darwin":
plat_name = 'darwin64' if PY2 else 'darwin64Py3'
file_name = 'resample.so'
else:
raise RuntimeError('Unsupported platform, please report a bug')

module = importlib.import_module('runviewer.resample.%s.resample' % plat_name)

resample = module.resample
ensure_extensions_compiled(os.path.abspath(os.path.dirname(__file__)))
extension = import_extension('runviewer.resample.resample')
resample = extension.resample
42 changes: 42 additions & 0 deletions resample/autocython_compile_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"resample.cp36-win32.pyd": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "ef5383c1b4968230799085714313a518a9e603dbd0448372a4bddea7f423112b",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample.cp36-win_amd64.pyd": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "b1f0585bd9ed8eb4285ec2b8516b75eb997684a3690f0f25026d3620878515cb",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample.cpython-36m-darwin.so": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "ea100d1214a42dfd07146c2e74098845a6d4adb56b2cf2580a4e0b03857cce8b",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample.cpython-36m-x86_64-linux-gnu.so": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "32f05264c238ad88e75a6f59e39685ce0ae9ddcde3f4b11b28e7d8df2e07ecdc",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample_py27_darwin_64bit.so": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "5238be09a0f6ab29c04f4d398feee4ac8cf5de8ead1ab1d2a0f6d7d2f58a2c3e",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample_py27_linux2_64bit.so": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "81398ba177a256c98b3a38eed628273b3efdefe87e15df430d30ca58316d438f",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample_py27_win32_32bit.pyd": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "7d2322dbf682c9819e56d989e160d1967d9a2470ad260cd47d9ea245cd51394c",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
},
"resample_py27_win32_64bit.pyd": {
"pyx": "2ce9098cc8a417339614b97bdae1a54f333308bba5d680b1237ea835ecc819e0",
"so": "d5705368d4fae13b5f4ad50e175029c81f71cbe8de4a94a2c07c3300f2688f87",
"setup.py": "2717ccaf1ef62b0dac38b67613bfc703b9f313d76c8ac35dee1a8ea2f58940b7"
}
}
Empty file removed resample/darwin64/__init__.py
Empty file.
Binary file removed resample/darwin64/resample.so
Binary file not shown.
Empty file removed resample/darwin64Py3/__init__.py
Empty file.
Binary file removed resample/darwin64Py3/resample.so
Binary file not shown.
Empty file removed resample/linux64/__init__.py
Empty file.
Binary file removed resample/linux64/resample.so
Binary file not shown.
Empty file removed resample/linux64Py3/__init__.py
Empty file.
Binary file removed resample/linux64Py3/resample.so
Binary file not shown.
244 changes: 0 additions & 244 deletions resample/resample.c

This file was deleted.

Binary file added resample/resample.cp36-win32.pyd
Binary file not shown.
Binary file added resample/resample.cp36-win_amd64.pyd
Binary file not shown.
Binary file added resample/resample.cpython-36m-darwin.so
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 776f704

Please sign in to comment.