forked from aws/aws-lambda-python-runtime-interface-client
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
98 lines (81 loc) · 3.16 KB
/
Copy pathsetup.py
File metadata and controls
98 lines (81 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
"""
importio
importos
importplatform
fromsubprocessimportcheck_call, check_output
fromsetuptoolsimportExtension, find_packages, setup
fromawslambdaricimport__version__
defget_curl_extra_linker_flags():
# We do not want to build the dependencies during packaging
ifplatform.system() !="Linux"oros.getenv("BUILD") =="true":
return []
# Build the dependencies
check_call(["./scripts/preinstall.sh"])
# call curl-config to get the required linker flags
cmd= ["./deps/artifacts/bin/curl-config", "--static-libs"]
curl_config=check_output(cmd).decode("utf-8").replace("\n", "")
# It is expected that the result of the curl-config call is similar to
# "/tmp/pip-req-build-g9dlug7g/deps/artifacts/lib/libcurl.a -lidn2"
# we want to return just the extra flags
flags=curl_config.split(" ")[1:]
returnflags
defget_runtime_client_extension():
ifplatform.system() !="Linux"andos.getenv("BUILD") !="true":
print(
"The native runtime_client only builds on Linux. Skipping its compilation."
)
return []
runtime_client=Extension(
"runtime_client",
["awslambdaric/runtime_client.cpp"],
extra_compile_args=["--std=c++11"],
library_dirs=["deps/artifacts/lib", "deps/artifacts/lib64"],
libraries=["aws-lambda-runtime", "curl"],
extra_link_args=get_curl_extra_linker_flags(),
include_dirs=["deps/artifacts/include"],
)
return [runtime_client]
defread(*filenames, **kwargs):
encoding=kwargs.get("encoding", "utf-8")
sep=kwargs.get("sep", os.linesep)
buf= []
forfilenameinfilenames:
withio.open(filename, encoding=encoding) asf:
buf.append(f.read())
returnsep.join(buf)
defread_requirements(req="base.txt"):
content=read(os.path.join("requirements", req))
return [
lineforlineincontent.split(os.linesep) ifnotline.strip().startswith("#")
]
setup(
name="awslambdaric",
version=__version__,
author="Amazon Web Services",
description="AWS Lambda Runtime Interface Client for Python",
long_description=read("README.md"),
long_description_content_type="text/markdown",
url="https://github.com/aws/aws-lambda-python-runtime-interface-client",
packages=find_packages(
exclude=("tests", "tests.*", "docs", "examples", "versions")
),
install_requires=read_requirements("base.txt"),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
python_requires=">=3.9",
ext_modules=get_runtime_client_extension(),
test_suite="tests",
)