Commit 461dc105 authored by Lukas Vik's avatar Lukas Vik
Browse files

Do PYTHONPATH insert() instead of append() in examples

This will prefer local repo checkouts of the projects instead of packages installed with pip.
Previously when e.g. build.py was called in a local repo checkout, if tsfpga was also installed via pip the tsfpga package would be imported from the pip install rather than the local repo.
parent 3641d518
......@@ -16,10 +16,11 @@ import builtins
from pathlib import Path
import sys
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
TSFPGA_ROOT = Path(__file__).parent.parent.parent
sys.path.append(str(TSFPGA_ROOT))
sys.path.insert(0, str(TSFPGA_ROOT))
PATH_TO_VUNIT = TSFPGA_ROOT.parent / "vunit"
sys.path.append(str(PATH_TO_VUNIT.resolve()))
sys.path.insert(0, str(PATH_TO_VUNIT.resolve()))
# -- Project information -----------------------------------------------------
......
......@@ -11,10 +11,11 @@ from pathlib import Path
from shutil import copy2, make_archive
import sys
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
PATH_TO_TSFPGA = Path(__file__).parent.parent.resolve()
sys.path.append(str(PATH_TO_TSFPGA))
sys.path.insert(0, str(PATH_TO_TSFPGA))
PATH_TO_VUNIT = PATH_TO_TSFPGA.parent / "vunit"
sys.path.append(str(PATH_TO_VUNIT))
sys.path.insert(0, str(PATH_TO_VUNIT))
from tsfpga.build_project_list import BuildProjectList
from tsfpga.system_utils import create_directory, delete
......
......@@ -12,10 +12,11 @@ import argparse
from pathlib import Path
import sys
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
PATH_TO_TSFPGA = Path(__file__).parent.parent.resolve()
sys.path.append(str(PATH_TO_TSFPGA))
sys.path.insert(0, str(PATH_TO_TSFPGA))
PATH_TO_VUNIT = PATH_TO_TSFPGA.parent / "vunit"
sys.path.append(str(PATH_TO_VUNIT))
sys.path.insert(0, str(PATH_TO_VUNIT))
from examples.tsfpga_example_env import get_tsfpga_modules, TSFPGA_EXAMPLES_TEMP_DIR
......
......@@ -11,10 +11,11 @@ from shutil import which
import subprocess
import sys
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
PATH_TO_TSFPGA = Path(__file__).parent.parent.resolve()
sys.path.append(str(PATH_TO_TSFPGA))
sys.path.insert(0, str(PATH_TO_TSFPGA))
PATH_TO_VUNIT = PATH_TO_TSFPGA.parent / "vunit"
sys.path.append(str(PATH_TO_VUNIT))
sys.path.insert(0, str(PATH_TO_VUNIT))
from vunit import VUnitCLI, VUnit
from vunit.vivado.vivado import create_compile_order_file, add_from_compile_order_file
......
......@@ -17,8 +17,10 @@ from xml.etree import ElementTree
from pybadges import badge
from git import Repo
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
REPO_ROOT = Path(__file__).parent.parent
sys.path.append(str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT))
import tsfpga
from tsfpga.about import get_short_doc, get_doc
from tsfpga.system_utils import create_directory, create_file, delete, read_file
......
......@@ -11,8 +11,9 @@ import pytest
import tsfpga
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
PATH_TO_VUNIT = tsfpga.REPO_ROOT.parent / "vunit"
sys.path.append(str(PATH_TO_VUNIT.resolve()))
sys.path.insert(0, str(PATH_TO_VUNIT.resolve()))
@pytest.fixture
......
......@@ -10,5 +10,6 @@ import sys
import tsfpga
# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install
PATH_TO_VUNIT = tsfpga.REPO_ROOT.parent / "vunit"
sys.path.append(str(PATH_TO_VUNIT.resolve()))
sys.path.insert(0, str(PATH_TO_VUNIT.resolve()))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment