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 2 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
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

0.5.0
`````
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

2 changes: 1 addition & 1 deletion bsonjs/bson/bson-atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
int32_t
bson_atomic_int_add (volatile int32_t *p, int32_t n)
{
return n + bson_atomic_int32_fetch_add ((DECL_ATOMIC_INTEGRAL_INT32 *) p, n, bson_memory_order_seq_cst);
return n + bson_atomic_int32_fetch_add (p, n, bson_memory_order_seq_cst);
}

int64_t
Expand Down
4 changes: 0 additions & 4 deletions bsonjs/bson/bson-atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ DECL_ATOMIC_INTEGRAL (int, int, )
#endif
#endif

#ifndef DECL_ATOMIC_INTEGRAL_INT32
#define DECL_ATOMIC_INTEGRAL_INT32 int32_t
#endif

BSON_EXPORT (int64_t)
_bson_emul_atomic_int64_fetch_add (int64_t volatile *val,
int64_t v,
Expand Down
14 changes: 12 additions & 2 deletions bsonjs/bson/bson-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,18 @@ bson_get_monotonic_time (void)
clock_gettime (CLOCK_MONOTONIC, &ts);
return (((int64_t) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000));
#elif defined(__APPLE__)
const uint64_t nsec = clock_gettime_nsec_np (CLOCK_UPTIME_RAW);
return (int64_t) (nsec / 1000u);
static mach_timebase_info_data_t info = {0};
static double ratio = 0.0;

if (!info.denom) {
/* the value from mach_absolute_time () * info.numer / info.denom
* is in nano seconds. So we have to divid by 1000.0 to get micro
* seconds*/
mach_timebase_info (&info);
ratio = (double) info.numer / (double) info.denom / 1000.0;
}

return mach_absolute_time () * ratio;
#elif defined(_WIN32)
/* Despite it's name, this is in milliseconds! */
int64_t ticks = GetTickCount64 ();
Expand Down
132 changes: 130 additions & 2 deletions bsonjs/bson/bson-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,134 @@ typedef SSIZE_T ssize_t;
* all its bits to 1. */
#define BSON_NUMERIC_LIMITS_MAX_UNSIGNED(T) ((T) (~((T) 0)))

/* Define numeric limit constants if not already available for C90
* compatibility. These can be removed once C99 is declared the minimum
* supported C standard. */
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L

#ifndef SCHAR_MAX
#define SCHAR_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (signed char)
#endif

#ifndef SHRT_MAX
#define SHRT_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (short)
#endif

#ifndef INT_MAX
#define INT_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int)
#endif

#ifndef LONG_MAX
#define LONG_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (long)
#endif

#ifndef LLONG_MAX
#define LLONG_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (long long)
#endif

#ifndef UCHAR_MAX
#define UCHAR_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned char)
#endif

#ifndef USHRT_MAX
#define USHRT_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned short)
#endif

#ifndef UINT_MAX
#define UINT_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned int)
#endif

#ifndef ULONG_MAX
#define ULONG_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned long)
#endif

#ifndef ULLONG_MAX
#define ULLONG_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned long long)
#endif

#ifndef INT8_MAX
#define INT8_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int8_t)
#endif

#ifndef INT16_MAX
#define INT16_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int16_t)
#endif

#ifndef INT32_MAX
#define INT32_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int32_t)
#endif

#ifndef INT64_MAX
#define INT64_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int64_t)
#endif

#ifndef UINT8_MAX
#define UINT8_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint8_t)
#endif

#ifndef UINT16_MAX
#define UINT16_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint16_t)
#endif

#ifndef UINT32_MAX
#define UINT32_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint32_t)
#endif

#ifndef UINT64_MAX
#define UINT64_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint64_t)
#endif

#ifndef SIZE_MAX
#define SIZE_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (size_t)
#endif

#ifndef PTRDIFF_MAX
#define PTRDIFF_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ptrdiff_t)
#endif

#ifndef SCHAR_MIN
#define SCHAR_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (signed char, SCHAR_MAX)
#endif

#ifndef SHRT_MIN
#define SHRT_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (short, SHRT_MAX)
#endif

#ifndef INT_MIN
#define INT_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int, INT_MAX)
#endif

#ifndef LONG_MIN
#define LONG_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (long, LONG_MAX)
#endif

#ifndef LLONG_MIN
#define LLONG_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (long long, LLONG_MAX)
#endif

#ifndef INT8_MIN
#define INT8_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int8_t, INT8_MAX)
#endif

#ifndef INT16_MIN
#define INT16_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int16_t, INT16_MAX)
#endif

#ifndef INT32_MIN
#define INT32_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int32_t, INT32_MAX)
#endif

#ifndef INT64_MIN
#define INT64_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int64_t, INT64_MAX)
#endif

#ifndef PTRDIFF_MIN
#define PTRDIFF_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (ptrdiff_t, PTRDIFF_MAX)
#endif

#endif /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */


#ifndef SSIZE_MAX
#define SSIZE_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ssize_t)
#endif
Expand Down Expand Up @@ -175,9 +303,9 @@ typedef signed char bool;
#define bson_sync_synchronize() __sync_synchronize ()
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \
defined(__i686__) || defined(__x86_64__)
#define bson_sync_synchronize() asm volatile ("mfence" ::: "memory")
#define bson_sync_synchronize() asm volatile("mfence" ::: "memory")
#else
#define bson_sync_synchronize() asm volatile ("sync" ::: "memory")
#define bson_sync_synchronize() asm volatile("sync" ::: "memory")
#endif
#elif defined(_MSC_VER)
#define bson_sync_synchronize() MemoryBarrier ()
Expand Down
2 changes: 1 addition & 1 deletion bsonjs/bson/bson-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _bson_context_set_oid_seq32 (bson_context_t *context, /* IN */
bson_oid_t *oid) /* OUT */
{
uint32_t seq = (uint32_t) bson_atomic_int32_fetch_add (
(DECL_ATOMIC_INTEGRAL_INT32 *) &context->seq32, 1, bson_memory_order_seq_cst);
(int32_t *) &context->seq32, 1, bson_memory_order_seq_cst);
seq = BSON_UINT32_TO_BE (seq);
memcpy (&oid->bytes[BSON_OID_SEQ32_OFFSET],
((uint8_t *) &seq) + 1,
Expand Down
Loading
Loading