Skip to content

Xonsh Support - #1206

Merged
gaborbernat merged 25 commits into
pypa:masterfrom
scopatz:xonsh
Nov 6, 2018
Merged

gaborbernat merged 25 commits into
pypa:masterfrom
scopatz:xonsh

Conversation

@scopatz

@scopatz scopatz commented Sep 28, 2018

Copy link
Copy Markdown

This aims to add xonsh support to virtualenv.

I am not sure how to generate the top-level ACTIVATE_XSH variable in virtualenv.py, and this probably needs to be tested, but otherwise, should be good to go!

Feedback welcome!

@scopatz

scopatz commented Sep 28, 2018

Copy link
Copy Markdown
Author

CC @pganssle

@scopatz

scopatz commented Sep 28, 2018

Copy link
Copy Markdown
Author

And feel free to push directly to this branch.

@gaborbernat

Copy link
Copy Markdown
Contributor

Tests?

@scopatz

scopatz commented Sep 28, 2018

Copy link
Copy Markdown
Author

@gaborbernat - any recommendations on how to add tests?

@scopatz

scopatz commented Sep 28, 2018

Copy link
Copy Markdown
Author

@gaborbernat - also I know this will fail because of the ACTIVATE_XSH issue.

@pganssle

Copy link
Copy Markdown
Member

This seems like the kind of thing where xonsh needs to be added to the matrix in Travis (i.e. all tests should be run using xonsh as the shell), though I don't know if tox will handle that as expected..

@gaborbernat

Copy link
Copy Markdown
Contributor

Let me have a better look at things and I'll get back to you in a few weeks with some proper advice.

@pfmoore

pfmoore commented Sep 29, 2018

Copy link
Copy Markdown
Member

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.

@pganssle

Copy link
Copy Markdown
Member

@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.

@gaborbernat

Copy link
Copy Markdown
Contributor

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.

@pfmoore

pfmoore commented Sep 29, 2018

Copy link
Copy Markdown
Member

If the timeline for "provide hooks to allow a 'xonsh support' plugin" is on the order of a few months,

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).

the question of finding a domain expert is somewhat moot

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 think let's add this now. In parallel we can then afterwards come up with an extensible API

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.

@scopatz

scopatz commented Oct 2, 2018

Copy link
Copy Markdown
Author

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.

Comment thread virtualenv.py Outdated
'activate.bat': ACTIVATE_BAT,
'deactivate.bat': DEACTIVATE_BAT,
'activate.ps1': ACTIVATE_PS,
'activate.xsh': ACTIVATE_XSH,

@pganssle pganssle Oct 18, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pganssle - you mentioned you had this working somewhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scopatz I made a PR against your branch here

@pganssle

Copy link
Copy Markdown
Member

I'm not seeing any shell-specific tests in the test suite. How are these intended to be tested?

@scopatz

scopatz commented Oct 19, 2018

Copy link
Copy Markdown
Author

Yeah, I was just looking at that. I can certainly translate test_activate.sh to xonsh if you would like.

@gaborbernat
gaborbernat force-pushed the master branch 6 times, most recently from 2b3f876 to 9dfcb43 Compare October 27, 2018 11:31
@scopatz

scopatz commented Oct 31, 2018

Copy link
Copy Markdown
Author

I have updated this, resolving conflicts from master

@gaborbernat

Copy link
Copy Markdown
Contributor

thanks can you add a test similar to what we have for powerscript for activation?

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/virtualenv.py Resolved
Comment thread virtualenv_embedded/activate.xsh Resolved
@scopatz

scopatz commented Nov 6, 2018

Copy link
Copy Markdown
Author

I think that this is finally all green and ready to go!

@gaborbernat

Copy link
Copy Markdown
Contributor

@scopatz just one more thing, let's add a changelog entry announcing it 🎉

@scopatz

scopatz commented Nov 6, 2018

Copy link
Copy Markdown
Author

@gaborbernat, sure thing! Where should I make those edits at? docs/changes.rst?

@gaborbernat

Copy link
Copy Markdown
Contributor

@schopatz yes

Comment thread setup.py Resolved
Comment thread virtualenv_embedded/activate.xsh Resolved
Comment thread setup.py Resolved
Comment thread src/virtualenv.py Resolved
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this test passing under python 2 🤔 if xonosh cannot run with it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test seems to be appropriately skipped on linux, windows, and mac on Python 2.7. Are you seeing something different?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Does it look good now?

@scopatz

scopatz commented Nov 6, 2018

Copy link
Copy Markdown
Author

The azure failure is an report_coverage Job failure, which is unrelated to anything I have done here, I believe.

@gaborbernat
gaborbernat merged commit 3fbfeb7 into pypa:master Nov 6, 2018
@scopatz

scopatz commented Nov 6, 2018

Copy link
Copy Markdown
Author

Woohoo! Thanks for all the help here!

@scopatz
scopatz deleted the xonsh branch November 6, 2018 23:17
@gaborbernat gaborbernat added this to the 16.2 milestone Dec 24, 2018
@anki-code anki-code mentioned this pull request Apr 15, 2026
5 tasks done
gaborbernat added a commit that referenced this pull request Apr 19, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants