Skip to content

Commit

Permalink
Python wheels support (#878)
Browse files Browse the repository at this point in the history
Update bld_wheels_and_upload.yml
  • Loading branch information
Earammak authored Aug 17, 2023
1 parent 00e4e56 commit ec969b7
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 61 deletions.
94 changes: 59 additions & 35 deletions .github/workflows/bld_wheels_and_upload.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
name: Build and upload to PyPI

# Build on every branch push, tag push, and pull request change:
# Build on every workflow_dispatch, branch push, tag push, and pull request change
on:
#workflow_dispatch:
workflow_dispatch:
pull_request:
push:
branches:
- WheelSupport
- master
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build_wheels_windows_64:
name: Build wheels on ${{ matrix.os }} 64-bit
name: Build wheels on ${{ matrix.os }} 64-bit
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v3
- name: Build wheels
uses: pypa/[email protected].1
uses: pypa/[email protected].2
env:
CIBW_SKIP: "*-win32"
CIBW_SKIP: "*pp3*"
CIBW_BUILD: "*-win_amd64"
CIBW_SKIP: "cp36-* pp*"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
Expand All @@ -33,9 +38,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build wheels
uses: pypa/[email protected].1
uses: pypa/[email protected].2
env:
CIBW_BUILD: "*-win32"
CIBW_SKIP: "cp36-* pp*"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
Expand All @@ -45,14 +51,13 @@ jobs:
strategy:
matrix:
os: [macos-latest,ubuntu-latest]
#os: [windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Build wheels
uses: pypa/[email protected].1
uses: pypa/[email protected].2
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_SKIP: "*-musllinux_* pp*"
CIBW_SKIP: "cp36-* *-musllinux_* pp* *-*linux_{aarch64,ppc64le}"
CIBW_REPAIR_WHEEL_COMMAND_LINUX:
auditwheel repair
--exclude libdb2.so.1
Expand All @@ -75,40 +80,59 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip build
run: python -m pip install --upgrade pip build
- name: Build sdist
run: python -m build --sdist --no-isolation
- name: Package version
id: version
run: |
cd dist
pip install ibm_db*
echo "VERSION=$(python -c 'import ibm_db; print(ibm_db.__version__)')" >> $GITHUB_OUTPUT
- name: Build source distribution
run: |
PACKAGE="ibm_db-$VERSION"
cd dist
tar -xzf $PACKAGE.tar.gz
rm -rf $PACKAGE/clidriver*
rm -rf $PACKAGE.tar.gz
tar -czf $PACKAGE.tar.gz $PACKAGE
rm -rf $PACKAGE
env:
VERSION: ${{ steps.version.outputs.VERSION}}
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
path: ./dist/*.tar.gz
path: |
./dist/*.tar.gz
upload_pypi:
needs: [build_sdist,build_wheels_macos_linux, build_wheels_windows_64,build_wheels_windows_32]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
#upload to PyPI on every tag starting with 'v'
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: Upload to testpypi
path: dist
- uses: pypa/[email protected]
with:
user: ${{secrets.TESTPYPI_USER}}
password: ${{secrets.TESTPYPI_PASSWORD}}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

- name: Upload to PYPI
uses: pypa/gh-action-pypi-publish@master
with:
user: ${{secrets.TESTPYPI_USER}}
password: ${{secrets.TESTPYPI_PASSWORD}}
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
#if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{secrets.TESTPYPI_USER}}
password: ${{ secrets.TESTPYPI_PASSWORD}}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{secrets.PYPI_USER}}
password: ${{ secrets.PYPI_PASSWORD}}

19 changes: 19 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
2023-08-08, Version 3.1.5
=========================

* Fix for issue #857 (Earammak)

* Support for Null value for an array (Earammak)

* Fix for issue #838 (Earammak)

* Code change #837 and readme update (Earammak)

* Optimize _checkGcc in setup.py (pschoen-itsc)

* Initial wheel support code changes (Earammak)

* Fix for issues #823 and #828 (Earammak)

* Readme update for latest python #813 and Readme update #814 (Earammak)

2022-11-24, Version 3.1.4
=========================

Expand Down
17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Provides Python interface for connecting to IBM Db2 for LUW, IBM Informix and IB

<a name="prereq"></a>
## Pre-requisites
Install Python 2.7 or Python 3 <= 3.11. The minimum python version supported by driver is python 2.7 and the latest version supported is python 3.11 except version 3.3 as it has reached end-of-life.
Install Python 3.7 <= 3.11. The minimum python version supported by driver is python 3.7 and the latest version supported is python 3.11.

> **For MacOS M1 / Apple Silicon chip system**
>
Expand All @@ -62,18 +62,6 @@ Install Python 2.7 or Python 3 <= 3.11. The minimum python version supported by
> ```
> 2. When regular installation does not work, it might help to preface your installation command with `ARCHFLAGS="-arch x86_64"`. Be sure to have uninstalled `ibm_db` before installing again, otherwise this fix won't help.
The pre-built 32-bit and 64-bit binaries on windows are available for the following versions:
```
python 2.7
python 3.4
python 3.5
python 3.6
python 3.7
python 3.8
python 3.9
python 3.10
python 3.11
```
You might need zlib, openssl, pip installations if not already available in your setup.
Expand Down Expand Up @@ -109,7 +97,8 @@ If you have to use your own URL for clidriver please set environment variable
IBM_DB_INSTALLER_URL
```
If you are using python 3.8 or 3.9 on windows and building the source manually, you will need to set dll path of dependent library of clidriver before importing the module as:
Note: For windows after installing ibm_db, we need to make sure to set dll path of dependent library of clidriver before importing the module as:
```
import os
os.add_dll_directory('path to clidriver installation until bin')
Expand Down
4 changes: 3 additions & 1 deletion ibm_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
+--------------------------------------------------------------------------+
*/

#define MODULE_RELEASE "0.0.12"
#define MODULE_RELEASE "3.1.4"

#include <Python.h>
#include <datetime.h>
Expand Down Expand Up @@ -12405,6 +12405,7 @@ INIT_ibm_db(void) {
PyModule_AddIntConstant(m, "SQL_ATTR_PARAM_BIND_TYPE", SQL_ATTR_PARAM_BIND_TYPE);
PyModule_AddIntConstant(m, "SQL_PARAM_BIND_BY_COLUMN", SQL_PARAM_BIND_BY_COLUMN);
PyModule_AddIntConstant(m, "SQL_ATTR_XML_DECLARATION", SQL_ATTR_XML_DECLARATION);
#ifndef __MVS__
PyModule_AddIntConstant(m, "SQL_ATTR_CLIENT_APPLCOMPAT", SQL_ATTR_CLIENT_APPLCOMPAT);
PyModule_AddIntConstant(m, "SQL_ATTR_CURRENT_PACKAGE_SET", SQL_ATTR_CURRENT_PACKAGE_SET);
PyModule_AddIntConstant(m, "SQL_ATTR_ACCESS_MODE", SQL_ATTR_ACCESS_MODE);
Expand Down Expand Up @@ -12491,6 +12492,7 @@ INIT_ibm_db(void) {
PyModule_AddIntConstant(m, "SQL_ATTR_IGNORE_SERVER_LIST",SQL_ATTR_IGNORE_SERVER_LIST);
PyModule_AddIntConstant(m, "SQL_ATTR_DECFLOAT_ROUNDING_MODE", SQL_ATTR_DECFLOAT_ROUNDING_MODE);
PyModule_AddIntConstant(m, "SQL_ATTR_PING_DB", SQL_ATTR_PING_DB);
#endif
PyModule_AddIntConstant(m, " SQL_ATTR_TXN_ISOLATION", SQL_ATTR_TXN_ISOLATION);
return MOD_RETURN_VAL(m);
}
4 changes: 2 additions & 2 deletions ibm_db_dbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ def _set_cursor_helper(self):
self.messages.append(_get_exception(inst))
raise self.messages[len(self.messages) - 1]
if not num_columns:
return True
return False
self._result_set_produced = True

return True
Expand Down Expand Up @@ -1406,8 +1406,8 @@ def execute(self, operation, parameters=None):
self.__description = None
self._all_stmt_handlers = []
self._prepare_helper(operation)
self._set_cursor_helper()
self._execute_helper(parameters)
self._set_cursor_helper()
return self._set_rowcount()

def executemany(self, operation, seq_parameters):
Expand Down
26 changes: 26 additions & 0 deletions install.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ Below steps were followed for the same:

- NOTE(Default behaviour):
- IBM_DB_HOME is the HLQ for your Db2 libraries(SDSNMACS, SDSNC.H)

- For compatibility with python ibm_db the following parameters must be set in the ODBC ini file
CURRENTAPPENSCH=ASCII or CURRENTAPPENSCH=UNICODE (CURRENTAPPENSCH=EBCDIC is not supported)
MULTICONTEXT=2
FLOAT=IEEE
e.g.
```; This is a comment line...
; Example COMMON stanza
[COMMON]
MVSDEFAULTSSID=VC1A
CONNECTTYPE=1
MULTICONTEXT=2
CURRENTAPPENSCH=ASCII
FLOAT=IEEE
; Example SUBSYSTEM stanza for VC1A subsystem
[VC1A]
MVSATTACHTYPE=RRSAF
PLANNAME=DSNACLI
; Example DATA SOURCE stanza for STLEC1 data source
[STLEC1]
AUTOCOMMIT=1
CURSORHOLD=1
```
- The ODBC ini file must be encoded in IBM-1047 and cannot have the text tag on, e.g.,
chtag -b $DSNAOINI or chtag -m -c IBM-1047 $DSNAOINI.
Use chtag -p $DSNAOINI to verify that the file have T=off (text tag off) and is either tagged binary or mixed IBM-1047.

e.g.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.cibuildwheel.macos]
repair-wheel-command = "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
repair-wheel-command = "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from setuptools.command.build_ext import build_ext
from setuptools.command.install import install

PACKAGE = 'ibm_db_wheel'
VERSION = '0.0.12'
PACKAGE = 'ibm_db'
VERSION = '3.1.4'
LICENSE = 'Apache License 2.0'
readme = os.path.join(os.path.dirname(__file__),'README.md')

Expand Down Expand Up @@ -461,7 +461,7 @@ def print_exception( e, url):
(get_python_lib(), ['./LICENSE']),
(get_python_lib(), ['./config.py.sample'])]

modules = ['ibm_db','ibm_db_dbi', 'testfunctions', 'ibmdb_tests']
modules = ['ibm_db_dbi', 'testfunctions', 'ibmdb_tests']

if 'zos' == sys.platform:
ext_modules = _ext_modules(os.path.join(os.getcwd(), include_dir), library, ibm_db_lib, ibm_db_lib_runtime)
Expand Down Expand Up @@ -500,11 +500,6 @@ def print_exception( e, url):
'Operating System :: Microsoft :: Windows :: Windows 10',
'Operating System :: Unix',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand Down

0 comments on commit ec969b7

Please sign in to comment.