-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support different names for base and non-base environment #180
Changes from 32 commits
b9e7cfa
1f9bbd4
03b40fd
5f0e051
42e769a
7272333
2af02fb
0e7113a
4a7be20
6f7300b
d3d6d9c
3d0e36e
7b83395
c223f5f
8f39521
422dbb8
1de5f43
1909ef0
46e7795
932f80c
c6730eb
ca9f608
dce5666
bc92af7
1d5f1be
ca52e2d
9b87330
0ab1e24
8516d46
fef15d0
2249a94
9588b89
f186e8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,10 @@ def __init__( | |
self.prefix = Path(prefix) | ||
self.base_prefix = Path(base_prefix) | ||
|
||
self.env_name = None | ||
if self.prefix.samefile(self.base_prefix): | ||
self.env_name = "base" | ||
else: | ||
self.env_name = self.prefix.name | ||
marcoesters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def create(self) -> List[Path]: | ||
raise NotImplementedError | ||
|
@@ -72,7 +75,7 @@ def placeholders(self) -> Dict[str, str]: | |
"DISTRIBUTION_NAME": self.base_prefix.name, | ||
"BASE_PYTHON": str(self.base_prefix / "bin" / "python"), | ||
"PREFIX": str(self.prefix), | ||
"ENV_NAME": self.prefix.name, | ||
"ENV_NAME": self.env_name or "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be false-y? 🤔 I think we don't need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that I look at it again, I don't think so. I guess I was overly cautious here. |
||
"PYTHON": str(self.prefix / "bin" / "python"), | ||
"MENU_DIR": str(self.prefix / "Menu"), | ||
"BIN_DIR": str(self.prefix / "bin"), | ||
|
@@ -138,6 +141,14 @@ def __init__(self, menu: Menu, metadata: dict): | |
self.menu = menu | ||
self._data = self._initialize_on_defaults(metadata) | ||
self.metadata = self._flatten_for_platform(self._data) | ||
if isinstance(self.metadata["name"], dict): | ||
if self.menu.prefix.samefile(self.menu.base_prefix): | ||
name = self.metadata["name"].get("target_environment_is_base", "") | ||
else: | ||
name = self.metadata["name"].get("target_environment_is_not_base", "") | ||
if not name: | ||
raise ValueError("Cannot parse `name` from dictionary representation.") | ||
self.metadata["name"] = name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point we have not rendered the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct. The tests for a dictionary representation of the name would have failed by then, so even if code changes render the name at that point, the tests will catch that. |
||
|
||
@property | ||
def location(self) -> Path: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Enhancements | ||
|
||
* Support different name for shortcuts within and outside base environment (support v1 behavior). (#180) | ||
|
||
### Bug fixes | ||
|
||
* <news item> | ||
|
||
### Deprecations | ||
|
||
* <news item> | ||
|
||
### Docs | ||
|
||
* <news item> | ||
|
||
### Other | ||
|
||
* <news item> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"$id": "https://schemas.conda.io/menuinst-1.schema.json", | ||
"menu_name": "Package", | ||
"menu_items": [ | ||
{ | ||
"name": { | ||
"target_environment_is_base": "A", | ||
"target_environment_is_not_base": "A_not_in_base" | ||
}, | ||
"description": "This will echo environment variables for test purposes", | ||
"icon": null, | ||
"command": [ | ||
"echo", | ||
"A" | ||
], | ||
"platforms": { | ||
"win": {}, | ||
"linux": {}, | ||
"osx": {} | ||
} | ||
}, | ||
{ | ||
"name": "B", | ||
"description": "This will echo environment variables for test purposes", | ||
"icon": null, | ||
"command": [ | ||
"echo", | ||
"B" | ||
], | ||
"platforms": { | ||
"win": {}, | ||
"linux": {}, | ||
"osx": {} | ||
} | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of non-conda implementations of the schema (where there's no "base" environment, like pixi or micromamba), and whether they'll have to deal with these semantics. They'll probably ignore
*_is_base
, but will have to handle*_is_not_base
.In a way, it looks to me that
target_environment_is_not_base
is the default case, whiletarget_environment_is_base
seems to be a special case in the grand scheme of things.Should we have this as
default
andtarget_environment_is_base
, instead? I know I'm bikeshedding a bit, but I wanted to make sure that other angles are considered.cc @wolfv for awareness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
default
is ambiguous and what's the most common use case for micromamba and pixi is not necessarily the use case for others. I would say that forconda
, the base environment case is much more common since the console shortcut, e.g., is installed into the base environment via the installer.I think explicit is better than implicit.