Repository navigation
Xonsh Support - #1206
Xonsh Support#1206
Conversation
|
CC @pganssle |
|
And feel free to push directly to this branch. |
|
Tests? |
|
@gaborbernat - any recommendations on how to add tests? |
|
@gaborbernat - also I know this will fail because of the |
|
This seems like the kind of thing where |
|
Let me have a better look at things and I'll get back to you in a few weeks with some proper advice. |
|
I'm not sure we should add activate scripts for yet more shells. It's already hard enough to find people with sufficient expertise to maintain feature parity across all the shells we do support (sh, csh, fish, cmd, powershell). Rather than this, would anyone be interested in a PR to allow users to locally customise the activation scripts installed in a new virtualenv? I'd be willing to write such a PR if it meant that we focused on only supporting a limited number of shells (and basic functionality for them) in the supplied scripts, leaving users with different needs to use the customisation option to handle them. |
|
@pfmoore I think there's a pretty strong case for including xonsh in the list of supported shells considering the nature of xonsh as a "shell but with Python". Not to volunteer him or anything, but I think that given that @scopatz is a xonsh maintainer and an active participant in the Python community, the question of finding a domain expert is somewhat moot in this case. That said, I do agree that it doesn't necessarily scale to have to maintain support for every shell in the upstream package, so providing some clear hooks for "shell support plugins" (and possibly breaking out all current shell support into individual plugin packages maintained by domain experts) seems like a net win. If the timeline for "provide hooks to allow a 'xonsh support' plugin" is on the order of a few months, then I think it probably makes sense to wait. If the timeline is on the order of a year or more, I think it makes sense in the short term to add xonsh as a supported shell and then possibly use it as a test case for moving support from within virtualenv to a separate package. |
|
I think let's add this now. In parallel we can then afterwards come up with an extensible API people can use to add their own, and then we can deprecate all this. |
I have an approach in mind, so it's more like a matter of a week or two. However, I'm not thinking of anything elaborate like plugin support (at least not what I imagine by that) but rather just something to let users add custom scripts of their own. I wasn't proposing anything that would allow an "official" xonsh plugin that could be distributed centrally and would link into the user's virtualenv installation. (That's not to say that isn't something that someone could develop, just it's not what I was proposing).
My point was more that issues like #1166 and #1168 would be stuck needing to get input (and probably code) from all the different shell experts, otherwise we'd end up with different behaviour (which is the issue #1168 is flagging). That makes it harder to move on any of these types of issue (I'm generally against the approach of "let's fix the ones I know how to, and leave users of other environments to raise separate PRs to cover the rest").
I'm OK with that, I don't see the maintenance burden issue as a crisis, just something we should consider when making the decision. |
|
Hi All, thanks for your feedback. I am very happy to keep maintaining this (and not likely to go anywhere, as @pganssle points out 😉) I just need to know what to do here to get this to work. |
| 'activate.bat': ACTIVATE_BAT, | ||
| 'deactivate.bat': DEACTIVATE_BAT, | ||
| 'activate.ps1': ACTIVATE_PS, | ||
| 'activate.xsh': ACTIVATE_XSH, |
There was a problem hiding this comment.
I think ACTIVATE_XSH needs to actually be defined, though apparently all the others are defined here, which is some crazy nonsense I don't understand.
There was a problem hiding this comment.
The ACTIVATE_xxx variables hold base64-encoded copies of the actual activate scripts. They are embedded in the virtualenv.py script so that we don't need to ship them as separate files (the virtualenv_embedded directory isn't shipped as part of the wheel).
bin/rebuild-script.py rebuilds virtualenv.py from the files in the virtualenv_embedded directory. Some fiddling will be needed to add ACTIVATE_XSH to that mechanism (but I don't know precisely what).
There was a problem hiding this comment.
@pganssle - you mentioned you had this working somewhere?
Add base64-encoded xonsh script
|
I'm not seeing any shell-specific tests in the test suite. How are these intended to be tested? |
|
Yeah, I was just looking at that. I can certainly translate |
2b3f876 to
9dfcb43
Compare
|
I have updated this, resolving conflicts from master |
|
thanks can you add a test similar to what we have for powerscript for activation? |
gaborbernat
left a comment
There was a problem hiding this comment.
Also, run tox -e embed,fix_lint when you've made the changes to automatically update embedding and formatting. Add tests as showcased in https://github.com/pypa/virtualenv/blob/master/tests/activation/test_powershell_activation.py
|
I think that this is finally all green and ready to go! |
|
@scopatz just one more thing, let's add a changelog entry announcing it 🎉 |
|
@gaborbernat, sure thing! Where should I make those edits at? |
|
@schopatz yes |
| def test_activate_with_xonsh(tmpdir, monkeypatch): | ||
| monkeypatch.chdir(tmpdir) | ||
| home_dir, _, __, bin_dir = virtualenv.path_locations(str(tmpdir.join("env"))) | ||
| virtualenv.create_environment(home_dir, no_pip=True, no_setuptools=True, no_wheel=True) |
There was a problem hiding this comment.
how is this test passing under python 2 🤔 if xonosh cannot run with it
There was a problem hiding this comment.
The test seems to be appropriately skipped on linux, windows, and mac on Python 2.7. Are you seeing something different?
There was a problem hiding this comment.
Oh I understand, it's not installed on python 2.7 so it's skipped. This works by chance as https://github.com/pypa/virtualenv/blob/master/tests/lib/__init__.py#L14 should mean we never skip inside the CI 😮 please add some logic inside the needs_xonosh to always skip if xonosh is not installed.
|
The azure failure is an |
|
Woohoo! Thanks for all the help here! |
Hello @gaborbernat! In the Xonsh shell project, we’ve done a significant amount of groundwork ([*](xonsh/xonsh#6152)) and are now on the verge of releasing version 0.23.0, which is expected to be the most stable release in the project’s history. While working on this version, we took your previous [feedback](xonsh/xonsh#3689 (comment)) into account and implemented additional improvements. In light of this, and given the recurring requests for virtualenv support, I’d like to introduce an updated version of Xonsh support for virtualenv. Please take a look. Thanks! ------ - [x] ran the linter to address style issues (`tox -e fix`) - [x] wrote descriptive pull request text - [x] ensured there are test(s) validating the fix - [x] added news fragment in `docs/changelog` folder - [x] updated/extended the documentation ------ * cc xonsh/xonsh#6025 * сс xonsh/xonsh#4466 * cc #2160 * cc #1206 --------- Co-authored-by: 1 <[email protected]> Co-authored-by: anki-code <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bernát Gábor <[email protected]>
This aims to add xonsh support to virtualenv.
I am not sure how to generate the top-level
ACTIVATE_XSHvariable invirtualenv.py, and this probably needs to be tested, but otherwise, should be good to go!Feedback welcome!