From a820f08b51b8d05bce8675cb899070ddee67a71f Mon Sep 17 00:00:00 2001 From: alexcjohnson <alex@plot.ly> Date: Wed, 3 Feb 2016 15:26:47 +0100 Subject: [PATCH 1/4] convert js/css display to pkg_resources --- qcodes/widgets/display.py | 60 +++++++++++++++++++-------------------- qcodes/widgets/widgets.py | 6 ++-- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/qcodes/widgets/display.py b/qcodes/widgets/display.py index 8723bdb118a..fab1dfb15fe 100644 --- a/qcodes/widgets/display.py +++ b/qcodes/widgets/display.py @@ -1,41 +1,41 @@ import os +from pkg_resources import resource_string from IPython.display import display, Javascript, HTML -def display_relative(base_file, rel_path, file_type=None): +def display_auto(qcodes_path, file_type=None): ''' - display some javascript, css, or html content in the notebook - from a relative file path. Will use the file extension + Display some javascript, css, or html content in the notebook + from a package-relative file path. Will use the file extension + to determine file type unless overridden by file_type - base_file: a directory or file (will use its parent directory) from which - to find the target file + qcodes_path: the path to the target file within the qcodes package - rel_path: the path to the target file from the base file + file_type: optionally override the file extension to determine + what type of file this is ''' - # some people use pkg_resources.resource_string for this, but that seems to - # require an absolute path within the package. - # this way lets us use a relative path - if os.path.isdir(base_file): - base_path = base_file + # Originally I implemented this using regular open() and read(), so it + # could use relative paths from the importing file. + # + # But for distributable packages, pkg_resources.resource_string is the + # best way to load data files, because it works even if the package is + # in an egg or zip file. See: + # http://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime + contents = resource_string('qcodes', qcodes_path).decode('utf-8') + if file_type is None: + ext = os.path.splitext(qcodes_path)[1].lower() + elif 'js' in file_type.lower(): + ext = '.js' + elif 'css' in file_type.lower(): + ext = '.css' else: - base_path = os.path.split(base_file)[0] + ext = '.html' - with open(os.path.join(base_path, rel_path)) as f: - contents = f.read() - if file_type is None: - ext = os.path.splitext(rel_path)[1].lower() - elif 'js' in file_type.lower(): - ext = '.js' - elif 'css' in file_type.lower(): - ext = '.css' - else: - ext = '.html' - - if ext == '.js': - display(Javascript(contents)) - elif ext == '.css': - display(HTML('<style>' + contents + '</style>')) - else: - # default to html. Anything else? - display(HTML(contents)) + if ext == '.js': + display(Javascript(contents)) + elif ext == '.css': + display(HTML('<style>' + contents + '</style>')) + else: + # default to html. Anything else? + display(HTML(contents)) diff --git a/qcodes/widgets/widgets.py b/qcodes/widgets/widgets.py index 6a8b7a4b3a0..2088a0323e5 100644 --- a/qcodes/widgets/widgets.py +++ b/qcodes/widgets/widgets.py @@ -4,12 +4,12 @@ from traitlets import Unicode, Float from qcodes.utils.multiprocessing import get_stream_queue -from .display import display_relative +from .display import display_auto from qcodes.loops import MP_NAME, halt_bg -display_relative(__file__, 'widgets.js') -display_relative(__file__, 'widgets.css') +display_auto('widgets/widgets.js') +display_auto('widgets/widgets.css') class UpdateWidget(widgets.DOMWidget): From 096a2eba553c1be04153cf562343d9a2b8b2439e Mon Sep 17 00:00:00 2001 From: alexcjohnson <alex@plot.ly> Date: Wed, 3 Feb 2016 16:29:29 +0100 Subject: [PATCH 2/4] setup.py --- setup.cfg | 3 +++ setup.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000000..b155904d1c9 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[nosetests] +with-coverage=1 +cover-package=qcodes \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 00000000000..95e711a45c8 --- /dev/null +++ b/setup.py @@ -0,0 +1,51 @@ +from setuptools import setup, find_packages + + +def readme(): + with open('README.md') as f: + return f.read() + + +setup(name='qcodes', + version='0.1.0', + use_2to3=False, + author='Alex Johnson', + author_email='johnson.alex.c@gmail.com', + maintainer='Alex Johnson', + maintainer_email='johnson.alex.c@gmail.com', + description='Python-based data acquisition framework developed by the ' + 'Copenhagen / Delft / Sydney / Microsoft quantum computing ' + 'consortium', + long_description=readme(), + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Science/Research', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Topic :: Scientific/Engineering' + ], + license='Private', + # if we want to install without tests: + # packages=find_packages(exclude=["*.tests", "tests"]), + packages=find_packages(), + package_data={'qcodes': ['widgets/*.js', 'widgets/*.css']}, + install_requires=[ + 'numpy>=1.10', + 'pyvisa>=1.8', + 'IPython>=4.0', + 'ipywidgets>=4.1' + # nose and coverage are only for tests, but we'd like to encourage + # people to run tests! + 'nose>=1.3', + 'coverage>=4.0' + ], + extras_require={ + 'MatPlot': ['matplotlib>=1.5'], + 'QtPlot': ['pyqtgraph>=0.9.10'] + }, + # I think the only part of qcodes that would care about zip_safe + # is utils.helpers.reload_code; users of a zip-installed package + # shouldn't be needing to do this anyway, but we should test first. + zip_safe=False) From 4eddb33cf916dcafbc20ddc14eeb04936efc8a49 Mon Sep 17 00:00:00 2001 From: alexcjohnson <alex@plot.ly> Date: Wed, 3 Feb 2016 21:22:24 +0100 Subject: [PATCH 3/4] update readmes and example nb using setup.py --- CONTRIBUTING.md | 11 +- README.md | 34 +++-- docs/examples/Qcodes example.ipynb | 197 ++++++++++++++++------------- 3 files changed, 132 insertions(+), 110 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3f8883e1c1..b1d8a67eac5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,16 +22,13 @@ Figured out a new way to use qcodes? Found a package that makes your life better ### Setup -- Install git: the [command-line toolset](https://git-scm.com/) is the most powerful but the [desktop GUI from github](https://desktop.github.com/) is also quite powerful +- Clone and register the package for development as described in [README.md#installation] -- Clone this repo: +- Run the tests. In the root directory of the repository: ``` -git clone https://github.com/qdev-dk/Qcodes.git +python setup.py nosetests ``` - -- Install the dependencies, including for testing (see [README.md#Requirements]) - -- Run the tests. In the root directory of the repository: +or: ``` nosetests --with-coverage --cover-package=qcodes ``` diff --git a/README.md b/README.md index 2caf397e975..69bdcf1594d 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,32 @@ Qcodes is compatible with Python 3.3+. It is primarily intended for use from Jup We recommend [Anaconda](https://www.continuum.io/downloads) as an easy way to get most of the dependencies out-of-the-box. -### Requirements +As the project is still private, install it directly from this repository: -(Note: with the exception of Python itself, these are just the versions currently installed by the core developers. We haven't tested compatibility with lower versions of most packages, but if you know that an older version works fine, please let us know. If a lower OR higher version of any package breaks Qcodes please open an issue.) +- Install git: the [command-line toolset](https://git-scm.com/) is the most powerful but the [desktop GUI from github](https://desktop.github.com/) is also quite good -- Python 3.3+ -- numpy 1.10+ -- pyvisa 1.8+ -- IPython 4.0+ -- ipywidgets 4.1+ -- matplotlib 1.5+ (only for matplotlib plotting) -- pyqtgraph 0.9.10+ (only for pyqtgraph plotting) +- Clone this repository somewhere on your hard drive. If you're using command line git, open a terminal window in the directory where you'd like to put qcodes and type: +``` +git clone https://github.com/qdev-dk/Qcodes.git +``` + +- Register it with Python, and install dependencies if any are missing: run this from the root directory of the repository you just cloned: +``` +python setup.py develop +``` + +Now Qcodes should be available to import into all Python sessions you run. To test, run `python` from some other directory (not where you just ran `setup.py`) and type `import qcodes`. If it works without an error you're ready to go. + +### Plotting Requirements + +Because these can sometimes be tricky to install (and not everyone will want all of them), the plotting packages are not set as required dependencies, so setup.py will not automatically install them. You can install them with `pip`: + +- For `qcodes.MatPlot`: matplotlib version 1.5 or higher +- For `qcodes.QtPlot`: pyqtgraph version 0.9.10 or higher -for testing: +### Updating Qcodes -- nose 1.3+ -- coverage 4.0+ +If you registered Qcodes with Python via `setup.py develop`, all you need to do to get the latest code is open a terminal window pointing to anywhere inside the repository and run `git pull` ## Usage diff --git a/docs/examples/Qcodes example.ipynb b/docs/examples/Qcodes example.ipynb index ecc0ed5d3a0..cf8d0753929 100644 --- a/docs/examples/Qcodes example.ipynb +++ b/docs/examples/Qcodes example.ipynb @@ -234,7 +234,7 @@ " min-height: 50px;\n", " max-height: 400px;\n", " min-width: 400px;\n", - " max-width: 600px;\n", + " max-width: 700px;\n", "}</style>" ], "text/plain": [ @@ -251,13 +251,6 @@ "import time\n", "import numpy as np\n", "\n", - "# load the qcodes path, until we have this installed as a package\n", - "import sys\n", - "import os\n", - "qcpath = os.path.join('..','..')\n", - "if qcpath not in sys.path:\n", - " sys.path.append(qcpath)\n", - "\n", "import qcodes as qc\n", "\n", "qc.set_mp_method('spawn') # force Windows behavior on mac\n", @@ -342,7 +335,7 @@ "DataSet: DataMode.PULL_FROM_SERVER, location='testsweep'\n", " amplitude: amplitude\n", " chan0: chan0\n", - "started at 2016-01-28 14:53:15\n" + "started at 2016-02-03 21:16:47\n" ] } ], @@ -370,80 +363,102 @@ "data": { "text/plain": [ "{'amplitude': DataArray[400]: amplitude\n", - " array([ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan]), 'chan0': DataArray[400]: chan0\n", - " array([ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", - " nan, nan, nan, nan])}" + " array([ 0.117, 0.117, 0.115, 0.111, 0.106, 0.099, 0.092, 0.085,\n", + " 0.077, 0.071, 0.064, 0.058, 0.053, 0.048, 0.044, 0.04 ,\n", + " 0.037, 0.034, 0.031, 0.029, 0.027, 0.025, 0.023, 0.022,\n", + " 0.02 , 0.019, 0.018, 0.017, 0.016, 0.015, 0.014, 0.013,\n", + " 0.013, 0.012, 0.011, 0.011, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan]),\n", + " 'chan0': DataArray[400]: chan0\n", + " array([-20. , -19.9, -19.8, -19.7, -19.6, -19.5, -19.4, -19.3, -19.2,\n", + " -19.1, -19. , -18.9, -18.8, -18.7, -18.6, -18.5, -18.4, -18.3,\n", + " -18.2, -18.1, -18. , -17.9, -17.8, -17.7, -17.6, -17.5, -17.4,\n", + " -17.3, -17.2, -17.1, -17. , -16.9, -16.8, -16.7, -16.6, -16.5,\n", + " -16.4, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan, nan, nan, nan, nan, nan,\n", + " nan, nan, nan, nan])}" ] }, "execution_count": 5, @@ -485,10 +500,10 @@ "text": [ "DataSet: DataMode.PULL_FROM_SERVER, location='test2d'\n", " amplitude_3: amplitude\n", - " chan1: chan1\n", " chan0: chan0\n", + " chan1: chan1\n", " amplitude_0: amplitude\n", - "started at 2016-01-28 14:53:48\n" + "started at 2016-02-03 21:17:12\n" ] } ], @@ -523,13 +538,13 @@ "text": [ "DataSet: DataMode.PULL_FROM_SERVER, location='test_multi_d'\n", " amplitude_5_0: amplitude\n", + " chan1: chan1\n", " chan2: chan2\n", " avg_amplitude: avg_amplitude\n", - " amplitude_2: amplitude\n", " amplitude_3_0: amplitude\n", + " amplitude_2: amplitude\n", " chan0: chan0\n", - " chan1: chan1\n", - "started at 2016-01-28 14:54:39\n" + "started at 2016-02-03 21:17:52\n" ] } ], @@ -558,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": { "collapsed": false, "scrolled": false @@ -569,11 +584,11 @@ "output_type": "stream", "text": [ "DataSet: DataMode.PULL_FROM_SERVER, location='test_complex_param'\n", + " avg_amplitude: avg_amplitude\n", " amplitude: amplitude\n", " chan2: chan2\n", " chan1: chan1\n", - " avg_amplitude: avg_amplitude\n", - "started at 2016-01-28 14:56:48\n" + "started at 2016-02-03 21:19:59\n" ] } ], From ef2edb28e6b7d3a475b78b5a54f5096d74c0d9a0 Mon Sep 17 00:00:00 2001 From: alexcjohnson <alex@plot.ly> Date: Wed, 3 Feb 2016 22:13:22 +0100 Subject: [PATCH 4/4] setup.py checks plot package versions --- setup.py | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 95e711a45c8..857171d001f 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,17 @@ from setuptools import setup, find_packages +from distutils.version import StrictVersion +from importlib import import_module def readme(): with open('README.md') as f: return f.read() +extras = { + 'MatPlot': ('matplotlib', '1.5'), + 'QtPlot': ('pyqtgraph', '0.9.10') +} +extras_require = {k: '>='.join(v) for k, v in extras.items()} setup(name='qcodes', version='0.1.0', @@ -35,17 +42,37 @@ def readme(): 'numpy>=1.10', 'pyvisa>=1.8', 'IPython>=4.0', - 'ipywidgets>=4.1' + 'ipywidgets>=4.1', # nose and coverage are only for tests, but we'd like to encourage # people to run tests! 'nose>=1.3', 'coverage>=4.0' ], - extras_require={ - 'MatPlot': ['matplotlib>=1.5'], - 'QtPlot': ['pyqtgraph>=0.9.10'] - }, + extras_require=extras_require, # I think the only part of qcodes that would care about zip_safe # is utils.helpers.reload_code; users of a zip-installed package # shouldn't be needing to do this anyway, but we should test first. zip_safe=False) + +version_template = ''' +***** +***** package {0} must be at least version {1}. +***** Please upgrade it (pip install -U {0}) in order to use {2} +***** +''' + +missing_template = ''' +***** +***** package {} not found +***** Please install it in order to use {} +***** +''' + +# now test the versions of extras +for extra, (module_name, min_version) in extras.items(): + try: + module = import_module(module_name) + if StrictVersion(module.__version__) < StrictVersion(min_version): + print(version_template.format(module_name, min_version, extra)) + except ImportError: + print(missing_template.format(module_name, extra))