Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON-4320 Add Support for Python 3.13 #58

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-2019, ubuntu-latest]
os: [macos-12, windows-2019, ubuntu-latest]
name: Build CPython ${{ matrix.python-version }}-${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pypa/cibuildwheel@v2.11.2
- uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_TEST_SKIP: '*universal2:arm64'
CIBW_BUILD: "cp37-macosx_x86_64 cp38-macosx_universal2 cp37-win* cp37-manylinux_{x86_64,i686}"
CIBW_BUILD: "cp38-macosx_universal2 cp38-win* cp38-manylinux_{x86_64,i686}"
- uses: actions/upload-artifact@v3
with:
name: python_bsonjs-3.7-${{ matrix.os }}-wheel
name: python_bsonjs-3.8-${{ matrix.os }}-wheel
path: ./wheelhouse/*.whl
if-no-files-found: error
test_non_linux_wheels:
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-2019]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
os: [macos-12, windows-2019]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
name: Test CPython ${{ matrix.python-version }}-${{ matrix.os }}
steps:
- name: Setup Python
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Download a previously created wheel
uses: actions/download-artifact@v2
with:
name: python_bsonjs-3.7-${{ matrix.os }}-wheel
name: python_bsonjs-3.8-${{ matrix.os }}-wheel
- name: Test wheel
shell: bash
run: |
Expand All @@ -66,14 +66,14 @@ jobs:
matrix:
os: [ubuntu-latest]
container: ['manylinux2014_i686', 'manylinux2014_x86_64']
python-version: ['cp37-cp37m', 'cp38-cp38',
'cp39-cp39', 'cp310-cp310', 'cp311-cp311', 'cp312-cp312']
python-version: ['cp38-cp38',
'cp39-cp39', 'cp310-cp310', 'cp311-cp311', 'cp312-cp312', 'cp313-cp313']
name: Test CPython ${{ matrix.python-version }}-${{ matrix.container }}
steps:
- name: Download a previously created wheel
uses: actions/download-artifact@v2
with:
name: python_bsonjs-3.7-${{ matrix.os }}-wheel
name: python_bsonjs-3.8-${{ matrix.os }}-wheel
- name: Test wheel
run: |
docker run --rm --volume `pwd`:/python quay.io/pypa/${{ matrix.container }} /bin/bash -c "/opt/python/${{ matrix.python-version }}/bin/python -m pip install -U pip && /opt/python/${{ matrix.python-version }}/bin/python -m pip install --find-links=/python/ --no-index python_bsonjs && /opt/python/${{ matrix.python-version }}/bin/python -m pip list | grep python-bsonjs && /opt/python/${{ matrix.python-version }}/bin/python -c 'from bsonjs import dumps'"
Expand All @@ -85,7 +85,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Build SDist
run: |
python -m pip install build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-2019]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ ENV/

# .idea
.idea/**

# Local checkout of mongo-c-driver
mongo-c-driver/
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

0.5.0
`````
Version 0.5.0 updates python-bsonjs's vendored copy of libbson to 1.27.6.
For a detailed breakdown of what changed in each version of libbson see its changelog:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add:

Version 0.5.0 updates python-bsonjs's vendored copy of libbson to 1.27.6.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

https://github.com/mongodb/mongo-c-driver/blob/1.27.6/src/libbson/NEWS
http://mongoc.org/libbson/1.27.6/

This release also adds support for Python 3.13 and drops support for Python 3.7.

0.4.0
`````
Version 0.4.0 updates python-bsonjs's vendored copy of libbson to 1.24.2.
Expand Down
9 changes: 2 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
python-bsonjs
=============

.. image:: https://travis-ci.org/mongodb-labs/python-bsonjs.svg?branch=master
:alt: View build status
:target: https://travis-ci.org/mongodb-labs/python-bsonjs

:Info: See `github <http://github.com/mongodb-labs/python-bsonjs>`_ for the latest source.
:Author: Shane Harvey <shane.harvey@mongodb.com>

About
=====

A fast BSON to MongoDB Extended JSON converter for Python that uses
`libbson <http://mongoc.org/libbson/1.20.0/>`_.
`libbson <http://mongoc.org/libbson/1.27.2/>`_.

Installation
============
Expand Down Expand Up @@ -110,7 +106,7 @@ like so
Installing From Source
======================

python-bsonjs supports CPython 3.7+.
python-bsonjs supports CPython 3.8+.

Compiler
````````
Expand Down Expand Up @@ -141,4 +137,3 @@ Test
To run the test suite::

$ python -m pytest

62 changes: 20 additions & 42 deletions bsonjs/bson/bcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdio.h>

#include "bcon.h"
#include "bson-config.h"
#include <bson/bson-config.h>

/* These stack manipulation macros are used to manage append recursion in
* bcon_append_ctx_va(). They take care of some awkward dereference rules (the
Expand All @@ -31,11 +31,9 @@

#define STACK_ELE(_delta, _name) (ctx->stack[(_delta) + ctx->n]._name)

#define STACK_BSON(_delta) \
(((_delta) + ctx->n) == 0 ? bson : &STACK_ELE (_delta, bson))
#define STACK_BSON(_delta) (((_delta) + ctx->n) == 0 ? bson : &STACK_ELE (_delta, bson))

#define STACK_ITER(_delta) \
(((_delta) + ctx->n) == 0 ? &root_iter : &STACK_ELE (_delta, iter))
#define STACK_ITER(_delta) (((_delta) + ctx->n) == 0 ? &root_iter : &STACK_ELE (_delta, iter))

#define STACK_BSON_PARENT STACK_BSON (-1)
#define STACK_BSON_CHILD STACK_BSON (0)
Expand Down Expand Up @@ -205,10 +203,7 @@ _noop (void)
/* appends val to the passed bson object. Meant to be a super simple dispatch
* table */
static void
_bcon_append_single (bson_t *bson,
bcon_type_t type,
const char *key,
bcon_append_t *val)
_bcon_append_single (bson_t *bson, bcon_type_t type, const char *key, bcon_append_t *val)
{
switch ((int) type) {
case BCON_TYPE_UTF8:
Expand All @@ -218,8 +213,7 @@ _bcon_append_single (bson_t *bson,
BSON_ASSERT (bson_append_double (bson, key, -1, val->DOUBLE));
break;
case BCON_TYPE_BIN: {
BSON_ASSERT (bson_append_binary (
bson, key, -1, val->BIN.subtype, val->BIN.binary, val->BIN.length));
BSON_ASSERT (bson_append_binary (bson, key, -1, val->BIN.subtype, val->BIN.binary, val->BIN.length));
break;
}
case BCON_TYPE_UNDEFINED:
Expand All @@ -238,13 +232,11 @@ _bcon_append_single (bson_t *bson,
BSON_ASSERT (bson_append_null (bson, key, -1));
break;
case BCON_TYPE_REGEX: {
BSON_ASSERT (
bson_append_regex (bson, key, -1, val->REGEX.regex, val->REGEX.flags));
BSON_ASSERT (bson_append_regex (bson, key, -1, val->REGEX.regex, val->REGEX.flags));
break;
}
case BCON_TYPE_DBPOINTER: {
BSON_ASSERT (bson_append_dbpointer (
bson, key, -1, val->DBPOINTER.collection, val->DBPOINTER.oid));
BSON_ASSERT (bson_append_dbpointer (bson, key, -1, val->DBPOINTER.collection, val->DBPOINTER.oid));
break;
}
case BCON_TYPE_CODE:
Expand All @@ -254,15 +246,13 @@ _bcon_append_single (bson_t *bson,
BSON_ASSERT (bson_append_symbol (bson, key, -1, val->SYMBOL, -1));
break;
case BCON_TYPE_CODEWSCOPE:
BSON_ASSERT (bson_append_code_with_scope (
bson, key, -1, val->CODEWSCOPE.js, val->CODEWSCOPE.scope));
BSON_ASSERT (bson_append_code_with_scope (bson, key, -1, val->CODEWSCOPE.js, val->CODEWSCOPE.scope));
break;
case BCON_TYPE_INT32:
BSON_ASSERT (bson_append_int32 (bson, key, -1, val->INT32));
break;
case BCON_TYPE_TIMESTAMP: {
BSON_ASSERT (bson_append_timestamp (
bson, key, -1, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment));
BSON_ASSERT (bson_append_timestamp (bson, key, -1, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment));
break;
}
case BCON_TYPE_INT64:
Expand Down Expand Up @@ -315,9 +305,7 @@ _bcon_append_single (bson_t *bson,
* procedural verification (if a parameter could have multiple types).
* */
static bool
_bcon_extract_single (const bson_iter_t *iter,
bcon_type_t type,
bcon_extract_t *val)
_bcon_extract_single (const bson_iter_t *iter, bcon_type_t type, bcon_extract_t *val)
{
switch ((int) type) {
case BCON_TYPE_UTF8:
Expand All @@ -330,8 +318,7 @@ _bcon_extract_single (const bson_iter_t *iter,
break;
case BCON_TYPE_BIN:
CHECK_TYPE (BSON_TYPE_BINARY);
bson_iter_binary (
iter, val->BIN.subtype, val->BIN.length, val->BIN.binary);
bson_iter_binary (iter, val->BIN.subtype, val->BIN.length, val->BIN.binary);
break;
case BCON_TYPE_UNDEFINED:
CHECK_TYPE (BSON_TYPE_UNDEFINED);
Expand All @@ -358,8 +345,7 @@ _bcon_extract_single (const bson_iter_t *iter,
break;
case BCON_TYPE_DBPOINTER:
CHECK_TYPE (BSON_TYPE_DBPOINTER);
bson_iter_dbpointer (
iter, NULL, val->DBPOINTER.collection, val->DBPOINTER.oid);
bson_iter_dbpointer (iter, NULL, val->DBPOINTER.collection, val->DBPOINTER.oid);
break;
case BCON_TYPE_CODE:
CHECK_TYPE (BSON_TYPE_CODE);
Expand All @@ -386,8 +372,7 @@ _bcon_extract_single (const bson_iter_t *iter,
break;
case BCON_TYPE_TIMESTAMP:
CHECK_TYPE (BSON_TYPE_TIMESTAMP);
bson_iter_timestamp (
iter, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment);
bson_iter_timestamp (iter, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment);
break;
case BCON_TYPE_INT64:
CHECK_TYPE (BSON_TYPE_INT64);
Expand Down Expand Up @@ -772,8 +757,7 @@ bcon_append_ctx_va (bson_t *bson, bcon_append_ctx_t *ctx, va_list *ap)
}

if (type == BCON_TYPE_DOC_END) {
STACK_POP_DOC (
bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
STACK_POP_DOC (bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
continue;
}

Expand All @@ -797,20 +781,16 @@ bcon_append_ctx_va (bson_t *bson, bcon_append_ctx_t *ctx, va_list *ap)

break;
case BCON_TYPE_DOC_START:
STACK_PUSH_DOC (bson_append_document_begin (
STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
STACK_PUSH_DOC (bson_append_document_begin (STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
break;
case BCON_TYPE_DOC_END:
STACK_POP_DOC (
bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
STACK_POP_DOC (bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
break;
case BCON_TYPE_ARRAY_START:
STACK_PUSH_ARRAY (bson_append_array_begin (
STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
STACK_PUSH_ARRAY (bson_append_array_begin (STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
break;
case BCON_TYPE_ARRAY_END:
STACK_POP_ARRAY (
bson_append_array_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
STACK_POP_ARRAY (bson_append_array_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
break;
default:
_bcon_append_single (STACK_BSON_CHILD, type, key, &u);
Expand Down Expand Up @@ -897,17 +877,15 @@ bcon_extract_ctx_va (bson_t *bson, bcon_extract_ctx_t *ctx, va_list *ap)
return false;
}

STACK_PUSH_DOC (
bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
STACK_PUSH_DOC (bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
break;
case BCON_TYPE_ARRAY_START:

if (bson_iter_type (&current_iter) != BSON_TYPE_ARRAY) {
return false;
}

STACK_PUSH_ARRAY (
bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
STACK_PUSH_ARRAY (bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
break;
default:

Expand Down
Loading
Loading