File: ci-driver.py

package info (click to toggle)
oscrypto 1.3.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,164 kB
  • sloc: python: 22,115; makefile: 7
file content (79 lines) | stat: -rw-r--r-- 1,947 bytes parent folder | download | duplicates (2)
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
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function

import os
import platform
import sys
import subprocess


run_args = [
    {
        'name': 'cffi',
        'kwarg': 'cffi',
    },
    {
        'name': 'openssl',
        'kwarg': 'openssl',
    },
    {
        'name': 'winlegacy',
        'kwarg': 'winlegacy',
    },
]


def _write_env(env, key, value):
    sys.stdout.write("%s: %s\n" % (key, value))
    sys.stdout.flush()
    if sys.version_info < (3,):
        env[key.encode('utf-8')] = value.encode('utf-8')
    else:
        env[key] = value


def run(**_):
    """
    Runs CI, setting various env vars

    :return:
        A bool - if the CI ran successfully
    """

    env = os.environ.copy()
    options = set(sys.argv[2:])

    newline = False
    if 'cffi' not in options:
        _write_env(env, 'OSCRYPTO_USE_CTYPES', 'true')
        newline = True
    if 'openssl' in options and sys.platform == 'darwin':
        mac_version_info = tuple(map(int, platform.mac_ver()[0].split('.')[:2]))
        if mac_version_info < (10, 15):
            _write_env(env, 'OSCRYPTO_USE_OPENSSL', '/usr/lib/libcrypto.dylib,/usr/lib/libssl.dylib')
        else:
            _write_env(env, 'OSCRYPTO_USE_OPENSSL', '/usr/lib/libcrypto.35.dylib,/usr/lib/libssl.35.dylib')
        newline = True
    if 'openssl3' in options and sys.platform == 'darwin':
        _write_env(
            env,
            'OSCRYPTO_USE_OPENSSL',
            '/usr/local/opt/openssl@3/lib/libcrypto.dylib,/usr/local/opt/openssl@3/lib/libssl.dylib'
        )
    if 'winlegacy' in options:
        _write_env(env, 'OSCRYPTO_USE_WINLEGACY', 'true')
        newline = True

    if newline:
        sys.stdout.write("\n")

    proc = subprocess.Popen(
        [
            sys.executable,
            'run.py',
            'ci',
        ],
        env=env
    )
    proc.communicate()
    return proc.returncode == 0