Skip to content

Commit

Permalink
Update liblmdb, add building for 3.12 (#361)
Browse files Browse the repository at this point in the history
* Pull lmdb 0.9.31 from upstream.

* Get Python 3.12 building in CI.

* Remove 2.7 builds as Github Actions removed support

* Add `import setuptools` to CI since not in 3.12 venv anymore

* Update supported versions, fix #358

* Update py-lmdb patch for lmdb 0.9.31

* Remove 2.7 cruft

* Drop 3.7 building on MacOS since not easily supported in CI

* Update changelog

* Reduce tests a bit
  • Loading branch information
jnwatson authored Jun 26, 2024
1 parent 57c6920 commit 4ab5cb2
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 235 deletions.
73 changes: 21 additions & 52 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,22 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', '3.11', pypy-2.7, pypy-3.9]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12', pypy-3.10]
impl: [cpython, cffi]
purity: [pure, with-pylmdb-mods]

exclude:
- python-version: pypy-2.7
# Pypy doesn't work with cpython
- python-version: pypy-3.10
impl: cpython
- python-version: pypy-3.9
impl: cpython
# CFFI has trouble building on Windows for 3.5 "self.find_available_vc_vers()[-1]" fails
- python-version: 3.5
os: windows-latest
# Microsoft removed VC 9.0 installer so Python 2.7 modules can no longer be built on Windows
- python-version: 2.7
os: windows-latest
# Doesn't seem to exist on github MacOS
- python-version: pypy-3.9
# macos latest is now arm64 and 3.7 doesn't have arm64 build
- python-version: 3.7
os: macos-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set env vars Windows
Expand Down Expand Up @@ -79,7 +72,7 @@ jobs:
cffi=$LMDB_FORCE_CFFI pure=$LMDB_PURE system=$LMDB_FORCE_SYSTEM"
echo "Windows: Envs are cpython=$Env:LMDB_FORCE_CPYTHON
cffi=$Env:LMDB_FORCE_CFFI pure=$Env:LMDB_PURE system=$Env:LMDB_FORCE_SYSTEM"
python -m pip install wheel
python -m pip install setuptools wheel
# Install this separately since sometimes Github Actions can't find it
python -m pip install cffi
python -m pip install flake8 pytest patch-ng
Expand All @@ -94,7 +87,9 @@ jobs:
#
- name: Test with pytest
# Limit the test cycle a little
if: matrix.python-version != '3.6' && matrix.python-version != '3.8'
if: >-
matrix.python-version != '3.7' && matrix.python-version != '3.9' &&
matrix.python-version != '3.11'
run: |
echo "Envs are cpython=$LMDB_FORCE_CPYTHON cffi=$LMDB_FORCE_CFFI
pure=$LMDB_PURE system=$LMDB_FORCE_SYSTEM"
Expand Down Expand Up @@ -141,7 +136,7 @@ jobs:
uses: RalfG/[email protected]
with:
python-versions: >-
cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311
cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312
build-requirements: 'patch-ng'

- name: What do we have
Expand All @@ -165,7 +160,7 @@ jobs:
matrix:
impl: [cpython, cffi]
purity: [pure, with-pylmdb-mods]
PYTHON: ["cp36-cp36m", "cp37-cp37m" , "cp38-cp38" , "cp39-cp39", "cp310-cp310", "cp311-cp311"]
PYTHON: ["cp37-cp37m" , "cp38-cp38" , "cp39-cp39", "cp310-cp310", "cp311-cp311"]
steps:
- uses: actions/checkout@v2
- run: |
Expand All @@ -179,7 +174,7 @@ jobs:
python --version;
/opt/python/${{ matrix.PYTHON }}/bin/python -m venv .venv;
yum install -y libffi-devel;
.venv/bin/pip install -U pip wheel cffi six;
.venv/bin/pip install -U pip setuptools wheel cffi six;
if \[ ${{ matrix.impl }} == cpython \] ; then
echo LMDB_FORCE_CPYTHON=1
else
Expand All @@ -194,7 +189,7 @@ jobs:
cffi=$LMDB_FORCE_CFFI pure=$LMDB_PURE system=$LMDB_FORCE_SYSTEM\";
echo \"Windows: Envs are cpython=$Env:LMDB_FORCE_CPYTHON
cffi=$Env:LMDB_FORCE_CFFI pure=$Env:LMDB_PURE system=$Env:LMDB_FORCE_SYSTEM\";
.venv/bin/pip install flake8 pytest patch-ng;
.venv/bin/pip install setuptools flake8 pytest patch-ng;
/opt/python/${{ matrix.PYTHON }}/bin/python setup.py develop bdist_wheel;
ls dist;
/opt/python/${{ matrix.PYTHON }}/bin/python -m pip install pytest;
Expand All @@ -212,29 +207,29 @@ jobs:

- uses: actions/upload-artifact@v2
if: >-
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.purity == 'with-pylmdb-mods' && matrix.impl == 'cpython'
with:
path: vers.txt
name: vers.txt
- uses: actions/upload-artifact@v2
if: >-
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.purity == 'with-pylmdb-mods' && matrix.impl == 'cpython'
with:
path: dist/lmdb*.tar.gz
name: source
- uses: RalfG/[email protected]_aarch64
if: >-
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.purity == 'with-pylmdb-mods' && matrix.impl == 'cpython'
with:
python-versions: >-
cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311
cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312
build-requirements: 'patch-ng'
- uses: actions/upload-artifact@v2
if: >-
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.PYTHON == 'cp310-cp310' && runner.os == 'Linux' &&
matrix.purity == 'with-pylmdb-mods' && matrix.impl == 'cpython'
with:
path: dist/lmdb*manylinux*.whl
Expand All @@ -248,41 +243,15 @@ jobs:
# We publish a subset of the targets we test
matrix:
os: [macos-latest, windows-latest]
python-version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', pypy-2.7, pypy-3.9]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', pypy-3.10]
impl: [cpython, cffi]
purity: [with-pylmdb-mods]

exclude:
- python-version: 'pypy-2.7'
impl: cpython
- python-version: 'pypy-3.9'
- python-version: 'pypy-3.10'
impl: cpython
- python-version: '2.7'
impl: cffi
- python-version: '3.5'
impl: cffi
- python-version: '3.6'
impl: cffi
- python-version: '3.7'
impl: cffi
- python-version: '3.8'
impl: cffi
- python-version: '3.9'
impl: cffi
- python-version: '3.10'
impl: cffi
- python-version: '3.11'
impl: cffi
# CFFI has trouble building on Windows for 3.5 "self.find_available_vc_vers()[-1]" fails
- python-version: 3.5
os: windows-latest
# Microsoft removed VC 9.0 installer so Python 2.7 modules can no longer be built on Windows
- python-version: '2.7'
os: windows-latest
# Doesn't seem to exist on github MacOS
- python-version: pypy-3.9
os: macos-latest

include:
# Ubuntu artifacts apply to all python versions
- os: ubuntu-20.04
Expand Down
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2024-06-25 1.5.0
* Add Python 3.12 binaries.

* Update bundled LMDB to 0.9.31.

* Remove Python 2.7 support.

2022-04-04 v1.4.1
* Update CI to build manylinux binaries.

Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ See [the documentation](https://lmdb.readthedocs.io) for more information.

# Python Version Support Statement

This project has been around for a while. Previously, it supported all the way back to before 2.5. Currently py-lmdb
supports Python 2.7, Python >= 3.5, and pypy.

Python 2.7 is now end-of-life. If you are still using Python 2.7, you should strongly considering porting to Python
3.

That said, this project will continue to support running on Python 2.7 until Github Actions remove support for it.
This project has been around for a while. Previously, it supported all the way back to before 2.5. Currently, py-lmdb
supports Python >= 3.5 and pypy.

The last version of py-lmdb that supported Python 2.7 was 1.4.1.
34 changes: 6 additions & 28 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ lmdb
This is a universal Python binding for the `LMDB 'Lightning' Database
<http://lmdb.tech/>`_. Two variants are provided and automatically selected
during install: a `CFFI <https://cffi.readthedocs.io/en/release-0.5/>`_ variant
that supports `PyPy <http://www.pypy.org/>`_ and all versions of CPython >=2.7,
and a C extension that supports CPython >=2.7 and >=3.4. Both variants
provide the same interface.
that supports `PyPy <http://www.pypy.org/>`_ and all versions of CPython >=3.5,
and a C extension that supports >= 3.5. Both variants provide the same interface.

LMDB is a tiny database with some excellent properties:

Expand Down Expand Up @@ -41,21 +40,12 @@ to be installed via pip and easy_install without the need for a compiler to be
present. The binary releases statically link against the bundled version of
LMDB.

Initially 32-bit and 64-bit binaries are provided for Python 2.7; in future
binaries will be published for all supported versions of Python.

To install, use a command like:

::

C:\Python27\python -mpip install lmdb

Or:

::

C:\Python27\python -measy_install lmdb


Installation: UNIX
++++++++++++++++++
Expand All @@ -78,14 +68,12 @@ depend on the CPython development headers. On Debian/Ubuntu:

apt-get install libffi-dev python-dev build-essential

To install the C extension, ensure a C compiler and `pip` or `easy_install` are
To install the C extension, ensure a C compiler and `pip` are
available and type:

::

pip install lmdb
# or
easy_install lmdb

The CFFI variant may be used on CPython by setting the ``LMDB_FORCE_CFFI``
environment variable before installation, or before module import with an
Expand Down Expand Up @@ -194,21 +182,11 @@ written the dirty pages to disk.
Bytestrings
+++++++++++

This documentation uses `bytestring` to mean either the Python<=2.7
:py:func:`str` type, or the Python>=3.0 :py:func:`bytes` type, depending on the
Python version in use.

Due to the design of Python 2.x, LMDB will happily accept Unicode instances
where :py:func:`str` instances are expected, so long as they contain only ASCII
characters, in which case they are implicitly encoded to ASCII. You should not
rely on this behaviour! It results in brittle programs that often break the
moment they are deployed in production. Always explicitly encode and decode any
Unicode values before passing them to LMDB.
This documentation uses `bytestring` to mean the Python>=3.0 :py:func:`bytes`
type.

This documentation uses :py:func:`bytes` in examples. In Python 3.x this is a
distinct type, whereas in Python 2.7 it is simply an alias for
:py:func:`str`.

distinct type.

Buffers
+++++++
Expand Down
4 changes: 2 additions & 2 deletions lib/lmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ typedef int mdb_filehandle_t;
/** Library minor version */
#define MDB_VERSION_MINOR 9
/** Library patch version */
#define MDB_VERSION_PATCH 29
#define MDB_VERSION_PATCH 31

/** Combine args a,b,c into a single integer for easy version comparisons */
#define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
Expand All @@ -210,7 +210,7 @@ typedef int mdb_filehandle_t;
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)

/** The release date of this library version */
#define MDB_VERSION_DATE "March 16, 2021"
#define MDB_VERSION_DATE "July 10, 2023"

/** A stringifier for the version info */
#define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")"
Expand Down
Loading

0 comments on commit 4ab5cb2

Please sign in to comment.