Skip to content

Commit

Permalink
Import all west modules from west.
Browse files Browse the repository at this point in the history
We are getting user feedback about missing dependencies (like
"commands" and "log") that are actually imports of internal west
modules by those names.

We've been playing games with the python path to omit typing "west",
but this always caused inconsistency (as the bootstrapper version is
imported as west._bootstrap.version) and now it's causing outright
user confusion.

Let's just be consistent and import everything as west.xxx.

Fixes #57.

Signed-off-by: Marti Bolivar <marti@foundries.io>
  • Loading branch information
Marti Bolivar committed Sep 28, 2018
1 parent e44a74d commit 8b40656
Show file tree
Hide file tree
Showing 30 changed files with 99 additions and 96 deletions.
4 changes: 2 additions & 2 deletions .shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ build:
- pip install dist/west*.whl
- pip install -r tests_requirements.txt
- mkdir -p shippable/{testresults,codecoverage}
- PYTHONPATH=src/west pytest --junitxml=shippable/testresults/nosetests.xml tests
- PYTHONPATH=src/west pytest --cov=west --cov-report=xml:shippable/codecoverage/coverage.xml tests
- PYTHONPATH=src pytest --junitxml=shippable/testresults/nosetests.xml tests
- PYTHONPATH=src pytest --cov=west --cov-report=xml:shippable/codecoverage/coverage.xml tests
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ To run the test suite, run this from the west repository::

Then, in a Bash shell::

PYTHONPATH=src/west py.test
PYTHONPATH=src py.test

On Windows::

cmd /C "set PYTHONPATH=/path/to/west/src/west && py.test"
cmd /C "set PYTHONPATH=/path/to/west/src && py.test"

Hacking on West
---------------
Expand Down
4 changes: 2 additions & 2 deletions src/west/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
See west.cmd.build for the build command itself.
'''

import cmake
import log
from west import cmake
from west import log

DEFAULT_BUILD_DIR = 'build'
'''Name of the default Zephyr build directory.'''
Expand Down
4 changes: 2 additions & 2 deletions src/west/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import subprocess
import shutil

import log
from util import quote_sh_list
from west import log
from west.util import quote_sh_list

__all__ = ['run_cmake', 'run_build',
'make_c_identifier',
Expand Down
9 changes: 5 additions & 4 deletions src/west/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import argparse
import os

import log
import cmake
from build import DEFAULT_BUILD_DIR, DEFAULT_CMAKE_GENERATOR, is_zephyr_build
from commands import WestCommand
from west import log
from west import cmake
from west.build import DEFAULT_BUILD_DIR, DEFAULT_CMAKE_GENERATOR, \
is_zephyr_build
from west.commands import WestCommand

BUILD_HELP = '''\
Convenience wrapper for building Zephyr applications.
Expand Down
4 changes: 2 additions & 2 deletions src/west/commands/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from textwrap import dedent

from commands.run_common import desc_common, add_parser_common, do_run_common
from commands import WestCommand
from west.commands.run_common import desc_common, add_parser_common, do_run_common
from west.commands import WestCommand


class Debug(WestCommand):
Expand Down
5 changes: 3 additions & 2 deletions src/west/commands/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

'''west "flash" command'''

from commands.run_common import desc_common, add_parser_common, do_run_common
from commands import WestCommand
from west.commands.run_common import desc_common, add_parser_common, \
do_run_common
from west.commands import WestCommand


class Flash(WestCommand):
Expand Down
6 changes: 3 additions & 3 deletions src/west/commands/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import pykwalify.core
import yaml

import log
import util
from commands import WestCommand
from west import log
from west import util
from west.commands import WestCommand


# Branch that points to the revision specified in the manifest (which might be
Expand Down
14 changes: 7 additions & 7 deletions src/west/commands/run_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from subprocess import CalledProcessError
import textwrap

import cmake
import log
import util
from build import DEFAULT_BUILD_DIR, is_zephyr_build
from runners import get_runner_cls, ZephyrBinaryRunner
from runners.core import RunnerConfig
from commands import CommandContextError
from west import cmake
from west import log
from west import util
from west.build import DEFAULT_BUILD_DIR, is_zephyr_build
from west.runners import get_runner_cls, ZephyrBinaryRunner
from west.runners.core import RunnerConfig
from west.commands import CommandContextError

# Context-sensitive help indentation.
# Don't change this, or output from argparse won't match up.
Expand Down
14 changes: 7 additions & 7 deletions src/west/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import sys
from subprocess import CalledProcessError, check_output, DEVNULL

import log
from commands import CommandContextError
from commands.build import Build
from commands.flash import Flash
from commands.debug import Debug, DebugServer, Attach
from commands.project import ListProjects, Fetch, Pull, Rebase, Branch, \
from west import log
from west.commands import CommandContextError
from west.commands.build import Build
from west.commands.flash import Flash
from west.commands.debug import Debug, DebugServer, Attach
from west.commands.project import ListProjects, Fetch, Pull, Rebase, Branch, \
Checkout, Diff, Status, Update, ForAll, \
WestUpdated
from util import quote_sh_list, in_multirepo_install
from west.util import quote_sh_list, in_multirepo_install

IN_MULTIREPO_INSTALL = in_multirepo_install(__file__)

Expand Down
28 changes: 14 additions & 14 deletions src/west/runners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
#
# SPDX-License-Identifier: Apache-2.0

from runners.core import ZephyrBinaryRunner
from west.runners.core import ZephyrBinaryRunner

# We import these here to ensure the ZephyrBinaryRunner subclasses are
# defined; otherwise, ZephyrBinaryRunner.create_for_shell_script()
# won't work.

# Explicitly silence the unused import warning.
# flake8: noqa: F401
from runners import arc
from runners import bossac
from runners import dfu
from runners import esp32
from runners import jlink
from runners import nios2
from runners import nrfjprog
from runners import nsim
from runners import openocd
from runners import pyocd
from runners import qemu
from runners import xtensa
from runners import intel_s1000
from west.runners import arc
from west.runners import bossac
from west.runners import dfu
from west.runners import esp32
from west.runners import jlink
from west.runners import nios2
from west.runners import nrfjprog
from west.runners import nsim
from west.runners import openocd
from west.runners import pyocd
from west.runners import qemu
from west.runners import xtensa
from west.runners import intel_s1000

def get_runner_cls(runner):
'''Get a runner's class object, given its name.'''
Expand Down
2 changes: 1 addition & 1 deletion src/west/runners/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from os import path

from runners.core import ZephyrBinaryRunner
from west.runners.core import ZephyrBinaryRunner

DEFAULT_ARC_TCL_PORT = 6333
DEFAULT_ARC_TELNET_PORT = 4444
Expand Down
2 changes: 1 addition & 1 deletion src/west/runners/bossac.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import platform

from runners.core import ZephyrBinaryRunner, RunnerCaps
from west.runners.core import ZephyrBinaryRunner, RunnerCaps

DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'

Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import signal
import subprocess

import log
from util import quote_sh_list
from west import log
from west.util import quote_sh_list

# Turn on to enable just printing the commands that would be run,
# without actually running them. This can break runners that are expecting
Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/dfu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import sys
import time

import log
from runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration
from west import log
from west.runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration


DfuSeConfig = namedtuple('DfuSeConfig', ['address', 'options'])
Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from os import path

import log
from runners.core import ZephyrBinaryRunner, RunnerCaps
from west import log
from west.runners.core import ZephyrBinaryRunner, RunnerCaps


class Esp32BinaryRunner(ZephyrBinaryRunner):
Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/intel_s1000.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import time
import subprocess

import log
from runners.core import ZephyrBinaryRunner
from west import log
from west.runners.core import ZephyrBinaryRunner

DEFAULT_XT_GDB_PORT = 20000

Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/jlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import os
import tempfile

import log
from runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration
from west import log
from west.runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration

DEFAULT_JLINK_GDB_PORT = 2331

Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/nios2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

'''Runner for NIOS II, based on quartus-flash.py and GDB.'''

import log
from runners.core import ZephyrBinaryRunner, NetworkPortHelper
from west import log
from west.runners.core import ZephyrBinaryRunner, NetworkPortHelper


class Nios2BinaryRunner(ZephyrBinaryRunner):
Expand Down
4 changes: 2 additions & 2 deletions src/west/runners/nrfjprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import sys

import log
from runners.core import ZephyrBinaryRunner, RunnerCaps
from west import log
from west.runners.core import ZephyrBinaryRunner, RunnerCaps


class NrfJprogBinaryRunner(ZephyrBinaryRunner):
Expand Down
2 changes: 1 addition & 1 deletion src/west/runners/nsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from os import path

from runners.core import ZephyrBinaryRunner
from west.runners.core import ZephyrBinaryRunner

DEFAULT_ARC_GDB_PORT = 3333
DEFAULT_PROPS_FILE = 'nsim.props'
Expand Down
2 changes: 1 addition & 1 deletion src/west/runners/openocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from os import path

from runners.core import ZephyrBinaryRunner
from west.runners.core import ZephyrBinaryRunner

DEFAULT_OPENOCD_TCL_PORT = 6333
DEFAULT_OPENOCD_TELNET_PORT = 4444
Expand Down
5 changes: 3 additions & 2 deletions src/west/runners/pyocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import os
import sys
from runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration
import log

from west.runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration
from west import log

DEFAULT_PYOCD_GDB_PORT = 3333

Expand Down
2 changes: 1 addition & 1 deletion src/west/runners/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'''Runner stub for QEMU.'''

from runners.core import ZephyrBinaryRunner, RunnerCaps
from west.runners.core import ZephyrBinaryRunner, RunnerCaps


class QemuBinaryRunner(ZephyrBinaryRunner):
Expand Down
2 changes: 1 addition & 1 deletion src/west/runners/xtensa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from os import path

from runners.core import ZephyrBinaryRunner, RunnerCaps
from west.runners.core import ZephyrBinaryRunner, RunnerCaps


class XtensaBinaryRunner(ZephyrBinaryRunner):
Expand Down
20 changes: 10 additions & 10 deletions tests/west/project/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

import commands.project
from west.commands import project

# Path to the template manifest used to construct a real one when
# running each test case.
Expand All @@ -19,15 +19,15 @@
KCONFIGLIB_PATH = 'sub/Kconfiglib'

COMMAND_OBJECTS = (
commands.project.ListProjects(),
commands.project.Fetch(),
commands.project.Pull(),
commands.project.Rebase(),
commands.project.Branch(),
commands.project.Checkout(),
commands.project.Diff(),
commands.project.Status(),
commands.project.ForAll(),
project.ListProjects(),
project.Fetch(),
project.Pull(),
project.Rebase(),
project.Branch(),
project.Checkout(),
project.Diff(),
project.Status(),
project.ForAll(),
)


Expand Down
2 changes: 1 addition & 1 deletion tests/west/runners/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from runners.core import RunnerConfig, ZephyrBinaryRunner
from west.runners.core import RunnerConfig

RC_BUILD_DIR = '/test/build-dir'
RC_BOARD_DIR = '/test/zephyr/boards/test-arch/test-board'
Expand Down
2 changes: 1 addition & 1 deletion tests/west/runners/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from runners.core import ZephyrBinaryRunner
from west.runners.core import ZephyrBinaryRunner


def test_runner_imports():
Expand Down
Loading

0 comments on commit 8b40656

Please sign in to comment.