Skip to content

Commit b1bc2b1

Browse files
committed
project: stop defaulting west init to upstream Zephyr
Stop defaulting `west init` to `west init -m https://github.com/zephyrproject-rtos/zephyr/`. The argument must be passed explicitly. Thanks to argparse, a bare `west init` now errors like this: ``` usage: west init [-m URL] [--mr REVISION] [--mf FILE] [-o=GIT_CLONE_OPTION] [directory] west init -l [--mf FILE] directory west init: error: one of the arguments -m/--manifest-url -l/--local is required ``` This is part of the wider effort to make west independent from Zephyr: #246 This should also help nudge people towards creating their own manifests, which will mitigate Zephyr's "tragedy of the commons" where many people want their stuff to be present the default upstream manifest, while also complaining that the default is way too big and slow (currently around 10 Gigabytes) - zephyrproject-rtos/zephyr#91061 - zephyrproject-rtos/zephyr#108783 (comment) Signed-off-by: Marc Herbert <Marc.Herbert@gmail.com>
1 parent 1e42087 commit b1bc2b1

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

README.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ By default the manifest file is named ``west.yml``.
2929
You use ``west init`` to set up this directory, then ``west update`` to fetch
3030
and/or update the repositories named in the manifest.
3131

32-
By default, west uses `upstream Zephyr's manifest file
33-
<https://github.com/zephyrproject-rtos/zephyr/blob/main/west.yml>`_, but west
34-
doesn't care if the manifest repository is zephyr or not. You can and are
35-
encouraged to make your own manifest repositories to meet your needs.
32+
West used to default to `upstream Zephyr's manifest file
33+
<https://github.com/zephyrproject-rtos/zephyr/blob/main/west.yml>`_.
34+
You are still able and will always be able to use this manifest but you
35+
are now required to pass it explicitly and, you are more encouraged than
36+
before to make your own manifest repositories to meet your particular needs.
3637

3738
For more details, see the `West (Zephyr's meta-tool)
3839
<https://docs.zephyrproject.org/latest/develop/west/index.html>`_ in the Zephyr
@@ -41,12 +42,12 @@ documentation.
4142
Example usage using the upstream manifest file::
4243

4344
mkdir zephyrproject && cd zephyrproject
44-
west init
45+
west init -m https://github.com/zephyrproject-rtos/zephyr/
4546
west update
4647

4748
What just happened:
4849

49-
- ``west init`` clones the upstream *west manifest* repository, which in this
50+
- ``west init -m ...`` clones the upstream *west manifest* repository, which in this
5051
case is the zephyr repository. The manifest repository contains ``west.yml``,
5152
a YAML description of the Zephyr installation, including Git repositories and
5253
other metadata.

src/west/app/project.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def __init__(self):
235235
super().__init__(
236236
'init',
237237
'create a west workspace',
238-
f'''\
238+
'''\
239239
Creates a west workspace.
240240
241241
With -l, creates a workspace around an existing local repository;
@@ -244,9 +244,9 @@ def __init__(self):
244244
245245
With -m, clones the repository at that URL and uses it as the
246246
manifest repository. If --mr is not given, the remote's default
247-
branch will be used, if it exists.
247+
branch will be used, if it exists. Example:
248248
249-
With neither, -m {MANIFEST_URL_DEFAULT} is assumed.
249+
west init -m https://github.com/my_project/my_manifest.git/
250250
251251
Warning: 'west init' renames and/or deletes temporary files inside the
252252
workspace being created. This fails on some filesystems when some
@@ -280,8 +280,9 @@ def do_add_parser(self, parser_adder):
280280
)
281281

282282
# Remember to update the usage if you modify any arguments.
283+
clone_or_not = parser.add_mutually_exclusive_group(required=True)
283284

284-
parser.add_argument(
285+
clone_or_not.add_argument(
285286
'-m',
286287
'--manifest-url',
287288
help='''manifest repository URL to clone;
@@ -306,7 +307,7 @@ def do_add_parser(self, parser_adder):
306307
parser.add_argument(
307308
'--mf', '--manifest-file', dest='manifest_file', help='manifest file name to use'
308309
)
309-
parser.add_argument(
310+
clone_or_not.add_argument(
310311
'-l',
311312
'--local',
312313
action='store_true',
@@ -416,7 +417,7 @@ def bootstrap(self, args) -> Path:
416417
topdir = Path(abspath(args.directory or os.getcwd()))
417418
self.banner('Initializing in', topdir)
418419

419-
manifest_url = args.manifest_url or MANIFEST_URL_DEFAULT
420+
manifest_url = args.manifest_url
420421
if args.manifest_rev:
421422
# This works with tags, too.
422423
branch_opt = ['--branch', args.manifest_rev]
@@ -2658,9 +2659,6 @@ def projects_unknown(manifest, projects):
26582659
# Top-level west directory, containing west itself and the manifest.
26592660
WEST_DIR = util.WEST_DIR
26602661

2661-
# Default manifest repository URL.
2662-
MANIFEST_URL_DEFAULT = 'https://github.com/zephyrproject-rtos/zephyr'
2663-
26642662
#
26652663
# Other shared globals.
26662664
#

tests/test_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ def test_init_again(west_init_tmpdir):
19221922
expected_msg = f'FATAL ERROR: already initialized in {west_init_tmpdir}'
19231923

19241924
# A bare `init` defaults to cloning -m http://zephyrproject/zephyr
1925-
exc, stderr = cmd_raises('init', SystemExit, cwd=west_init_tmpdir)
1925+
exc, stderr = cmd_raises(['init', '-m', 'bogus_url'], SystemExit, cwd=west_init_tmpdir)
19261926
assert exc.value.code == 1
19271927
assert expected_msg in stderr
19281928

0 commit comments

Comments
 (0)