sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.2k stars 413 forks source link

Add devcontainer.json for development with VS Code in a Docker container #33671

Closed mkoeppe closed 1 year ago

mkoeppe commented 2 years ago

https://code.visualstudio.com/docs/remote/containers

We add two new sections in the developer's guide: https://47f8b984ef964a5aa34147393fbdc32e0dde88ad--sagemath-tobias.netlify.app/developer/portability_testing.html#using-our-pre-built-docker-images-published-on-ghcr-io

We also set up devcontainer configurations for the CoCalc and computop/sage Docker images, as well as downstream distribution packaging of Sage.

Tested devcontainer.json of

Follow-ups:

Depends on #33873 Depends on #34352

CC: @tobiasdiez @dimpase @williamstein @culler @saraedum @kwankyu

Component: user interface

Author: Tobias Diez, Matthias Koeppe, Kwankyu Lee

Branch/Commit: 4affef2

Reviewer: Kwankyu Lee, Matthias Koeppe

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

mkoeppe commented 2 years ago

Description changed:

--- 
+++ 
@@ -1 +1 @@
-
+https://code.visualstudio.com/docs/remote/containers
mkoeppe commented 2 years ago

Description changed:

--- 
+++ 
@@ -1 +1,4 @@
 https://code.visualstudio.com/docs/remote/containers
+
+see also https://github.com/gitpod-io/gitpod/issues/7721
+
mkoeppe commented 2 years ago

Dependencies: #29536

tobiasdiez commented 2 years ago

Author: Tobias Diez

tobiasdiez commented 2 years ago

Commit: 85a7100

tobiasdiez commented 2 years ago

Changed dependencies from #29536 to none

tobiasdiez commented 2 years ago

Branch: public/build/devcontainer

tobiasdiez commented 2 years ago
comment:5

A basic devcontainer definition is now added for ubuntu systems.


New commits:

85a7100Add devcontainer for ubuntu
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 85a7100 to 11110ae

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

11110aeAdd bootstrap
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 11110ae to c5295e3

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

c5295e3enable-build-as-root
tobiasdiez commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,3 @@
 https://code.visualstudio.com/docs/remote/containers

-see also https://github.com/gitpod-io/gitpod/issues/7721
-
+Can be tested by starting a codespace at https://github.com/codespaces/new?hide_repo_select=true&ref=public%2Fbuild%2Fdevcontainer&repo=302607352&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json (might not be possible for everyone as codespaces is still in the test phase).
mkoeppe commented 2 years ago
comment:9

Thanks! That's a beginning. Why do you not use the full build (-with-targets)?

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from c5295e3 to 872c0c8

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

58e112abootstrap-conda: Use script package _develop instead of hardcoded list of dev tools; remove unused RECOMMENDED
21e06c5bootstrap-conda: Write an additional comment
4290b11Add pytest-xdist package
a365828build/pkgs/pytest/dependencies: Add missing dep
a2e396bbuild/pkgs/pytest_xdist/dependencies: Add missing dep
2ec0061Merge #33825
5857902build/pkgs/_develop/dependencies: Add pytest, pytest_xdist
2368adcbootstrap-conda: Write an additional comment (fixup)
0df31a9bootstrap-conda: Rewrite using fewer redirects
872c0c8.devcontainer: Generalize to other distros
mkoeppe commented 2 years ago

Changed author from Tobias Diez to Tobias Diez, Matthias Koeppe

mkoeppe commented 2 years ago

Dependencies: #33825

mkoeppe commented 2 years ago

Changed dependencies from #33825 to #33851

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 872c0c8 to 96bb5ad

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

8d7f7abMerge #33851
96bb5ad.devcontainer: Generalize to other distros
tobiasdiez commented 2 years ago
comment:14

Replying to @mkoeppe:

Thanks! That's a beginning. Why do you not use the full build (-with-targets)?

I didn't saw the point in that. In contrast to gitpod you don't know which version of sage the developer will use in the devcontainer, especially since devcontainer are cached by vscode until they are manually rebuild.

mkoeppe commented 2 years ago
comment:15

You also don't know that on gitpod, as I've explained in #33113 comment:18

mkoeppe commented 2 years ago
comment:16

Anyway, I've made it configurable

mkoeppe commented 2 years ago
comment:17

There are some problems when running this from a locally configured source tree, I'll try to find a solution for this.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

765dff7Merge #33740
ccbc21abootstrap, bootstrap-conda, src/doc/bootstrap: Use build/bin/sage-package directly
4560895src/doc/Makefile: Remove explicit use of SAGE_ROOT and the top-level sage script
7759f3cGenerate en/reference/repl/options.txt at build time, not bootstrap time
58ab878bootstrap-conda: Fix typo, generate->generating to match messages from bootstrap
02f2460Merge #33851
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 96bb5ad to 02f2460

mkoeppe commented 2 years ago
comment:19

Replying to @mkoeppe:

There are some problems when running this from a locally configured source tree, I'll try to find a solution for this.

Fixed in #33852, merged via #33851

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 02f2460 to d08ff6f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

d08ff6f.devcontainer/devcontainer.json: Use configure --prefix
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

bea9a69.devcontainer/devcontainer.json: Use make build V=0
a36721e.devcontainer/devcontainer.json: Use with-targets
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from d08ff6f to a36721e

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from a36721e to eb52e25

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

eb52e25.devcontainer/devcontainer.json: Install python extension
tobiasdiez commented 2 years ago
comment:23

I doesn't make sense to add those two packages to the _develop package. They are not needed to create a devcontainer, but have to be installed into the devcontainer to work with vscode. Thus they should only be listed in the devcontainer/Dockerfile.

Moreover, git should be installed (and configured) through the "feature" flag: https://code.visualstudio.com/docs/remote/containers#_dev-container-features-preview

mkoeppe commented 2 years ago
comment:24

Replying to @tobiasdiez:

I doesn't make sense to add those two packages to the _develop package. They are not needed to create a devcontainer, but have to be installed into the devcontainer to work with vscode.

Hm? That's exactly what is done.

mkoeppe commented 2 years ago
comment:25

Yes, git is still missing.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from eb52e25 to a6777bc

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

a6777bcbuild/pkgs/_develop/distros/debian.txt: Add git here for now
mkoeppe commented 2 years ago
comment:28

I haven't tested other distros yet. Need to add corresponding .txt files.

tobiasdiez commented 2 years ago
comment:29

Replying to @mkoeppe:

Replying to @tobiasdiez:

I doesn't make sense to add those two packages to the _develop package. They are not needed to create a devcontainer, but have to be installed into the devcontainer to work with vscode.

Hm? That's exactly what is done.

They are now added to this virtual develop package, which is meant for "useful stuff for developers". But these two packages are needed by vscode and thus should only be mentioned in the corresponding dockerfile, and not in the virtual develop package.

mkoeppe commented 2 years ago
comment:30

Replying to @tobiasdiez:

They are now added to this virtual develop package, which is meant for "useful stuff for developers". But these two packages are needed by vscode and thus should only be mentioned in the corresponding dockerfile, and not in the virtual develop package.

I don't want to go back to maintaining separate Dockerfiles for the various distributions.

I can of course create a separate script package "_devcontainer" for this purpose. Not sure if it really has to be so fine-grained.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

12ea8cebuild/pkgs/_develop/distros: Add packages providing gpgconf
238b7bbbuild/pkgs/_develop/distros: Add packages providing ssh
5daaa9aMerge #33851
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from a6777bc to 5daaa9a

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 5daaa9a to 4831977

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

6699fb3.devcontainer/devcontainer.json: Also install packages from build/pkgs/_develop/dependencies
4831977.devcontainer: Fix use of sage-print-system-package-command
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

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

44493f0.vscode/extensions.json: Recommend extension 'Remote - Containers'
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 4831977 to 44493f0

tobiasdiez commented 2 years ago
comment:34

Replying to @mkoeppe:

Replying to @tobiasdiez:

They are now added to this virtual develop package, which is meant for "useful stuff for developers". But these two packages are needed by vscode and thus should only be mentioned in the corresponding dockerfile, and not in the virtual develop package.

I don't want to go back to maintaining separate Dockerfiles for the various distributions.

I can of course create a separate script package "_devcontainer" for this purpose. Not sure if it really has to be so fine-grained.

There is no need for a new package, just put it in a switch/if statement for the different systems in the devcontainer dockerfile.

mkoeppe commented 2 years ago
comment:35

I have built this reusable infrastructure so that it can be reused. It's OK if you don't like it, but that does not make it "needs_work".