Information Systems:Setting up IBM i for Python development
Jump to navigation
Jump to search
Overview
This page documents the initial stages of Python development on the i. It is meant to be a running log of notes rather than a structured article as there is a lot of trial-and-error during this stage.
Notes
General
- On the IFS, /uwdsrc was created to be the root folder to house the source of all further development.
- Krengeltech remains the best candidate as a 'Professional Services/Development Team', as they specialize in 5733-OPS, and have a close relationship with IBM in this area.
- Bitbucket and GitHub repos were created, but BitBucket will likely prevail as they offer free private repos (they're also preferred by Krengeltech for this reason).
- git is installed on the i (5733-OPS Option 6), and connections to Bitbucket and GitHub have been established i.e. /uwdsrc syncs to bitbucket.org:norwinu/uwdsrc.git. git on the i uses SSH keys (no HTTPS auth), so some were generated using the IBM tools in PASE (likely based on openssl), and added to both repo sites.
- SSHd was enabled on the i as this is the proper way of interacting with the IFS to do the open-source stuff. I personally use bash through puTTY. The daemon starts and stops with TCP/IP.
- Note: Inaccessible from internet. Uses normal sign-in.
Python
- Python 3 is installed through 5733-OPS Option 2. The current version is 3.4.4, but Python is constantly being upgraded with PTFs so this may change very soon. Python 2 will not be used.
- Python has its package manager pip, which can be used to install modules from PyPI - the official Python repository. However, some modules are provided by IBM as PTFs. It is imperative that these modules be used instead. They are often older versions but are forks of the main project for the module and are verified to work for IBM i. Upgrades to these modules should only be done through PTFs.
- The Python modules IBM ships through PTFs are:
- ibm_db (installed)
- ibm_db_django (installed)
- itoolkit (installed)
- flipflop (not installed)
- bottle (installed)
- sqlite3, as of 15:45, 14 June 2017 (PDT), does not work. See the Django section.
Django
- Django 1.7 is verified to be the most workable version. 1.8 is supposed to be supported
- Django is being tested through the built-in web server (i.e. 'python3 manage.py runserver) using port 8081.
- sqlite3 (Python module) does not currently work. There is a pending PTF by IBM to fix this. Django uses this by default but since DB2 is going to be used as a backend, sqlite3 will not be necessary.
- ibm_db_django does not work out of the box i.e. it cannot successfully connect to DB2 for i. ibm_db_django/base.py and ibm_db_dbi.py had to be edited using workarounds. It might be worth it to fork these two modules into our own repo so we can maintain a changelog of the custom changes, but right now we're going to wait it out.
- Django creates tables for its admin app. Right now, these all reside in library/schema NORWINU. Django does not seem to natively support schemas, so it works inside whatever the current library is. DB2 SQL seems to always set the current library to the current username, which is why the Django tables were all created in NORWINU.
- Journal required: Further to the previous point, the initial Django setup (i.e. 'python3 manage.py migrate) errored out since it attempted to carry out a bunch of SQL operations. It turned out DB2 SQL requires tables to be journaled before allowing INSERT/ALTER operations. Thus, journal NORLIBJRN was set up to journal to journal receiver QJRNRECV in library NORWINU. Side note: this is actually the first time we've journaled on the i - it works pretty smoothly!