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 default devcontainer using conda #35072

Merged
merged 5 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/debian
{
"name": "Conda",
"image": "mcr.microsoft.com/vscode/devcontainers/base:0-bullseye",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

// Setup conda environment
"onCreateCommand": ".devcontainer/onCreate-conda.sh",

// Install additional features.
"features": {
// For config options, see https://github.com/devcontainers/features/tree/main/src/conda
"ghcr.io/devcontainers/features/conda": {
"version": "latest",
"addCondaForge": "true"
}
},
"customizations": {
"vscode": {
"extensions": [
"guyskk.language-cython",
"ms-python.isort",
"ms-toolsai.jupyter",
"ms-python.vscode-pylance",
"ms-python.pylint",
"ms-python.python",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst"
]
}
}
}
14 changes: 14 additions & 0 deletions .devcontainer/onCreate-conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Do not keep running on errors
set -e

# Create conda environment
./bootstrap-conda
conda install mamba -n base -c conda-forge -y
mamba env create --file src/environment-dev.yml || mamba env update --file src/environment-dev.yml
conda init bash

# Build sage
conda run -n sage-dev ./bootstrap
conda run -n sage-dev ./configure --with-python=/opt/conda/envs/sage-dev/bin/python --prefix=/opt/conda/envs/sage-dev
conda run -n sage-dev pip install --no-build-isolation -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
conda run -n sage-dev pip install --no-build-isolation -v -v -e ./src
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ src/ENV/
src/env.bak/
src/venv.bak/

# devcontainer
/.devcontainer/devcontainer.json

# mypy
**/.mypy_cache/

Expand Down
27 changes: 4 additions & 23 deletions src/doc/en/developer/portability_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1164,23 +1164,7 @@ provides sample ``devcontainer.json`` configuration files
<https://github.com/sagemath/sage/tree/develop/.devcontainer/>`_ for this
purpose.

To get started, symlink (or copy) one of the sample files to
``$SAGE_ROOT/.devcontainer/devcontainer.json``. For example, choose
`$SAGE_ROOT/.devcontainer/portability-ubuntu-jammy-standard/devcontainer.json
<https://github.com/sagemath/sage/tree/develop/.devcontainer/portability-ubuntu-jammy-standard/devcontainer.json>`_, which uses the Docker image based on ``ubuntu-jammy-standard``,
the most recent
development version of Sage (``dev`` tag), and a full installation of
the Sage distribution (``with-targets``).

In macOS for example, you can do this using the shell as follows::

[mkoeppe@sage sage] $ (cd .devcontainer && ln -s portability-ubuntu-jammy-standard/devcontainer.json .)

Now start VS Code::

[mkoeppe@sage sage] $ code .

Then VS Code may prompt you whether you would like to open the current
If you open the sage folder in VS Code, it may prompt you whether you would like to open the current
directory in the dev container (yes). If it does not, use the command palette
(:kbd:`Ctrl` + :kbd:`Shift` + :kbd:`P`), enter the command "Remote-Containers:
Reopen Folder in Container" , and hit :kbd:`Enter`.
Expand Down Expand Up @@ -1225,8 +1209,7 @@ in a terminal, `open a new terminal in VS Code
``configure`` script.

You can edit a copy of the configuration file to change to a different platform, another
version, or build stage. After editing the configuration file (or changing the
symlink), run "Remote-Containers: Rebuild Container" from the command
version, or build stage. After editing the configuration file, run "Remote-Containers: Rebuild Container" from the command
palette. See the `VS Code devcontainer.json reference
<https://code.visualstudio.com/docs/remote/devcontainerjson-reference>`_
and the `GitHub introduction to dev containers
Expand All @@ -1248,8 +1231,7 @@ installation of SageMath in this container by building from the current source t
project <https://hub.docker.com/r/computop/sage/>`_, providing
SnapPy, Regina, PHCPack, etc.

If you want to use one of these ``devcontainer.json`` files, symlink (or copy)
it and start VS Code as explained above. After VS Code finished configuring the
After VS Code finished configuring the
dev container, to use Sage in a terminal, `open a new terminal in VS Code
<https://code.visualstudio.com/docs/terminal/basics>`_, type ``./sage`` and hit
:kbd:`Enter`.
Expand Down Expand Up @@ -1284,8 +1266,7 @@ work without change) or to adapt them to your needs.
project <https://hub.docker.com/r/computop/sage/>`_, providing
SnapPy, Regina, PHCPack, etc.

If you want to use one of these ``devcontainer.json`` files, symlink (or copy)
it and start VS Code as explained above. After VS Code finished configuring the
After VS Code finished configuring the
dev container, to use Sage in a terminal, `open a new terminal in VS Code
<https://code.visualstudio.com/docs/terminal/basics>`_, type ``sage`` and hit
:kbd:`Enter`. (Do not use ``./sage``; this will not work because the source
Expand Down