Skip to content
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

Add VS Code config for SAGE_ROOT/venv #30677

Closed
tobiasdiez opened this issue Sep 28, 2020 · 53 comments
Closed

Add VS Code config for SAGE_ROOT/venv #30677

tobiasdiez opened this issue Sep 28, 2020 · 53 comments

Comments

@tobiasdiez
Copy link
Contributor

Its recommended to check in some VS Code config files (which makes it easier for new users to start developing).

We configure it to use the Sage venv via the configure-generated symlink SAGE_ROOT/venv (from #32442)

The .gitignore configuration follows https://www.toptal.com/developers/gitignore/api/python,visualstudiocode

CC: @mkoeppe

Component: build

Keywords: sd111

Author: Tobias Diez

Branch/Commit: 0eadcd1

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/30677

@tobiasdiez tobiasdiez added this to the sage-9.2 milestone Sep 28, 2020
@tobiasdiez

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 3, 2020

Changed commit from 656f85c to caf88ef

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 3, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

caf88efAdd config for unittests

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Oct 24, 2020
@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 6, 2020

comment:5

Hoping we can make progress on this ticket this week - https://wiki.sagemath.org/days111

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 6, 2020

Changed keywords from none to sd111

@kliem
Copy link
Contributor

kliem commented Dec 9, 2020

Author: Tobias Diez

@dimpase
Copy link
Member

dimpase commented Dec 12, 2020

comment:7

rebase is needed

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 11, 2021

comment:8

This ticket could also be retargeted to #31377, using local/ as the venv instead of src/.venv.

@tobiasdiez
Copy link
Contributor Author

comment:9

Replying to @mkoeppe:

This ticket could also be retargeted to #31377, using local/ as the venv instead of src/.venv.

The nice thing about pipenv is that one can specify python packages for development, and so install e.g. pytest and linters in the virtual environment. VS code picks these up, and complains if they are not installed otherwise. Does sage's build setup has a similar flag to install dev packages?

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 18, 2021

comment:10

In the current model, the linters are installed by tox into the tox environment.

@dimpase
Copy link
Member

dimpase commented Mar 10, 2021

comment:11

needs a rebase

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 24, 2021

comment:12

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Mar 24, 2021
@mkoeppe
Copy link
Contributor

mkoeppe commented Jul 19, 2021

comment:13

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 28, 2021

comment:14

This should be redone without dep on #30371

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title Add VS Code config for inplace venv Add VS Code config for SAGE_ROOT/venv Oct 3, 2021
@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 3, 2021

Changed dependencies from #30371 to #32442

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 25, 2021

comment:28

What is the work issue "config test discovery"?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

656f85cAdd VS code config for inplace venv
caf88efAdd config for unittests
208d2faMerge branch 'public/build/vscode' of git://trac.sagemath.org/sage into public/build/vscode
9bc5815Merge branch 'develop' of git://github.com/sagemath/sage into public/build/vscode
9bcead8Add config to discover tests

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2021

Changed commit from 87719de to 9bcead8

@tobiasdiez
Copy link
Contributor Author

comment:30

Replying to @mkoeppe:

What is the work issue "config test discovery"?

Adding config for VS code testing feature: https://code.visualstudio.com/docs/python/testing.
I've added this now.

@tobiasdiez
Copy link
Contributor Author

Changed work issues from config test discovery to none

@tobiasdiez
Copy link
Contributor Author

comment:32

It would be nice if this could be reviewed (and merged) relatively soon.

@dimpase
Copy link
Member

dimpase commented Nov 18, 2021

comment:33

Does it mean to work together with a particular VSCode plugin?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 18, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

89b8754Fix exit code for pytest in case of no matched files
278f0e0Merge branch 'public/build/vscode' of trac.sagemath.org:sage into public/build/vscode
df1534cAdd extension recommendations

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 18, 2021

Changed commit from 9bcead8 to df1534c

@tobiasdiez
Copy link
Contributor Author

comment:35

Replying to @dimpase:

Does it mean to work together with a particular VSCode plugin?

With the "standard" python extension https://marketplace.visualstudio.com/items?itemName=ms-python.python, which I've now also added as "recommendation" (vscode will ask once when a workspace is opened for the first time to install these recommended extensions).

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 18, 2021

Changed commit from df1534c to 0eadcd1

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 18, 2021

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

0eadcd1Add VS Code config for SAGE_ROOT/venv

@dimpase
Copy link
Member

dimpase commented Nov 19, 2021

comment:37

I got it installed, and what should I try? I don't use vscode for developent, so it's pretty unclear.

Incidentally, I saw that vscode has support for jupyter notebooks now, but the kernels it knows are the Python only ones. Should it know - be able to discover somehow - Sage's jupyter kernel, too?

@tobiasdiez
Copy link
Contributor Author

comment:38

It should "just work". This ticket is not doing much, only adding basic configs so that vs code is automatically discovering the right things. In particular:

Coding you still have to do yourself though ;) (or install https://copilot.github.com/)

But you are right, adding documentation for how to use vs code might be a good follow-up. The same for the jupyter support - I had a quick look and it seems to work in principle but still have to figure out the details.

@dimpase
Copy link
Member

dimpase commented Nov 19, 2021

comment:39

Replying to @tobiasdiez:

It should "just work". This ticket is not doing much, only adding basic configs so that vs code is automatically discovering the right things. In particular:

I know it's hard to explain in text - but I have trouble understanding how to do the
1st 2 items. (we can have a video call via google meet or so, so that I can see the screen and
the cursor...)

By It should "just work" - do you mean the jupyter thing?
Well, I can browse (and view, nicely) Sage's jupyter notebooks in vscode, but not run, as I don't see a way to select the right kernel, and it's now shown in the menu.

Coding you still have to do yourself though ;) (or install https://copilot.github.com/)

I sometimes use vscode as an IDE to write markdown or LaTeX (or Lean :-)), but never for other things, so far.

@tobiasdiez
Copy link
Contributor Author

comment:40

For the virtual env, you should have something like Pytohn 3.8.10 ('venv': venv) in the lower left corner

With this ticket, this is now the default and can be changed as described in https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment.

For testing, vscode should now look for pytests instead of the "Configure Python tests" window that you get normally after activating the test icon (with the red border)

For jupyter, it may work if you have jupter installed in the sage venv and then select it as the kernel as described here https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook.
There are also config options to do this by default, but I've not yet looked into this.
For basic things, this is working for me, but I'm not sure about e.g. sage syntax etc.

@dimpase
Copy link
Member

dimpase commented Nov 21, 2021

comment:41

OK, I'm getting somewhere with Jupyter.

This time I started with opening the SAGE_ROOT "folder", clicked on "trust the author", and only after that, opened a Sage Jupyter notebook.

Now, the Sage kernel shows up in the kernel list, and if I choose it, then after a while (~10 sec or more, I thought it just hangs, at first) it loads and everything works.
Opening it next time is a bit faster. (I'm on a slow net now, and maybe it's phoning back?!).

Anyhow, these details (about opening folger and blessing it) should be added to wiki, or docs, something like this.

Otherwise, good!

@dimpase
Copy link
Member

dimpase commented Nov 21, 2021

Reviewer: Dima Pasechnik

@dimpase
Copy link
Member

dimpase commented Nov 21, 2021

Changed dependencies from #32442 to none

@dimpase
Copy link
Member

dimpase commented Nov 21, 2021

comment:43

It should be adverticed in the release wiki, we probably will then get a lot of feedback.

@tobiasdiez
Copy link
Contributor Author

comment:44

Thanks for the review.

I agree that it would be helpful to have a how to get started with vscode, especially for beginners. But I couldn't any similar docs for other Ides either. What are the conventions, and is it okay to "advertise" vscode by adding it to the docs?

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 21, 2021

comment:45

This would be a very valuable contribution. We have a meta-ticket #30500 for these kinds of things, but so far nobody has done the work.

@dimpase
Copy link
Member

dimpase commented Nov 21, 2021

comment:46

Replying to @tobiasdiez:

Thanks for the review.

I agree that it would be helpful to have a how to get started with vscode, especially for beginners. But I couldn't any similar docs for other Ides either. What are the conventions, and is it okay to "advertise" vscode by adding it to the docs?

as vscode is getting dominant, hiding from the public that we have these binding in Sage is kind of silly.

we do have binding for jupyter(lab), and something for emacs too, so it's not setting up a precedent.

@vbraun
Copy link
Member

vbraun commented Jan 1, 2022

Changed branch from public/build/vscode to 0eadcd1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants