forked from CNES/pangeo-pyinterp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
39 lines (29 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) 2022 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])
return pathlib.Path(
WORKING_DIRECTORY, "build",
"lib.%s-%d.%d" % (sysconfig.get_platform(), MAJOR, MINOR), 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()
def pytest_addoption(parser):
"""Add command line options to pytest."""
parser.addoption("--visualize", action="store_true", default=False)
parser.addoption("--dump", action="store_true", default=False)