Skip to content

Commit

Permalink
Pypi preparations (#103)
Browse files Browse the repository at this point in the history
* Getting project ready for pypi

* Add pypi to travis

* Switch readme from MD to RST

* Fix badge links

* Remove now unneeded setup.cfg file

* Setup pypi to also push universal wheel

* Couple corrections to readme

* Move old setup long description into readme

* Remove old .other package which I have no intentions of supporting in pypi

* Move a bunch of optional deps into required

* Playing with version requirements

* Just remove the pyusb versioning

* Fixing linting

* Newlines

* Remove try imports for usbtmc and vxi11

* Update readme with new pypi name
  • Loading branch information
scasagrande committed Apr 18, 2016
1 parent 2f35500 commit 61a0da0
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 203 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -16,3 +16,10 @@ script:
- pylint instruments/
after_success:
- coveralls
deploy:
provider: pypi
user: ${PYPI_USERNAME}
password: ${PYPI_PASSWORD}
distributions: "sdist bdist_wheel"
on:
tags: true
123 changes: 0 additions & 123 deletions README.md

This file was deleted.

140 changes: 140 additions & 0 deletions README.rst
@@ -0,0 +1,140 @@
InstrumentKit
=============

.. image:: https://img.shields.io/travis/Galvant/InstrumentKit.svg?maxAge=2592000
:target: https://travis-ci.org/Galvant/InstrumentKit

.. image:: https://img.shields.io/coveralls/Galvant/InstrumentKit/dev.svg?maxAge=2592000
:target: https://coveralls.io/r/Galvant/InstrumentKit?branch=dev

.. image:: https://readthedocs.org/projects/instrumentkit/badge/?version=latest
:target: https://readthedocs.org/projects/instrumentkit/?badge=latest

InstrumentKit is an open source Python library designed to help the
end-user get straight into communicating with their equipment via a PC.
InstrumentKit aims to accomplish this by providing a connection- and
vendor-agnostic API. Users can freely swap between a variety of
connection types (ethernet, gpib, serial, usb) without impacting their
code. Since the API is consistent across similar instruments, a user
can, for example, upgrade from their 1980's multimeter using GPIB to a
modern Keysight 34461a using ethernet with only a single line change.

Supported means of communication are:

- Galvant Industries GPIBUSB adapter (``open_gpibusb``)
- Serial (``open_serial``)
- Sockets (``open_tcpip``)
- VISA (``open_visa``)
- Read/write from unix files (``open_file``)
- USBTMC (``open_usbtmc``)
- VXI11 over Ethernet (``open_vxi11``)

There is planned support for HiSLIP someday, but a good Python HiSLIP library will be needed first.

If you have any problems or have code you wish to contribute back to the
project please feel free to open an issue or a pull request!

Installation
------------

The ``instruments`` package can be installed from this repository by the
following means:

From Git:

.. code-block:: console
$ git clone git@github.com:Galvant/InstrumentKit.git
$ cd InstrumentKit
$ python setup.py install
From Github using pip:

.. code-block:: console
$ pip install -e git+https://www.github.com/Galvant/InstrumentKit.git#egg=instrumentkit
From pypi using pip:

.. code-block:: console
$ pip install instrumentkit
Usage Example
-------------

To open a connection to a generic SCPI-compatible multimeter using a Galvant
Industries' GPIBUSB adapter:

.. code-block:: python
>>> import instruments as ik
>>> inst = ik.generic_scpi.SCPIMultimeter.open_gpibusb("/dev/ttyUSB0", 1)
From there, various built-in properties and functions can be called. For
example, the instrument's identification information can be retrieved by
calling the name property:

.. code-block:: python
>>> print(inst.name)
Or, since in the demo we connected to an ``SCPIMultimeter``, we can preform
multimeter-specific tasks, such as switching functions, and taking a
measurement reading:

.. code-block:: python
>>> reading = inst.measure(inst.Mode.voltage_dc)
>>> print("Value: {}, units: {}".format(reading.magnitude, reading.units))
Due to the sheer number of commands most instruments support, not every single
one is included in InstrumentKit. If there is a specific command you wish to
send, one can use the following functions to do so:

.. code-block:: python
>>> inst.sendcmd("DATA") # Send command with no response
>>> resp = inst.query("*IDN?") # Send command and retrieve response
Python Version Compatibility
----------------------------

At this time, Python 2.7, 3.3, 3.4, and 3.5 are supported. Should you encounter
any problems with this library that occur in one version or another, please
do not hesitate to let us know.

Documentation
-------------

You can find the project documentation at our ReadTheDocs pages located at
http://instrumentkit.readthedocs.org/en/latest/index.html

Contributing
------------

The InstrumentKit team always welcome additional contributions to the project.
However, we ask that you please review our contributing developer guidelines
which can be found in the documentation. We also suggest that you look at
existing classes which are similar to your work to learn more about the
structure of this project.

To run the tests against all supported version of Python, you will need to
have the binary for each installed, as well as any requirements needed to
install ``numpy`` under each Python version. On Debian/Ubuntu systems this means
you will need to install the ``python-dev`` package for each version of Python
supported (``python2.7-dev``, ``python3.3-dev``, etc).

With the required system packages installed, all tests can be run with ``tox``:

.. code-block:: console
$ pip install tox
$ tox
License
-------

All code in this repository is released under the AGPL-v3 license. Please see
the ``license`` folder for more information.
8 changes: 6 additions & 2 deletions doc/source/intro.rst
Expand Up @@ -32,12 +32,14 @@ $ pip install -r requirements.txt
- `quantities`_
- `enum34`_
- `future`_
- `python-vxi11`_
- `PyUSB`_
- `python-usbtmc`_
- `PyYAML`_

Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~

- `PyYAML`_ (required for configuration file support)
- `PyUSB`_ (version 1.0a or higher, required for raw USB support)
- `PyVISA`_ (required for accessing instruments via VISA library)

.. _PySerial: http://pyserial.sourceforge.net/
Expand All @@ -47,6 +49,8 @@ Optional Dependencies
.. _PyYAML: https://bitbucket.org/xi/pyyaml
.. _PyUSB: http://sourceforge.net/apps/trac/pyusb/
.. _PyVISA: http://pyvisa.sourceforge.net/
.. _python-usbtmc: https://pypi.python.org/pypi/python-usbtmc
.. _python-vxi11: https://pypi.python.org/pypi/python-vxi11

Getting Started
===============
Expand Down
27 changes: 1 addition & 26 deletions instruments/__init__.py
Expand Up @@ -32,16 +32,13 @@
from . import units
from .config import load_instruments

# Replace instruments.other with a deprecation warning.
import instruments.other as _other

# VERSION METADATA ###########################################################
# In keeping with PEP-396, we define a version number of the form
# {major}.{minor}[.{postrelease}]{prerelease-tag}

__version__ = "0.0.1"

__title__ = "instruments"
__title__ = "instrumentkit"
__description__ = "Test and measurement communication library"
__uri__ = "https://instrumentkit.readthedocs.org/"

Expand All @@ -50,25 +47,3 @@

__license__ = "AGPLv3"
__copyright__ = "Copyright (c) 2012-2016 Steven Casagrande"


class _Other(object):

def __getattr__(self, name):
import warnings
attr = getattr(_other, name)

msg = (
"The instruments.other package is deprecated. "
"Please use the {} package instead.".format(
".".join(attr.__module__.split(".")[:2])
)
)

# This really should be a DeprecationWarning, except those are silenced
# by default. Why?
warnings.warn(msg, UserWarning)

return attr

other = _Other()
5 changes: 1 addition & 4 deletions instruments/abstract_instruments/comm/usbtmc_communicator.py
Expand Up @@ -14,10 +14,7 @@
import io
from builtins import str, bytes

try:
import usbtmc
except ImportError:
usbtmc = None
import usbtmc

from instruments.abstract_instruments.comm import AbstractCommunicator

Expand Down
7 changes: 2 additions & 5 deletions instruments/abstract_instruments/comm/vxi11_communicator.py
Expand Up @@ -15,12 +15,9 @@

from builtins import str, bytes

from instruments.abstract_instruments.comm import AbstractCommunicator
import vxi11

try:
import vxi11
except ImportError:
vxi11 = None
from instruments.abstract_instruments.comm import AbstractCommunicator

# CLASSES #####################################################################

Expand Down
1 change: 1 addition & 0 deletions instruments/abstract_instruments/instrument.py
Expand Up @@ -591,6 +591,7 @@ def open_usb(cls, vid, pid):
:rtype: `Instrument`
:return: Object representing the connected instrument.
"""
# pylint: disable=no-member
if usb is None:
raise ImportError("USB support not imported. Do you have PyUSB "
"version 1.0 or later?")
Expand Down

0 comments on commit 61a0da0

Please sign in to comment.