awslabs / aws-crt-python

Python bindings for the AWS Common Runtime
Apache License 2.0
87 stars 43 forks source link

Update setup.py #594

Closed gorloffslava closed 2 weeks ago

gorloffslava commented 3 weeks ago

This PR adds a new buildtime environment variable AWS_CRT_BUILD_USE_SHARED_LIBS.

When it's set to 1, it overrides the default behavior of trying to link static library variants on Unix OSs (except darwin ).

This default behavior is enforced by the following lines: https://github.com/awslabs/aws-crt-python/blob/2dae492d57b40c68839f2ecd7867bea34e6f9f1a/setup.py#L340-L348

Currently, there is no way to disable it and prefer shared libraries instead, what this PR solves.

As a continuation of the #593, it allows to reduce the libraries footprint in disk-restricted environments like Lambda, promote shared libraries reuse in RAM (e.g., if multiple Python packages depend on them), and generally make it more aligned with best native Python extensions build practices.

This PR is backward-compatible as feature it provides is opt-in, it doesn't change the default behavior of preferring static libraries.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

BwL1289 commented 3 weeks ago

@graebm as stated this is a continuation of #593. Thought it was easier to open a PR then submit a new issue 😄.

graebm commented 2 weeks ago

Thanks for the PR. I'm looking into this ... just busy

BwL1289 commented 2 weeks ago

No problem. Apologies I missed this in the previous issue/PR.

graebm commented 2 weeks ago

Here's my take on it: https://github.com/awslabs/aws-crt-python/pull/596

It's the opposite of your approach. I'll fix AWS's internal build system to use the new-extra-weird env-var. Instead of forcing slightly-less-weird users like yourself to set 2 env-vars.

graebm commented 2 weeks ago

Thoughts on #596? Does this work for you?

BwL1289 commented 2 weeks ago

@graebm just seeing - will test and get back to you. Thank you!