Initial package

This commit is contained in:
Nikola Forró 2023-03-20 15:50:12 +01:00
parent 8192b03eed
commit 26a34e8c0c
6 changed files with 170 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/awscrt-0.16.13.tar.gz

View File

@ -1,3 +1,3 @@
# python-awscrt
The python-awscrt package
Python bindings for the AWS Common Runtime

78
python-awscrt.spec Normal file
View File

@ -0,0 +1,78 @@
%global desc %{expand:
Python bindings for the AWS Common Runtime}
Name: python-awscrt
Version: 0.16.13
Release: 1%{?dist}
Summary: Python bindings for the AWS Common Runtime
# All files are licensed under Apache-2.0, except:
# - crt/aws-c-common/include/aws/common/external/cJSON.h is MIT
# - crt/aws-c-common/source/external/cJSON.c is MIT
# - crt/s2n/pq-crypto/kyber_r3/KeccakP-brg_endian_avx2.h is BSD-3-Clause
License: Apache-2.0 AND MIT AND BSD-3-Clause
URL: https://github.com/awslabs/aws-crt-python
Source0: %{pypi_source awscrt}
# https://github.com/awslabs/aws-crt-python/pull/456
Patch0: use-system-libcrypto.patch
# one test requires internet connection, skip it
Patch1: skip-test-requiring-network.patch
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: cmake
BuildRequires: openssl-devel
BuildRequires: python%{python3_pkgversion}-websockets
# some parts of the code are not big endian friendly
ExcludeArch: s390x
%description
%{desc}
%package -n python%{python3_pkgversion}-awscrt
Summary: %{summary}
%description -n python%{python3_pkgversion}-awscrt
%{desc}
%prep
%autosetup -p1 -n awscrt-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
export AWS_CRT_BUILD_USE_SYSTEM_LIBCRYPTO=1
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files _awscrt awscrt
%check
PYTHONPATH="%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}" %{python3} -m unittest
%files -n python%{python3_pkgversion}-awscrt -f %{pyproject_files}
%doc README.md
%changelog
* Thu Mar 16 2023 Nikola Forró <nforro@redhat.com> - 0.16.13-1
- Initial package

View File

@ -0,0 +1,12 @@
diff --git a/test/test_http_client.py b/test/test_http_client.py
index 5af87b6..dd2631a 100644
--- a/test/test_http_client.py
+++ b/test/test_http_client.py
@@ -347,6 +347,7 @@ class TestClient(NativeResourceTest):
tls_connection_options=tls_conn_opt)
return connection_future.result(self.timeout)
+ @unittest.skip("Requires network")
def test_h2_client(self):
url = urlparse("https://d1cz66xoahf9cl.cloudfront.net/http_test_doc.txt")
connection = self._new_h2_client_connection(url)

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (awscrt-0.16.13.tar.gz) = 4f5d3309c2e12f64b74b264a24a3e341f9b6e03579ca0b8631ca065577b863381bc85491d7619f820ba3196961289c2ef82f5cd3cedde1e5247600de24afcdfe

View File

@ -0,0 +1,77 @@
diff --git a/crt/CMakeLists.txt b/crt/CMakeLists.txt
index a2aa142..2484781 100644
--- a/crt/CMakeLists.txt
+++ b/crt/CMakeLists.txt
@@ -29,10 +29,14 @@ include(CTest)
# On Unix we use S2N for TLS and AWS-LC crypto.
# (On Windows and Apple we use the default OS libraries)
if(UNIX AND NOT APPLE)
- set(DISABLE_GO ON CACHE BOOL "Build without using Go, we don't want the extra dependency")
- set(DISABLE_PERL ON CACHE BOOL "Build without using Perl, we don't want the extra dependency")
- set(BUILD_LIBSSL OFF CACHE BOOL "Don't need libssl, only need libcrypto")
- add_subdirectory(aws-lc)
+ option(USE_OPENSSL "Set this if you want to use your system's OpenSSL compatible libcrypto" OFF)
+
+ if(NOT USE_OPENSSL)
+ set(DISABLE_GO ON CACHE BOOL "Build without using Go, we don't want the extra dependency")
+ set(DISABLE_PERL ON CACHE BOOL "Build without using Perl, we don't want the extra dependency")
+ set(BUILD_LIBSSL OFF CACHE BOOL "Don't need libssl, only need libcrypto")
+ add_subdirectory(aws-lc)
+ endif()
set(UNSAFE_TREAT_WARNINGS_AS_ERRORS OFF CACHE BOOL "")
add_subdirectory(s2n)
diff --git a/setup.py b/setup.py
index e85948c..d7c6291 100644
--- a/setup.py
+++ b/setup.py
@@ -121,6 +121,10 @@ def get_cmake_path():
raise Exception("CMake must be installed to build from source.")
+def using_system_libcrypto():
+ return os.getenv('AWS_CRT_BUILD_USE_SYSTEM_LIBCRYPTO') == '1'
+
+
class AwsLib:
def __init__(self, name, extra_cmake_args=[], libname=None):
self.name = name
@@ -132,8 +136,9 @@ class AwsLib:
# They're built along with the extension.
AWS_LIBS = []
if sys.platform != 'darwin' and sys.platform != 'win32':
- # aws-lc produces libcrypto.a
- AWS_LIBS.append(AwsLib('aws-lc', libname='crypto'))
+ if not using_system_libcrypto():
+ # aws-lc produces libcrypto.a
+ AWS_LIBS.append(AwsLib('aws-lc', libname='crypto'))
AWS_LIBS.append(AwsLib('s2n'))
AWS_LIBS.append(AwsLib('aws-c-common'))
AWS_LIBS.append(AwsLib('aws-c-sdkutils'))
@@ -182,6 +187,9 @@ class awscrt_build_ext(setuptools.command.build_ext.build_ext):
f'-DCMAKE_BUILD_TYPE={build_type}',
])
+ if using_system_libcrypto():
+ cmake_args.append('-DUSE_OPENSSL=ON')
+
if sys.platform == 'darwin':
# build lib with same MACOSX_DEPLOYMENT_TARGET that python will ultimately
# use to link everything together, otherwise there will be linker warnings.
@@ -298,13 +306,13 @@ def awscrt_ext():
extra_link_args += ['-framework', 'Security']
else: # unix
- # linker will prefer shared libraries over static if it can find both.
- # force linker to choose static variant by using using "-l:libcrypto.a" syntax instead of just "-lcrypto".
- libraries = [':lib{}.a'.format(x) for x in libraries]
# OpenBSD doesn't have librt; functions are found in libc instead.
if not sys.platform.startswith('openbsd'):
libraries += ['rt']
+ if using_system_libcrypto():
+ libraries += ['crypto']
+
# hide the symbols from libcrypto.a
# this prevents weird crashes if an application also ends up using
# libcrypto.so from the system's OpenSSL installation.