-
Notifications
You must be signed in to change notification settings - Fork 27
/
conftest.py
39 lines (31 loc) · 1.15 KB
/
conftest.py
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
# Copyright (c) 2024 CNES
#
# All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import os
import pathlib
import sys
import sysconfig
# Check Python requirement
MAJOR = sys.version_info[0]
MINOR = sys.version_info[1]
# Working directory
WORKING_DIRECTORY = pathlib.Path(__file__).parent.absolute()
def build_dirname(extname=None):
"""Returns the name of the build directory."""
extname = '' if extname is None else os.sep.join(extname.split('.')[:-1])
path = pathlib.Path(WORKING_DIRECTORY, 'build',
f'lib.{sysconfig.get_platform()}-{MAJOR}.{MINOR}',
extname)
if path.exists():
return path
return pathlib.Path(
WORKING_DIRECTORY, 'build',
f'lib.{sysconfig.get_platform()}-{sys.implementation.cache_tag}',
extname)
def push_front_syspath():
"""Add the build directory to the front of sys.path."""
if WORKING_DIRECTORY.joinpath('setup.py').exists():
# We are in the root directory of the development tree
sys.path.insert(0, str(build_dirname().resolve()))
push_front_syspath()