Skip to content

Commit 996e651

Browse files
authored
PYTHON-4320 Add Support for Python 3.13 (#58)
* PYTHON-4320 Add Support for Python 3.13 * fix compliation * address review * add new file
1 parent fc5a56a commit 996e651

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2280
-3116
lines changed

.github/workflows/release-python.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ jobs:
1919
runs-on: ${{ matrix.os }}
2020
strategy:
2121
matrix:
22-
os: [macos-latest, windows-2019, ubuntu-latest]
22+
os: [macos-12, windows-2019, ubuntu-latest]
2323
name: Build CPython ${{ matrix.python-version }}-${{ matrix.os }}
2424
steps:
2525
- uses: actions/checkout@v4
26-
- uses: pypa/cibuildwheel@v2.11.2
26+
- uses: pypa/cibuildwheel@v2.20.0
2727
env:
2828
CIBW_ARCHS_MACOS: x86_64 universal2
2929
CIBW_TEST_SKIP: '*universal2:arm64'
30-
CIBW_BUILD: "cp37-macosx_x86_64 cp38-macosx_universal2 cp37-win* cp37-manylinux_{x86_64,i686}"
30+
CIBW_BUILD: "cp38-macosx_universal2 cp38-win* cp38-manylinux_{x86_64,i686}"
3131
- uses: actions/upload-artifact@v3
3232
with:
33-
name: python_bsonjs-3.7-${{ matrix.os }}-wheel
33+
name: python_bsonjs-3.8-${{ matrix.os }}-wheel
3434
path: ./wheelhouse/*.whl
3535
if-no-files-found: error
3636
test_non_linux_wheels:
3737
needs: build_wheels
3838
runs-on: ${{ matrix.os }}
3939
strategy:
4040
matrix:
41-
os: [macos-latest, windows-2019]
42-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
41+
os: [macos-12, windows-2019]
42+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
4343
name: Test CPython ${{ matrix.python-version }}-${{ matrix.os }}
4444
steps:
4545
- name: Setup Python
@@ -50,7 +50,7 @@ jobs:
5050
- name: Download a previously created wheel
5151
uses: actions/download-artifact@v2
5252
with:
53-
name: python_bsonjs-3.7-${{ matrix.os }}-wheel
53+
name: python_bsonjs-3.8-${{ matrix.os }}-wheel
5454
- name: Test wheel
5555
shell: bash
5656
run: |
@@ -66,14 +66,14 @@ jobs:
6666
matrix:
6767
os: [ubuntu-latest]
6868
container: ['manylinux2014_i686', 'manylinux2014_x86_64']
69-
python-version: ['cp37-cp37m', 'cp38-cp38',
70-
'cp39-cp39', 'cp310-cp310', 'cp311-cp311', 'cp312-cp312']
69+
python-version: ['cp38-cp38',
70+
'cp39-cp39', 'cp310-cp310', 'cp311-cp311', 'cp312-cp312', 'cp313-cp313']
7171
name: Test CPython ${{ matrix.python-version }}-${{ matrix.container }}
7272
steps:
7373
- name: Download a previously created wheel
7474
uses: actions/download-artifact@v2
7575
with:
76-
name: python_bsonjs-3.7-${{ matrix.os }}-wheel
76+
name: python_bsonjs-3.8-${{ matrix.os }}-wheel
7777
- name: Test wheel
7878
run: |
7979
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'"
@@ -85,7 +85,7 @@ jobs:
8585
- name: Setup Python
8686
uses: actions/setup-python@v4
8787
with:
88-
python-version: 3.7
88+
python-version: 3.8
8989
- name: Build SDist
9090
run: |
9191
python -m pip install build

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [macos-latest, ubuntu-latest, windows-2019]
20-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
20+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2121

2222
steps:
2323
- uses: actions/checkout@v2

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ ENV/
130130

131131
# .idea
132132
.idea/**
133+
134+
# Local checkout of mongo-c-driver
135+
mongo-c-driver/

CHANGELOG.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
0.5.0
5+
`````
6+
Version 0.5.0 updates python-bsonjs's vendored copy of libbson to 1.27.6.
7+
For a detailed breakdown of what changed in each version of libbson see its changelog:
8+
https://github.com/mongodb/mongo-c-driver/blob/1.27.6/src/libbson/NEWS
9+
http://mongoc.org/libbson/1.27.6/
10+
11+
This release also adds support for Python 3.13 and drops support for Python 3.7.
12+
413
0.4.0
514
`````
615
Version 0.4.0 updates python-bsonjs's vendored copy of libbson to 1.24.2.

README.rst

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22
python-bsonjs
33
=============
44

5-
.. image:: https://travis-ci.org/mongodb-labs/python-bsonjs.svg?branch=master
6-
:alt: View build status
7-
:target: https://travis-ci.org/mongodb-labs/python-bsonjs
8-
95
:Info: See `github <http://github.com/mongodb-labs/python-bsonjs>`_ for the latest source.
106
:Author: Shane Harvey <shane.harvey@mongodb.com>
117

128
About
139
=====
1410

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

1814
Installation
1915
============
@@ -110,7 +106,7 @@ like so
110106
Installing From Source
111107
======================
112108

113-
python-bsonjs supports CPython 3.7+.
109+
python-bsonjs supports CPython 3.8+.
114110

115111
Compiler
116112
````````
@@ -141,4 +137,3 @@ Test
141137
To run the test suite::
142138

143139
$ python -m pytest
144-

bsonjs/bson/bcon.c

+20-42
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <stdio.h>
2323

2424
#include "bcon.h"
25-
#include "bson-config.h"
25+
#include <bson/bson-config.h>
2626

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

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

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

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

4038
#define STACK_BSON_PARENT STACK_BSON (-1)
4139
#define STACK_BSON_CHILD STACK_BSON (0)
@@ -205,10 +203,7 @@ _noop (void)
205203
/* appends val to the passed bson object. Meant to be a super simple dispatch
206204
* table */
207205
static void
208-
_bcon_append_single (bson_t *bson,
209-
bcon_type_t type,
210-
const char *key,
211-
bcon_append_t *val)
206+
_bcon_append_single (bson_t *bson, bcon_type_t type, const char *key, bcon_append_t *val)
212207
{
213208
switch ((int) type) {
214209
case BCON_TYPE_UTF8:
@@ -218,8 +213,7 @@ _bcon_append_single (bson_t *bson,
218213
BSON_ASSERT (bson_append_double (bson, key, -1, val->DOUBLE));
219214
break;
220215
case BCON_TYPE_BIN: {
221-
BSON_ASSERT (bson_append_binary (
222-
bson, key, -1, val->BIN.subtype, val->BIN.binary, val->BIN.length));
216+
BSON_ASSERT (bson_append_binary (bson, key, -1, val->BIN.subtype, val->BIN.binary, val->BIN.length));
223217
break;
224218
}
225219
case BCON_TYPE_UNDEFINED:
@@ -238,13 +232,11 @@ _bcon_append_single (bson_t *bson,
238232
BSON_ASSERT (bson_append_null (bson, key, -1));
239233
break;
240234
case BCON_TYPE_REGEX: {
241-
BSON_ASSERT (
242-
bson_append_regex (bson, key, -1, val->REGEX.regex, val->REGEX.flags));
235+
BSON_ASSERT (bson_append_regex (bson, key, -1, val->REGEX.regex, val->REGEX.flags));
243236
break;
244237
}
245238
case BCON_TYPE_DBPOINTER: {
246-
BSON_ASSERT (bson_append_dbpointer (
247-
bson, key, -1, val->DBPOINTER.collection, val->DBPOINTER.oid));
239+
BSON_ASSERT (bson_append_dbpointer (bson, key, -1, val->DBPOINTER.collection, val->DBPOINTER.oid));
248240
break;
249241
}
250242
case BCON_TYPE_CODE:
@@ -254,15 +246,13 @@ _bcon_append_single (bson_t *bson,
254246
BSON_ASSERT (bson_append_symbol (bson, key, -1, val->SYMBOL, -1));
255247
break;
256248
case BCON_TYPE_CODEWSCOPE:
257-
BSON_ASSERT (bson_append_code_with_scope (
258-
bson, key, -1, val->CODEWSCOPE.js, val->CODEWSCOPE.scope));
249+
BSON_ASSERT (bson_append_code_with_scope (bson, key, -1, val->CODEWSCOPE.js, val->CODEWSCOPE.scope));
259250
break;
260251
case BCON_TYPE_INT32:
261252
BSON_ASSERT (bson_append_int32 (bson, key, -1, val->INT32));
262253
break;
263254
case BCON_TYPE_TIMESTAMP: {
264-
BSON_ASSERT (bson_append_timestamp (
265-
bson, key, -1, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment));
255+
BSON_ASSERT (bson_append_timestamp (bson, key, -1, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment));
266256
break;
267257
}
268258
case BCON_TYPE_INT64:
@@ -315,9 +305,7 @@ _bcon_append_single (bson_t *bson,
315305
* procedural verification (if a parameter could have multiple types).
316306
* */
317307
static bool
318-
_bcon_extract_single (const bson_iter_t *iter,
319-
bcon_type_t type,
320-
bcon_extract_t *val)
308+
_bcon_extract_single (const bson_iter_t *iter, bcon_type_t type, bcon_extract_t *val)
321309
{
322310
switch ((int) type) {
323311
case BCON_TYPE_UTF8:
@@ -330,8 +318,7 @@ _bcon_extract_single (const bson_iter_t *iter,
330318
break;
331319
case BCON_TYPE_BIN:
332320
CHECK_TYPE (BSON_TYPE_BINARY);
333-
bson_iter_binary (
334-
iter, val->BIN.subtype, val->BIN.length, val->BIN.binary);
321+
bson_iter_binary (iter, val->BIN.subtype, val->BIN.length, val->BIN.binary);
335322
break;
336323
case BCON_TYPE_UNDEFINED:
337324
CHECK_TYPE (BSON_TYPE_UNDEFINED);
@@ -358,8 +345,7 @@ _bcon_extract_single (const bson_iter_t *iter,
358345
break;
359346
case BCON_TYPE_DBPOINTER:
360347
CHECK_TYPE (BSON_TYPE_DBPOINTER);
361-
bson_iter_dbpointer (
362-
iter, NULL, val->DBPOINTER.collection, val->DBPOINTER.oid);
348+
bson_iter_dbpointer (iter, NULL, val->DBPOINTER.collection, val->DBPOINTER.oid);
363349
break;
364350
case BCON_TYPE_CODE:
365351
CHECK_TYPE (BSON_TYPE_CODE);
@@ -386,8 +372,7 @@ _bcon_extract_single (const bson_iter_t *iter,
386372
break;
387373
case BCON_TYPE_TIMESTAMP:
388374
CHECK_TYPE (BSON_TYPE_TIMESTAMP);
389-
bson_iter_timestamp (
390-
iter, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment);
375+
bson_iter_timestamp (iter, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment);
391376
break;
392377
case BCON_TYPE_INT64:
393378
CHECK_TYPE (BSON_TYPE_INT64);
@@ -772,8 +757,7 @@ bcon_append_ctx_va (bson_t *bson, bcon_append_ctx_t *ctx, va_list *ap)
772757
}
773758

774759
if (type == BCON_TYPE_DOC_END) {
775-
STACK_POP_DOC (
776-
bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
760+
STACK_POP_DOC (bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
777761
continue;
778762
}
779763

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

798782
break;
799783
case BCON_TYPE_DOC_START:
800-
STACK_PUSH_DOC (bson_append_document_begin (
801-
STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
784+
STACK_PUSH_DOC (bson_append_document_begin (STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
802785
break;
803786
case BCON_TYPE_DOC_END:
804-
STACK_POP_DOC (
805-
bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
787+
STACK_POP_DOC (bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
806788
break;
807789
case BCON_TYPE_ARRAY_START:
808-
STACK_PUSH_ARRAY (bson_append_array_begin (
809-
STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
790+
STACK_PUSH_ARRAY (bson_append_array_begin (STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD));
810791
break;
811792
case BCON_TYPE_ARRAY_END:
812-
STACK_POP_ARRAY (
813-
bson_append_array_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
793+
STACK_POP_ARRAY (bson_append_array_end (STACK_BSON_PARENT, STACK_BSON_CHILD));
814794
break;
815795
default:
816796
_bcon_append_single (STACK_BSON_CHILD, type, key, &u);
@@ -897,17 +877,15 @@ bcon_extract_ctx_va (bson_t *bson, bcon_extract_ctx_t *ctx, va_list *ap)
897877
return false;
898878
}
899879

900-
STACK_PUSH_DOC (
901-
bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
880+
STACK_PUSH_DOC (bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
902881
break;
903882
case BCON_TYPE_ARRAY_START:
904883

905884
if (bson_iter_type (&current_iter) != BSON_TYPE_ARRAY) {
906885
return false;
907886
}
908887

909-
STACK_PUSH_ARRAY (
910-
bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
888+
STACK_PUSH_ARRAY (bson_iter_recurse (&current_iter, STACK_ITER_CHILD));
911889
break;
912890
default:
913891

0 commit comments

Comments
 (0)