summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/docs/environments.rst10
-rw-r--r--lib/spack/spack/cmd/develop.py21
-rw-r--r--lib/spack/spack/test/cmd/develop.py6
-rw-r--r--var/spack/repos/builtin.mock/packages/mpich/package.py1
4 files changed, 25 insertions, 13 deletions
diff --git a/lib/spack/docs/environments.rst b/lib/spack/docs/environments.rst
index f2eb0fa9a0..eec185eab8 100644
--- a/lib/spack/docs/environments.rst
+++ b/lib/spack/docs/environments.rst
@@ -425,9 +425,13 @@ Developing Packages in a Spack Environment
The ``spack develop`` command allows one to develop Spack packages in
an environment. It requires a spec containing a concrete version, and
-will configure Spack to install the package from local source. By
-default, it will also clone the package to a subdirectory in the
-environment. This package will have a special variant ``dev_path``
+will configure Spack to install the package from local source.
+If a version is not provided from the command line interface then spack
+will automatically pick the highest version the package has defined.
+This means any infinity versions (``develop``, ``main``, ``stable``) will be
+preferred in this selection process.
+By default, ``spack develop`` will also clone the package to a subdirectory in the
+environment for the local source. This package will have a special variant ``dev_path``
set, and Spack will ensure the package and its dependents are rebuilt
any time the environment is installed if the package's local source
code has been modified. Spack's native implementation to check for modifications
diff --git a/lib/spack/spack/cmd/develop.py b/lib/spack/spack/cmd/develop.py
index 0a9b7d1387..1025b1bb69 100644
--- a/lib/spack/spack/cmd/develop.py
+++ b/lib/spack/spack/cmd/develop.py
@@ -85,8 +85,14 @@ def _retrieve_develop_source(spec: spack.spec.Spec, abspath: str) -> None:
def develop(parser, args):
+ # Note: we could put develop specs in any scope, but I assume
+ # users would only ever want to do this for either (a) an active
+ # env or (b) a specified config file (e.g. that is included by
+ # an environment)
+ # TODO: when https://github.com/spack/spack/pull/35307 is merged,
+ # an active env is not required if a scope is specified
+ env = spack.cmd.require_active_env(cmd_name="develop")
if not args.spec:
- env = spack.cmd.require_active_env(cmd_name="develop")
if args.clone is False:
raise SpackError("No spec provided to spack develop command")
@@ -116,16 +122,18 @@ def develop(parser, args):
raise SpackError("spack develop requires at most one named spec")
spec = specs[0]
+
version = spec.versions.concrete_range_as_version
if not version:
- raise SpackError("Packages to develop must have a concrete version")
+ # look up the maximum version so infintiy versions are preferred for develop
+ version = max(spec.package_class.versions.keys())
+ tty.msg(f"Defaulting to highest version: {spec.name}@{version}")
spec.versions = spack.version.VersionList([version])
# If user does not specify --path, we choose to create a directory in the
# active environment's directory, named after the spec
path = args.path or spec.name
if not os.path.isabs(path):
- env = spack.cmd.require_active_env(cmd_name="develop")
abspath = spack.util.path.canonicalize_path(path, default_wd=env.path)
else:
abspath = path
@@ -149,13 +157,6 @@ def develop(parser, args):
_retrieve_develop_source(spec, abspath)
- # Note: we could put develop specs in any scope, but I assume
- # users would only ever want to do this for either (a) an active
- # env or (b) a specified config file (e.g. that is included by
- # an environment)
- # TODO: when https://github.com/spack/spack/pull/35307 is merged,
- # an active env is not required if a scope is specified
- env = spack.cmd.require_active_env(cmd_name="develop")
tty.debug("Updating develop config for {0} transactionally".format(env.name))
with env.write_transaction():
if args.build_directory is not None:
diff --git a/lib/spack/spack/test/cmd/develop.py b/lib/spack/spack/test/cmd/develop.py
index 202e165165..c0cbb003ec 100644
--- a/lib/spack/spack/test/cmd/develop.py
+++ b/lib/spack/spack/test/cmd/develop.py
@@ -65,6 +65,12 @@ class TestDevelop:
develop("--no-clone", "-p", str(tmpdir), "mpich@1.0")
self.check_develop(e, spack.spec.Spec("mpich@=1.0"), str(tmpdir))
+ def test_develop_no_version(self, tmpdir):
+ env("create", "test")
+ with ev.read("test") as e:
+ develop("--no-clone", "-p", str(tmpdir), "mpich")
+ self.check_develop(e, spack.spec.Spec("mpich@=main"), str(tmpdir))
+
def test_develop(self):
env("create", "test")
with ev.read("test") as e:
diff --git a/var/spack/repos/builtin.mock/packages/mpich/package.py b/var/spack/repos/builtin.mock/packages/mpich/package.py
index 08338033a9..4c87d6932f 100644
--- a/var/spack/repos/builtin.mock/packages/mpich/package.py
+++ b/var/spack/repos/builtin.mock/packages/mpich/package.py
@@ -16,6 +16,7 @@ class Mpich(Package):
variant("debug", default=False, description="Compile MPICH with debug flags.")
+ version("main", branch="main", git="https://github.com/pmodels/mpich")
version("3.0.4", md5="9c5d5d4fe1e17dd12153f40bc5b6dbc0")
version("3.0.3", md5="0123456789abcdef0123456789abcdef")
version("3.0.2", md5="0123456789abcdef0123456789abcdef")