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 3.11 Abi3 wheels #479

Merged
merged 30 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cc4f184
add wheels for python 3.12 and update ci
waahm7 May 22, 2023
62bbc38
fix version
waahm7 Jun 7, 2023
c0c261f
fix wrap_socket
waahm7 Jun 7, 2023
db0ed31
update api for stable 311 api
waahm7 Jun 8, 2023
f4511ff
remove 312 wheel
waahm7 Jun 8, 2023
5e65e02
lint fix
waahm7 Jun 8, 2023
66bd959
fix mem leaks
waahm7 Jun 8, 2023
6042562
update builder
waahm7 Jun 8, 2023
70a039b
revert ubuntu
waahm7 Jun 8, 2023
3785f8f
latest submodule
waahm7 Jun 8, 2023
3796a83
Better DecRef
waahm7 Jun 9, 2023
2c81423
Merge branch 'main' into python-312
waahm7 Jun 12, 2023
232e556
lint fix
waahm7 Jun 12, 2023
6998ab6
Adds steal reference comment
waahm7 Jun 12, 2023
b87e909
add comments
waahm7 Jun 12, 2023
1ca818e
fix append function
waahm7 Jun 12, 2023
1260521
lint fix
waahm7 Jun 12, 2023
b4cd04b
Update source/http_headers.c
waahm7 Jun 12, 2023
5540a0d
Update source/mqtt5_client.c
waahm7 Jun 12, 2023
0e85cd6
Update source/mqtt5_client.c
waahm7 Jun 12, 2023
884289e
Update source/mqtt_client_connection.c
waahm7 Jun 12, 2023
61270a6
Update source/mqtt_client_connection.c
waahm7 Jun 12, 2023
bf8e02a
Update source/mqtt_client_connection.c
waahm7 Jun 12, 2023
b59045d
Update source/mqtt_client_connection.c
waahm7 Jun 12, 2023
4015a94
Update source/mqtt5_client.c
waahm7 Jun 12, 2023
8ff4f03
Update source/mqtt5_client.c
waahm7 Jun 12, 2023
2550900
PR feedback
waahm7 Jun 12, 2023
ad41140
update builder
waahm7 Jun 12, 2023
b9e356b
update variable name
waahm7 Jun 12, 2023
19df8c3
MuslLinux Wheels (#480)
waahm7 Jun 14, 2023
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
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
- cp39-cp39
- cp310-cp310
- cp311-cp311
- cp312-cp312
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
steps:
# Only aarch64 needs this, but it doesn't hurt anything
- name: Install qemu/docker
Expand Down Expand Up @@ -82,7 +83,7 @@ jobs:


linux-compat:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-22.04 # latest
strategy:
matrix:
image:
Expand All @@ -99,7 +100,7 @@ jobs:


linux-compiler-compat:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-22.04 # latest
strategy:
matrix:
compiler:
Expand Down Expand Up @@ -156,7 +157,7 @@ jobs:


osx:
runs-on: macos-11 # latest
runs-on: macos-13 # latest
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
Expand Down Expand Up @@ -211,7 +212,7 @@ jobs:

# check that tests requiring custom env-vars or AWS credentials are simply skipped
tests-ok-without-env-vars:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-22.04 # latest
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -228,7 +229,7 @@ jobs:
python3 -m unittest discover --failfast --verbose

package-source:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-22.04 # latest
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -242,7 +243,7 @@ jobs:

# check that docs can still build
check-docs:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-22.04 # latest
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -254,7 +255,7 @@ jobs:
./scripts/make-docs.py

check-submodules:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-22.04 # latest
steps:
- name: Checkout Source
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion crt/aws-c-s3
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 9b7b1f to b9c4d6
29 changes: 26 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
import subprocess
import sys
import sysconfig
from wheel.bdist_wheel import bdist_wheel


def is_64bit():
return sys.maxsize > 2**32
return sys.maxsize > 2 ** 32


def is_32bit():
Expand Down Expand Up @@ -152,7 +153,6 @@ def __init__(self, name, extra_cmake_args=[], libname=None):
AWS_LIBS.append(AwsLib('aws-c-mqtt'))
AWS_LIBS.append(AwsLib('aws-c-s3'))


PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))

VERSION_RE = re.compile(r""".*__version__ = ["'](.*?)['"]""", re.S)
Expand Down Expand Up @@ -283,6 +283,16 @@ def run(self):
super().run()


class bdist_wheel_abi3(bdist_wheel):
def get_tag(self):
python, abi, plat = super().get_tag()
if python.startswith("cp") and sys.version_info >= (3, 11):
# on CPython, our wheels are abi3 and compatible back to 3.11
return "cp311", "abi3", plat

return python, abi, plat
graebm marked this conversation as resolved.
Show resolved Hide resolved


def awscrt_ext():
# fetch the CFLAGS/LDFLAGS from env
extra_compile_args = os.environ.get('CFLAGS', '').split()
Expand Down Expand Up @@ -350,6 +360,19 @@ def awscrt_ext():
if not is_macos_universal2():
extra_link_args += ['-Wl,-fatal_warnings']

if sys.version_info >= (3, 11):
return setuptools.Extension(
'_awscrt',
language='c',
libraries=libraries,
sources=glob.glob('source/*.c'),
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
extra_objects=extra_objects,
define_macros=[('Py_LIMITED_API', '0x030B0000')],
py_limited_api=True,
)
waahm7 marked this conversation as resolved.
Show resolved Hide resolved

return setuptools.Extension(
'_awscrt',
language='c',
Expand Down Expand Up @@ -392,6 +415,6 @@ def _load_version():
],
python_requires='>=3.7',
ext_modules=[awscrt_ext()],
cmdclass={'build_ext': awscrt_build_ext},
cmdclass={'build_ext': awscrt_build_ext, "bdist_wheel": bdist_wheel_abi3},
test_suite='test',
)
10 changes: 6 additions & 4 deletions source/auth_credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ PyObject *aws_py_credentials_provider_new_chain(PyObject *self, PyObject *args)
if (!providers_pyseq) {
goto done;
}
size_t provider_count = (size_t)PySequence_Fast_GET_SIZE(providers_pyseq);
size_t provider_count = (size_t)PySequence_Size(providers_pyseq);
if (provider_count == 0) {
PyErr_SetString(PyExc_ValueError, "Must supply at least one AwsCredentialsProvider.");
goto done;
Expand All @@ -526,11 +526,12 @@ PyObject *aws_py_credentials_provider_new_chain(PyObject *self, PyObject *args)
}

for (size_t i = 0; i < provider_count; ++i) {
PyObject *provider_py = PySequence_Fast_GET_ITEM(providers_pyseq, i);
PyObject *provider_py = PySequence_GetItem(providers_pyseq, i);
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
providers_carray[i] = aws_py_get_credentials_provider(provider_py);
if (!providers_carray[i]) {
goto done;
}
Py_XDECREF(provider_py);
graebm marked this conversation as resolved.
Show resolved Hide resolved
}

struct credentials_provider_binding *binding;
Expand Down Expand Up @@ -724,7 +725,7 @@ PyObject *aws_py_credentials_provider_new_cognito(PyObject *self, PyObject *args
goto done;
}

logins_count = (size_t)PySequence_Fast_GET_SIZE(logins_pyseq);
logins_count = (size_t)PySequence_Size(logins_pyseq);
if (logins_count > 0) {

logins_carray =
Expand All @@ -735,7 +736,7 @@ PyObject *aws_py_credentials_provider_new_cognito(PyObject *self, PyObject *args
}

for (size_t i = 0; i < logins_count; ++i) {
PyObject *login_tuple_py = PySequence_Fast_GET_ITEM(logins_pyseq, i);
PyObject *login_tuple_py = PySequence_GetItem(logins_pyseq, i);
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
struct aws_cognito_identity_provider_token_pair *login_entry = &logins_carray[i];
AWS_ZERO_STRUCT(*login_entry);

Expand All @@ -752,6 +753,7 @@ PyObject *aws_py_credentials_provider_new_cognito(PyObject *self, PyObject *args
i);
goto done;
}
Py_XDECREF(login_tuple_py);
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions source/event_stream_headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,15 @@ bool aws_py_event_stream_native_headers_init(struct aws_array_list *native_heade
goto done;
}

const Py_ssize_t count = PySequence_Fast_GET_SIZE(sequence_py);
const Py_ssize_t count = PySequence_Size(sequence_py);
for (Py_ssize_t i = 0; i < count; ++i) {
/* Borrowed reference, don't need to decref */
PyObject *header_py = PySequence_Fast_GET_ITEM(sequence_py, i);
PyObject *header_py = PySequence_GetItem(sequence_py, i);

if (!s_add_native_header(native_headers, header_py)) {
goto done;
}
Py_XDECREF(header_py);
Copy link
Contributor

Choose a reason for hiding this comment

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

same 2 comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.

}

success = true;
Expand Down Expand Up @@ -270,7 +271,7 @@ PyObject *aws_py_event_stream_python_headers_create(
goto error;
}

PyList_SET_ITEM(list_py, i, tuple_py); /* steals reference to tuple */
PyList_SetItem(list_py, i, tuple_py); /* steals reference to tuple */
}

return list_py;
Expand Down
15 changes: 8 additions & 7 deletions source/http_headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ PyObject *aws_py_http_headers_add_pairs(PyObject *self, PyObject *args) {
return NULL;
}

const Py_ssize_t count = PySequence_Fast_GET_SIZE(py_sequence);
const Py_ssize_t count = PySequence_Size(py_sequence);
for (Py_ssize_t i = 0; i < count; ++i) {
/* XYZ_GET_ITEM() calls returns borrowed references */
PyObject *py_pair = PySequence_Fast_GET_ITEM(py_sequence, i);
PyObject *py_pair = PySequence_GetItem(py_sequence, i);
graebm marked this conversation as resolved.
Show resolved Hide resolved

if (!PyTuple_Check(py_pair) || PyTuple_GET_SIZE(py_pair) != 2) {
if (!PyTuple_Check(py_pair) || PyTuple_Size(py_pair) != 2) {
PyErr_SetString(PyExc_TypeError, type_errmsg);
goto done;
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
}

struct aws_byte_cursor name = aws_byte_cursor_from_pyunicode(PyTuple_GET_ITEM(py_pair, 0));
struct aws_byte_cursor value = aws_byte_cursor_from_pyunicode(PyTuple_GET_ITEM(py_pair, 1));
struct aws_byte_cursor name = aws_byte_cursor_from_pyunicode(PyTuple_GetItem(py_pair, 0));
struct aws_byte_cursor value = aws_byte_cursor_from_pyunicode(PyTuple_GetItem(py_pair, 1));
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
Py_DECREF(py_pair);
if (!name.ptr || !value.ptr) {
PyErr_SetString(PyExc_TypeError, type_errmsg);
goto done;
Expand Down Expand Up @@ -175,8 +176,8 @@ static PyObject *s_py_tuple_from_header(struct aws_http_header header) {
goto error;
}

PyTuple_SET_ITEM(py_pair, 0, py_name);
PyTuple_SET_ITEM(py_pair, 1, py_value);
PyTuple_SetItem(py_pair, 0, py_name);
PyTuple_SetItem(py_pair, 1, py_value);
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
return py_pair;

error:
Expand Down
2 changes: 1 addition & 1 deletion source/http_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int s_on_incoming_header_block_done(
goto done;
}

PyList_SET_ITEM(header_list, i, tuple); /* steals reference to tuple */
PyList_SetItem(header_list, i, tuple); /* steals reference to tuple */
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
}

/* TODO: handle informational and trailing headers */
Expand Down
15 changes: 3 additions & 12 deletions source/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,30 +531,21 @@ void *aws_py_get_binding(PyObject *obj, const char *capsule_name, const char *cl

PyObject *py_binding = PyObject_GetAttrString(obj, "_binding"); /* new reference */
if (!py_binding) {
return PyErr_Format(
PyExc_TypeError,
"Expected valid '%s', received '%s' (no '_binding' attribute)",
class_name,
Py_TYPE(obj)->tp_name);
return PyErr_Format(PyExc_TypeError, "Expected valid '%s' (no '_binding' attribute)", class_name);
}

void *binding = NULL;
if (!PyCapsule_CheckExact(py_binding)) {
PyErr_Format(
PyExc_TypeError,
"Expected valid '%s', received '%s' ('_binding' attribute is not a capsule)",
class_name,
Py_TYPE(obj)->tp_name);
PyErr_Format(PyExc_TypeError, "Expected valid '%s' ('_binding' attribute is not a capsule)", class_name);
goto done;
}

binding = PyCapsule_GetPointer(py_binding, capsule_name);
if (!binding) {
PyErr_Format(
PyExc_TypeError,
"Expected valid '%s', received '%s' ('_binding' attribute does not contain '%s')",
"Expected valid '%s' ('_binding' attribute does not contain '%s')",
class_name,
Py_TYPE(obj)->tp_name,
capsule_name);
goto done;
}
Expand Down
24 changes: 12 additions & 12 deletions source/mqtt5_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static PyObject *s_aws_set_user_properties_to_PyObject(
Py_XDECREF(user_properties_list);
return NULL;
}
PyList_SET_ITEM(user_properties_list, i, tuple); /* Steals reference to tuple */
PyList_SetItem(user_properties_list, i, tuple); /* Steals reference to tuple */
graebm marked this conversation as resolved.
Show resolved Hide resolved
}
return user_properties_list;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ static void s_on_publish_received(const struct aws_mqtt5_packet_publish_view *pu
}

for (size_t i = 0; i < subscription_identifier_count; ++i) {
PyList_SET_ITEM(
PyList_SetItem(
subscription_identifier_list, i, PyLong_FromLongLong(publish_packet->subscription_identifiers[i]));
}

Expand Down Expand Up @@ -1629,7 +1629,7 @@ static void s_on_subscribe_complete_fn(
}

for (size_t i = 0; i < reason_codes_count; ++i) {
PyList_SET_ITEM(reason_codes_list, i, PyLong_FromLong(suback->reason_codes[i]));
PyList_SetItem(reason_codes_list, i, PyLong_FromLong(suback->reason_codes[i]));
}
}

Expand Down Expand Up @@ -1860,7 +1860,7 @@ static void s_on_unsubscribe_complete_fn(
}

for (size_t i = 0; i < reason_codes_count; ++i) {
PyList_SET_ITEM(reason_codes_list, i, PyLong_FromLong(unsuback->reason_codes[i]));
PyList_SetItem(reason_codes_list, i, PyLong_FromLong(unsuback->reason_codes[i]));
}
}

Expand Down Expand Up @@ -2030,23 +2030,23 @@ PyObject *aws_py_mqtt5_client_get_stats(PyObject *self, PyObject *args) {
goto done;
}

PyTuple_SET_ITEM(result, 0, PyLong_FromUnsignedLongLong((unsigned long long)stats.incomplete_operation_count));
if (PyTuple_GET_ITEM(result, 0) == NULL) {
PyTuple_SetItem(result, 0, PyLong_FromUnsignedLongLong((unsigned long long)stats.incomplete_operation_count));
if (PyTuple_GetItem(result, 0) == NULL) {
goto done;
}

PyTuple_SET_ITEM(result, 1, PyLong_FromUnsignedLongLong((unsigned long long)stats.incomplete_operation_size));
if (PyTuple_GET_ITEM(result, 1) == NULL) {
PyTuple_SetItem(result, 1, PyLong_FromUnsignedLongLong((unsigned long long)stats.incomplete_operation_size));
if (PyTuple_GetItem(result, 1) == NULL) {
goto done;
}

PyTuple_SET_ITEM(result, 2, PyLong_FromUnsignedLongLong((unsigned long long)stats.unacked_operation_count));
if (PyTuple_GET_ITEM(result, 2) == NULL) {
PyTuple_SetItem(result, 2, PyLong_FromUnsignedLongLong((unsigned long long)stats.unacked_operation_count));
if (PyTuple_GetItem(result, 2) == NULL) {
goto done;
}

PyTuple_SET_ITEM(result, 3, PyLong_FromUnsignedLongLong((unsigned long long)stats.unacked_operation_size));
if (PyTuple_GET_ITEM(result, 3) == NULL) {
PyTuple_SetItem(result, 3, PyLong_FromUnsignedLongLong((unsigned long long)stats.unacked_operation_size));
if (PyTuple_GetItem(result, 3) == NULL) {
goto done;
}

Expand Down
Loading
Loading