| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import os |
||
| 2 | |||
| 3 | from setuptools import setup |
||
| 4 | |||
| 5 | |||
| 6 | def load_version(version_file_path): |
||
| 7 | import re |
||
| 8 | file_contents = open(version_file_path, "rt").read() |
||
| 9 | version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]" |
||
| 10 | match = re.search(version_regex, file_contents, re.M) |
||
| 11 | if match: |
||
| 12 | return match.group(1) |
||
| 13 | else: |
||
| 14 | raise RuntimeError(f"Unable to find version string in {version_file_path}") |
||
| 15 | |||
| 16 | |||
| 17 | if os.getenv('LAGOM_SKIP_COMPILE') and os.getenv('LAGOM_COMPILE'): |
||
| 18 | raise Exception("Both LAGOM_SKIP_COMPILE and LAGOM_COMPILE ") |
||
| 19 | elif os.getenv('LAGOM_COMPILE'): |
||
| 20 | LAGOM_COMPILE = bool(int(os.environ['LAGOM_COMPILE'])) |
||
| 21 | elif os.getenv('LAGOM_SKIP_COMPILE'): |
||
| 22 | LAGOM_COMPILE = not bool(int(bool(int(os.environ['LAGOM_SKIP_COMPILE'])))) |
||
| 23 | else: |
||
| 24 | LAGOM_COMPILE = False |
||
| 25 | |||
| 26 | if LAGOM_COMPILE: |
||
| 27 | from mypyc.build import mypycify |
||
| 28 | setup( |
||
| 29 | version=load_version("lagom/version.py"), |
||
| 30 | ext_modules=mypycify([ |
||
| 31 | 'lagom/container.py', |
||
| 32 | 'lagom/context_based.py', |
||
| 33 | 'lagom/definitions.py', |
||
| 34 | 'lagom/experimental/definitions.py', |
||
| 35 | 'lagom/updaters.py', |
||
| 36 | ]) |
||
| 37 | ) |
||
| 38 | else: |
||
| 39 | setup( |
||
| 40 | version=load_version("lagom/version.py") |
||
| 41 | ) |
||
| 43 |