Ignition Scripting API now available via pypi

In the past I have shared with this community the Ignition repo I maintain at GitHub:

And inspired by a comment made by @kgamble and someone’s fork, I created the ignition-api package available to anyone interested.

Currently I have only created releases for versions 8.0.17 (8.0 branch from the repo), 8.1.9, and 8.1.10 (main branch from the repo).

I recommend using Python 2.7.18, and to install you may use any of the following:

To get the latest and/or upgrade:

$ python2 -m pip install --upgrade ignition-api

Or to get a specific version:

$ python2 -m pip install ignition-api==8.0.17.post1

or

$ python2 -m pip install ignition-api==8.1.9

For the 7.9 branch I am relying on Python 2.5 (since Ignition relies on Jython 2.5.3), so pip doesn’t appear to work, but you may still do the following:

$ git clone --single-branch --branch 7.9 https://github.com/thecesrom/Ignition.git 7.9
$ cd 7.9
$ python2 setup.py install --record files.txt

Note: Starting with release 7.9.19 all you’d have to do is download the source code for its release, un[zip|tar] it and use the setup.py from each release.

The --record option is so you create a receipt of all installed files in case you want to uninstall it by running:

$ cat files.txt | xargs rm -rf

As for the jython branch, the process is somewhat similar to 7.9's but with certain distinctions.

Note: I recommend installing Jython with pip included to make it a lot easier to install/uninstall packages.

Starting with the 8.1.10-jython release, just run the following:

$ jython -m pip install https://github.com/thecesrom/Ignition/archive/refs/tags/v8.1.10-jython.zip
DEPRECATION: A future version of pip will drop support for Python 2.7.
Collecting https://github.com/thecesrom/Ignition/archive/refs/tags/v8.1.10-jython.zip
  Using cached https://github.com/thecesrom/Ignition/archive/refs/tags/v8.1.10-jython.zip
Installing collected packages: ignition-api-jython
  Running setup.py install for ignition-api-jython ... done
Successfully installed ignition-api-jython-8.1.10

Just replace v#.#.#-jython.zip using the latest stable version.

And to uninstall:

$ jython -m pip uninstall ignition-api -y

And that’s it.

Happy coding!

7 Likes

This has been tested using Python 2.7.18, 2.5.6, and Jython 2.7.1 and 2.7.2, as well as PyCharm. All of this was so it could also work on Visual Studio Code, but unfortunately it does not.

See here:

1 Like

If at some point jython -m pip install ignition-api-jython from PyPI works, I have also created that package.

Alternatively if you wish to install it, you may use the latest release from the jython branch.

For release 8.1.10-jython you would do the following:

$ jython -m pip install https://github.com/thecesrom/Ignition/archive/refs/tags/v8.1.10-jython.zip
Collecting https://github.com/thecesrom/Ignition/archive/refs/tags/v8.1.10-jython.zip
  Downloading https://github.com/thecesrom/Ignition/archive/refs/tags/v8.1.10-jython.zip
     \ 225kB 1.6MB/s
Installing collected packages: ignition-api-jython
  Running setup.py install for ignition-api-jython ... done
Successfully installed ignition-api-jython-8.1.10
$ jython -m pip list
Package             Version
------------------- -------
ignition-api-jython 8.1.10
pip                 19.1
setuptools          41.0.1

This will allow you to do something like:

$ jython
Jython 2.7.2 (v2.7.2:925a3cc3b49d, Mar 21 2020, 10:03:58)
[OpenJDK 64-Bit Server VM (Azul Systems, Inc.)] on java11.0.11
Type "help", "copyright", "credits" or "license" for more information.
>>> import system.gui
>>> system.gui.warningBox("This one is a warning.")

image

Just make sure you change the version number from the URL, i.e. v#.#.#-jython.zip to the latest. But note that the ignition-api-jython package is for version 8.1.10 onwards.

An update.

After pip-installing ignition-api I am able to get code completion on Visual Studio Code, so I can mark the following feature request as implemented.

The following versions now include the com.inductiveautomation package, just consider that it is not a one-to-one implementation. I have only created the necessary code for some use cases.

Latest versions and how to install them:

8.1.10

$ python2 -m pip install ignition-api

8.0.17

$ python2 -m pip install ignition-api==8.0.17.post3

7.9.18

$ python2 -m pip install ignition-api==7.9.18.post2

Code completion works on PyCharm 2021.2.2 (also when running the code from its Python Console) and Visual Studio Code 1.60.2 for the following versions:
7.9.18 (from 7.9 branch)
8.0.17 (from 8.0 branch)
8.1.10 (from main branch)

As for 8.1.10-jython, Visual Studio Code does not appear to support Jython as an interpreter, and on PyCharm these are the features that work:
Code completion (a.k.a. intellisense)
Python Console (see: PY-44759, PY-50491)

And apparently Jython appears to struggle when trying to import anything under com.inductiveautomation.

So, considering all of the above, the jython branch, as fun as it was to work on it, will no longer be maintained. It will be kept until 8.1.11 is released just in case something or someone steps in.