Debian Codegraph @

.builder/actions/aws_crt_python.py

raw symbols SCIP
1 import Builder
2 import argparse
3 from pathlib import Path
4 import sys
5
6
7 class AWSCrtPython(Builder.Action):
8
9 def run(self, env):
10 # allow custom python to be used
11 parser = argparse.ArgumentParser()
12 parser.add_argument('--python')
13 args = parser.parse_known_args(env.args.args)[0]
14 if args.python:
15 self.python = args.python
16 else:
17 # Fall back on using the "{python}" builder variable
18 self.python = env.config['variables']['python']
19
20 # Create a virtual environment and use that.
21 # Otherwise, in places like ubuntu 24.04, PEP 668 stops
22 # you from globally installing/upgrading packages
23 venv_dirpath = Path.cwd() / '.venv-builder'
24 env.shell.exec(self.python, '-m', 'venv', str(venv_dirpath), check=True)
25 if sys.platform == 'win32':
26 self.python = str(venv_dirpath / 'Scripts/python')
27 else:
28 self.python = str(venv_dirpath / 'bin/python')
29
30 # Enable S3 tests
31 env.shell.setenv('AWS_TEST_S3', '1')
32 env.shell.setenv('AWS_TEST_LOCALHOST', '1')
33
34 actions = [
35 [self.python, '--version'],
36 [self.python, '-m', 'pip', 'install', '--upgrade', 'pip'],
37 Builder.SetupCrossCICrtEnvironment(),
38 [self.python, '-m', 'pip', 'install', '--verbose', '.[dev]'],
39 # "--failfast" because, given how our leak-detection in tests currently works,
40 # once one test fails all the rest usually fail too.
41 [self.python, '-m', 'unittest', 'discover', '--verbose', '--failfast'],
42 # postman-echo.com in now requires TLS1.3,
43 # but our Mac implementation doesn't support TLS1.3 yet.
44 # The work has been planned to Dec. 2025 to support TLS1.3,
45 # so disable the test for now. And reenable it afterward
46 # # http_client_test.py launches external processes using the extra args
47 # [self.python, 'crt/aws-c-http/integration-testing/http_client_test.py',
48 # self.python, 'elasticurl.py'],
49 ]
50
51 return Builder.Script(actions, name='aws-crt-python')