-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
west library / application / bootstrap structure and API #38
Comments
IRC discussion found in attachment. |
Thanks for opening this! Re. the API, I would go for a plain from west import ESP32BinaryRunner (Much nicer than the ugly separate top-level I don't think West is large enough to warrant any namespacing in the API. Heavily namespaced code tends to be hard to read, IMO ( For the structure, simplest thing would just to put everything at the top level I think. Probably too simple though. At least the tests ought to go in a separate directory.
Adding one layer of subdirectories:
I'm sure it could be tweaked (didn't even list a bunch of other files), but personally I prefer fairly shallow and " Any thoughts? |
I looked into how the Python standard library tends to organize things (can be found in
Adopting the suggestion from the last comment to that approach, you get Mark II:
(The runners could go in an extra directory as well, though there aren't a lot of them at the moment, and shaving a directory level is always nice. It's an implementation detail anyway.)
from .runner_bossac import BossacBinaryRunner
from .runner_xtensa import XtensaBinaryRunner People would then be able to simply do from west import BossacBinaryRunner, XtensaBinaryRunner
from .debug import Debug
from .flash import Flash
... This is pretty similar to the old design, just a bit stripped down, and with the library clearly separated out. @mbolivar @tejlmand @carlescufi Edit: Wonder if Mark III would be to get rid of the |
I think this discussion is a great one and worth having, but that before we go and do The Big Refactor, we should at a minimum have an answer for how people are going to define and use custom, out of tree, never-going-to-be-upstreamed west commands without having to touch the main west repository. I also think having a |
@ulfalizer thanks for the detailed description. To be completely honest to you and @mbolivar, I do not know about the exact details of PEP420 so I don't think I can have an opinion on using the same packaging approach as the Python standard library. I believe we took a decision on importing everything from a single namespace, meaning the
I am not sure if you want to move that to the root folder? I feel we need to discuss this in the context of:
Maybe we could start there? Defining in detail what belongs where? |
Heh, didn't notice that people had written stuff here.
Yeah, that part irks me. The bootstrapper could just be a single I don't understand what we need namespace packages for, and I've never seen them come up outside distribution packaging and the like. It's just more stuff that'll confuse people I think. :)
Personally, I'd just move the flashers and the like out of West and into the Zephyr repo. That has at least three advantages:
Sounds good. Currently, I don't think we have anything like a well-defined API. It's more of a "let's make everything importable in case someone wants to use it". I suspect we don't even need a library though, at least not yet. It feels like we're trying to be a bit too "enterprisey". |
Well, from early discussion,
So In this context, it makes sense to have to flashing scripts in About making a lib, then for automated build systems, it is often nicer / more convenient to be able to interface to an well-structured API, instead of a command line interface.
I assume this is because you consider
So maybe we should re-visit the self-update mechanism for
Why is that ? Note: Actually I think Zephyr is the first time I have experienced the possibility to use a build system to flash a target. |
That still feels like "we decided that it makes sense to lump a bunch of things into a I don't think we should get hung up on the name. What we're adding is a repo tool and some flashing and building helpers. Calling both of them West doesn't say anything about where it makes the most sense to implement each.
It's because I think those are unrelated features, regardless of whether you call them West or not (and regardless of what you call any command(s)). I think we ought to be thinking "does it make sense to put these features together?", ignoring the West part altogether. We could still it call some things West if we want to, for branding. That doesn't mean that they all have to go in the same command, or be implemented in the same place.
Easiest would be to implement features where the self-update mechanism makes less sense somewhere else, I think.
I thought they were wrappers around existing CMake commands, but I might be wrong. It feels like they make the most sense in the Zephyr repository at least. Doing a reversal test, if the building and flashing helpers were already implemented in the Zephyr repository, would you want to move them into the tool that implements the multi-repo commands? What advantages do you see with that? |
I am confused about your continued and persistent insistence on this point, which I feel we have discussed at length already is not correct. It seems like you are looking at what is currently in the west source code and deciding that is all that will ever be in west. West is a meta tool for doing Zephyr development. Its commands will implement what is required to develop embedded applications using the Zephyr RTOS. Almost by the definition of an RTOS that involves flashing and debugging binaries on supported targets. For various reasons it is also going to involve managing multiple git repositories in a coordinated way. Concluding that it stops there makes no sense.
We have also discussed this repeatedly. I feel it is obvious that you disagree with the outcome, but I don't think it's worth continually revisiting this subject. Separate orthogonal tools would be the result of applying the Unix philosophy to implementing software to manage Zephyr's user workflows. That is well understood. The Unix philosophy has advantages and disadvantages which are discussed ad nauseam in numerous places and I don't think it's worth repeating them as if this were still a debate in this context. Can we move on? |
Agreeing with @mbolivar here, so no need to repeat him on that part.
Nope, they are referred to from CMake and are defined as custom targets, found in Note the python script folder, those are already Furthermore I think it makes sense to have this in the Those independent tools can be maintained without needing to checkout |
Alright, so we're adding a That's a legit question. I'm not trying to be difficult, but I just don't get it. We obviously are adding a This isn't some Unix purism thing to me. I just don't get why we decided to suddenly start putting everything new into a single command. Do we have any criteria for what goes in the I think we need to avoid confusing West-the-new-hotness with the @tejlmand I was thinking you could just do something like |
Rough and consensus-driven, but yes: it belongs in West if it's a core user workflow. "Get the code, keep it up to date" passes this test. "Run and debug code on my target" clearly does as well. This is like awscli for zephyr. |
Well, to me, this seems to have been discussed very early in the phase of creating stand-alone
yep it does. But when having
and then the build system (being cmake/ninja, cmake/make, or something else in future), is just a build system. |
@mbolivar @tejlmand @ulfalizer Let me settle this once and for all. The scope of the tool has been described in an issue for a long time now, and we are not going to change it now. |
@carlescufi @tejlmand now that we've settled the design down a little bit, I think it might be okay to revisit this subject. Here is what we have left in west/src after moving the runners and build/flash/debug commands out:
I would like to propose the following layout as a way to merge the bootstrapper, "real" main, and built-in commands, along with a library-style API for other features:
In particular:
|
I'm calling this a bug as the lack of even stable |
This settles the "one single command" CLI question. I hope the internal implementation, APIs and documentation will keep preserving as much isolation as possible between individual tools and the many benefits of software modularity; not the least troubleshooting and maintenance. I also hope the number of "apparently circular" dependencies like |
This relates to issue zephyrproject-rtos#38, the TL;DR of which is that we've never gotten around to properly separating west's application internals from its API in source code, and instead relied on documentation to spell out exactly what the API was that users could rely on. Let's start fixing that by moving everything users can't rely on into a new west.app. This includes everything in west.commands except the __init__ module, so we can just make that a new src/west/commands.py file and have it be a module instead of a package. This lets its pykwalify schema file, west-commands-schema.yml, sit next to it in src/west, which is flatter than before. The code changes in this commit (source lines changed, rather than files just getting moved around) are: - change the entry point in setup.py to west.app.main:main - change some imports in src/west/app/main.py to import from west.app instead of west.commands - add a new src/west/app/__init__.py, since we're not using namespace packages - changes in MANIFEST.in and test_help.py to reflect new paths - adjust some comments and docstrings This change makes the API divide clearer. This in turn exposes some problems with our use of west.log from west.manifest: 1. logging to stdout is a bad practice from a library 2. west.log also uses global state (which relates to zephyrproject-rtos#149 also) which non-command-line users won't have set up properly (this is an example of why zephyrproject-rtos#1 is true) Subsequent commits will move to only using west.log from within west.app.* and the existing deprecated west.build and west.cmake APIs, which users should be migrating away from anyway. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This relates to issue #38, the TL;DR of which is that we've never gotten around to properly separating west's application internals from its API in source code, and instead relied on documentation to spell out exactly what the API was that users could rely on. Let's start fixing that by moving everything users can't rely on into a new west.app. This includes everything in west.commands except the __init__ module, so we can just make that a new src/west/commands.py file and have it be a module instead of a package. This lets its pykwalify schema file, west-commands-schema.yml, sit next to it in src/west, which is flatter than before. The code changes in this commit (source lines changed, rather than files just getting moved around) are: - change the entry point in setup.py to west.app.main:main - change some imports in src/west/app/main.py to import from west.app instead of west.commands - add a new src/west/app/__init__.py, since we're not using namespace packages - changes in MANIFEST.in and test_help.py to reflect new paths - adjust some comments and docstrings This change makes the API divide clearer. This in turn exposes some problems with our use of west.log from west.manifest: 1. logging to stdout is a bad practice from a library 2. west.log also uses global state (which relates to #149 also) which non-command-line users won't have set up properly (this is an example of why #1 is true) Subsequent commits will move to only using west.log from within west.app.* and the existing deprecated west.build and west.cmake APIs, which users should be migrating away from anyway. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fixed in #358 |
from the user point of view
west
is the go-to tool intended for repository handling, building, flashing etc.Internally,
west
can be seen as:With the initial version, v.0.1.0 out and progress is made on v0.2.0, it is important to keep track of the future direction.
This includes, but is not limited to:
west
do we expect other would re-use ?The text was updated successfully, but these errors were encountered: