Hi Colin,
I think the wheels binary format is what you are looking for. You can install it into a venv (see previous message) using
pip3 install wheel
, then build your package using
python3 setup.py bdist_wheel
(assuming it uses setuptools). It'll generate a binary file with both your Python + shared libs already compiled. Then this file can be installed by doing a
pip3 install <file.whl>
, even for users that do not have wheel installed, so it can still be a single command to install. This should only be used for Python 3.10, not lower versions of IBM Open Enterprise SDK for Python. To answer your question though, the reason it gives you the error is that the
bdist
distribution format is meant so that you extract/copy it yourself, pip does not handle that. When you use
bdist_wheel
, it will, which will fix your error.
There's been two main ways Python has typically done distribution of packages - distutils and setuptools. As of Python 3.10, distutils has now been marked as deprecated (to be removed in 3.12), so should no longer be used. That said, there is some documentation still available for it
here (and this can be swapped to use setuptools by simply changing the import statements). Setuptools has replaced distutils, and largely provides the same experience / options, and you can find some examples on how to get started with it
here - there isn't anything z/OS specific, so any general guide on distutils/setuptools can be used. You may find articles like
this useful for simple examples on using setuptools with c extensions.
When it comes to the actual distribution, here's a quick explanation of the commands for creating the archive files (pip will prefer wheels when installing, i.e any dependency):
python3 setup.py sdist
- Creates a source distribution, i.e. contains the raw source files, when the installing the user will compile any requirements
python3 setup.py bdist
- Creates a binary distribution, i.e contains the compiled shared libs + Python files. The user must extract/copy the files to the destination
python3 setup.py bdist_wheel
- Creates a binary distribution, similar to bdist
but it will install directly with pip
Regards,
Steven
------------------------------
Steven Pitman
------------------------------
Original Message:
Sent: Wed January 05, 2022 12:00 PM
From: Colin Paice
Subject: What is the best way to package on z/OS
Steven,
I'm struggling with packaging and installing it.
I'm using python3 setup.py bdist to build my file, and in a virtual environment I'm using
python3 -m pip install -v -v -v --user --no-cache-dir /u/pymqi/dist/pymqi-1.12.0.os390-27.00-1090.tar.gz 1>a 2>b
This gives me
pip._internal.exceptions.InstallationError: file:///u/pymqi/dist/pymqi-1.12.0.os390-27.00-1090.tar.gz
does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
and it is correct - setup.py is not in the package.
I read that pip does not handle bdist files, and I should use bdist_wheel. I could not get this to work, and it looks wheel is not installed by default on z/OS 3.10.
I also saw that setup.py from distutils is deprecated; but I could not find a way of building a C extension... I can use setuptools for pure python - but could not find how to compile things.
Is there any documentation of how to build an extension on z/OS?
regards
Colin
------------------------------
Colin Paice
Original Message:
Sent: Tue January 04, 2022 11:09 AM
From: Steven Pitman
Subject: What is the best way to package on z/OS
Hi Colin,
For storing the package, there's a few options you can take:
1) If the user has access to IBM z/OS XL C/C++ and it's open source, you could submit it to PyPI and have the user install the package with pip, like any other package
2) If they have access to Rocket Git, you could also only store it on GitHub, and install it with pip directly from there
3) If it's not open source, you could store the binary (the pax & tar formats can support file tagging) on Github or any other file management system (ex: Artifactory) and have the user download it
For installing IBM Open Enterprise SDK for Python without a sysprog, you can download the pax edition and follow the Installation documentation. If you already have Python installed with SMP/E or it was installed into a directory you do not have write access to, Python comes with the module venv (sample usage found here). This module can create a local environment of Python, which you can then use to install packages into for any testing required.
Steven
------------------------------
Steven Pitman
Original Message:
Sent: Tue January 04, 2022 07:35 AM
From: Colin Paice
Subject: What is the best way to package on z/OS
I am looking at porting the PYMQI package to z/OS.
What is the best way to package it and make it available? There are some .py files, and a C program which gets compiled and bound into pymqe.cpython-310.so .
I could create a zip package and store it on GitHub, so you would have to download, it, upload it and install it.
What is the right way of doing it?
Also in many customers, Python is on a read only zfs system.
What is the best way of installing it in my local system and running with it, (think of it as evaluation mode) rather than get the sysprog to update production.
Colin
------------------------------
Colin Paice
------------------------------