| 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 |
|
| 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 |
|
| 18 |
self.python = env.config['variables']['python'] |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 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 |
|
| 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 |
|
| 40 |
|
| 41 |
[self.python, '-m', 'unittest', 'discover', '--verbose', '--failfast'], |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
] |
| 50 |
|
| 51 |
return Builder.Script(actions, name='aws-crt-python') |