-
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
Conversation
I was thinking about the setup we use in napari. The installers basically ship:
If we merge this PR, napari shortcuts will always have that env name appended, which might be redundant (we will see something like Something like: ...
"name": "Spyder 4.0 {{ ENV_NAME_IF_NOT_BASE }}",
... Too hacky? Alternatively, we could add a new field |
We are talking with @mrclary to do exactly the same for Spyder! So, if you decide to implement that directly here, we wouldn't need to in our |
I don't think it's too hacky. This is exactly the behavior that many seem to want. We could alternatively also define the |
I'm sorry, @ccordoba12, I need to clarify that this is not exactly what we are trying to do with Spyder. What we are doing for Spyder is setting the name of the shortcut as I do not support this PR as it currently is because I don't think These would not really do anything for Spyder since |
I think a separate menu item is a better way to go about this. A separate placeholder would still require implicit
would either have to implicitly insert parentheses or would just insert the name without them. Adding an optional |
The more I think about this the less I see a way out, hah. I'm not sure I like the idea of adding more items to an implementation agnostic schema, when those items are kind of implementation specific... I need to think more about this 😬 |
If they do not have a concept like this, they don't have to use these, i.e., |
Ok, sorry for the misunderstanding.
You're probably right: any project that depends on |
What if we extend ...
"name": {
"prefix_is_base": "Something",
"prefix_is_not_base": "Something (else)"
},
... I think I like that better, and it's a bit more future proof because if there are more use cases in the future, we won't have to add yet another key, only more conditions to the |
@jaimergp, I like this idea. |
Sorry for leaving this dormant - just getting back to this after a long leave of absence. I do like the mapping idea, but we need to make this backwards compatible. Or do we want to have any string be a potential mapping? I concur with "default" and "base_env" even though I'd probably want to be more explicit and use "base_environment". |
We should be able to accept a string (original behaviour) or a mapping of conditions to string. Since we have total control over condition keys, we can either get creative with I don't care much as long as things are documented nicely. |
Co-authored-by: jaimergp <[email protected]>
name = self.metadata["name"].get("target_environment_is_base", "") | ||
if not name: | ||
raise KeyError("Cannot parse `name` from dictionary representation.") | ||
self.metadata["name"] = name |
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.
At this point we have not rendered the {{ variables }}
, right?
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.
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.
Co-authored-by: jaimergp <[email protected]>
…nto env-name-shortcut
menuinst/platforms/base.py
Outdated
@@ -75,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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be false-y? 🤔 I think we don't need the or ""
part, right?
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.
Now that I look at it again, I don't think so. I guess I was overly cautious here.
This will need a CEP update. |
Description
menuinst v1
added the environment name to shortcuts when the packages are installed outside the base environment.This behavior appears to be intended for Windows:menuinst/menuinst/platforms/win.py
Line 201 in 1df31c6
However,env_name
is never set. This PR setsenv_name
outside the base environment.Add a feature to re-enable this behavior by expanding the schema. Contrary to v1, this is an option now and not standard behavior to allow for more flexibility.
Checklist - did you ...
news
directory (using the template) for the next release's release notes?