Repository: scipy/scipy
Pull request: DEV,BLD: Move to meson on gitpod
Enables building with meson on gitpod. 

#### Reference issue
Closes #16065

#### What does this implement/fix?
Enables building with meson, using the `environment_meson.yml` file on gitpod, including pre-building SciPy and the documentation.


Problem statement:
BUG: Gitpod build with `python runtests.py` fails; move to meson on gitpod
### Describe your issue.

The current configuration of gitpod for the SciPy repo involves creating the `scipy-dev` environment and building through `python setup.py build_ext --inplace`. However, running `python runtests.py` with this setup results in test errors. 

On the other hand, creating the `scipy-meson` environment and running `python dev.py` works well. My suggestion is to move to meson on gitpod. This would also help with consistency, since our developer quickstart now recommends meson.

### Reproducing Code Example

```python
Open gitpod on scipy repo, and do `python runtests.py` in the terminal.
```


### Error message

```shell
Building, see build.log...
    ... build in progress (0:01:00.073483 elapsed)
Build OK (0:01:51.134909 elapsed)
Running tests for scipy version:1.9.0.dev0+1937.7043404, installed at:/workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy
============================= test session starts ==============================
platform linux -- Python 3.10.4, pytest-7.1.1, pluggy-1.0.0
rootdir: /workspace/scipy, configfile: pytest.ini
plugins: cov-3.0.0, forked-1.4.0, xdist-2.5.0
collected 122 items / 263 errors / 2 deselected / 120 selected

==================================== ERRORS ====================================
_ ERROR collecting build/testenv/lib/python3.10/site-packages/scipy/cluster/tests/test_disjoint_set.py _
ImportError while importing test module '/workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/cluster/tests/test_disjoint_set.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/envs/scipy-dev/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
scipy/cluster/__init__.py:25: in <module>
    from . import vq, hierarchy
scipy/cluster/vq.py:72: in <module>
    from scipy.spatial.distance import cdist
scipy/spatial/__init__.py:105: in <module>
    from ._kdtree import *
scipy/spatial/_kdtree.py:5: in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
E   ImportError: /workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/spatial/_ckdtree.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNSt11logic_errorC1EPKc
_ ERROR collecting build/testenv/lib/python3.10/site-packages/scipy/cluster/tests/test_hierarchy.py _
ImportError while importing test module '/workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/cluster/tests/test_hierarchy.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/envs/scipy-dev/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
scipy/cluster/__init__.py:25: in <module>
    from . import vq, hierarchy
scipy/cluster/vq.py:72: in <module>
    from scipy.spatial.distance import cdist
scipy/spatial/__init__.py:105: in <module>
    from ._kdtree import *
scipy/spatial/_kdtree.py:5: in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
E   ImportError: /workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/spatial/_ckdtree.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNSt11logic_errorC1EPKc
_ ERROR collecting build/testenv/lib/python3.10/site-packages/scipy/cluster/tests/test_vq.py _
ImportError while importing test module '/workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/cluster/tests/test_vq.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/envs/scipy-dev/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
scipy/cluster/__init__.py:25: in <module>
    from . import vq, hierarchy
scipy/cluster/vq.py:72: in <module>
    from scipy.spatial.distance import cdist
scipy/spatial/__init__.py:105: in <module>
    from ._kdtree import *
scipy/spatial/_kdtree.py:5: in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
E   ImportError: /workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/spatial/_ckdtree.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNSt11logic_errorC1EPKc
_ ERROR collecting build/testenv/lib/python3.10/site-packages/scipy/fft/_pocketfft/tests/test_basic.py _
ImportError while importing test module '/workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/fft/_pocketfft/tests/test_basic.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/envs/scipy-dev/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
scipy/fft/__init__.py:85: in <module>
    from ._basic import (
scipy/fft/_basic.py:1: in <module>
    from scipy._lib.uarray import generate_multimethod, Dispatchable
scipy/_lib/uarray.py:28: in <module>
    from ._uarray import *
scipy/_lib/_uarray/__init__.py:115: in <module>
    from ._backend import *
scipy/_lib/_uarray/_backend.py:5: in <module>
    from . import _uarray
E   ImportError: /workspace/scipy/build/testenv/lib/python3.10/site-packages/scipy/_lib/_uarray/_uarray.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNSt16invalid_argumentD1Ev

<snip>
```


### SciPy/NumPy/Python version information

1.9.0.dev0+1937.7043404 1.22.3 sys.version_info(major=3, minor=10, micro=4, releaselevel='final', serial=0)

Hints from issue discussion:

Commit message: DEV - Update Meson-gitpod (#1)

* :building_construction: [ENH] - Update Dockerfile - split into Meson and dev

* ENH - Split Dockerbuilds

* DEV: Add pip to avoid warning

* ENH: Add docs to Dockerfile

* DEV: Improve Docker build

* DEV: Quick fix for env setup

* DEV: Testing - will revert

* DEV: Only use docutils

* DEV: Revert test

* DEV: Docutils install - will remove later

Patch to review:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index b922045dc6fe..374c5027e8fe 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -1,16 +1,18 @@
 name: Build Base Docker Image
 
-# Triggered only if environment.yml in main changes
+# Triggered only if environment_meson.yml in main changes
 # Pushes a Docker image with all dev dependencies to Docker Hub
 on:
   push:
     branches:
       - main
     paths:
+      # will keep both until there is a reason to get rid of scipy-dev entirely
+      - 'environment_meson.yml'
       - 'environment.yml'
 
 jobs:
-  build:
+  build-dev-base:
     name: Build base Docker image
     runs-on: ubuntu-latest
     environment: scipy-dev
@@ -34,12 +36,52 @@ jobs:
         id: getrefs
       - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v1
-      - name: Cache Docker layers
-        uses: actions/cache@v3
+      - name: Login to Docker Hub
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+      - name: Build and push
+        id: docker_build
+        uses: docker/build-push-action@v2
         with:
-          path: /tmp/.buildx-cache
-          key: ${{ runner.os }}-buildx-${{ github.sha }}
-          restore-keys: ${{ runner.os }}-buildx-
+          context: "."
+          file: "./tools/docker_dev/meson.Dockerfile"
+          push: ${{ github.event_name != 'pull_request' }}
+          # https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
+          cache-from: type=gha
+          cache-to: type=gha,mode=max
+          tags: |
+            scipy/scipy-dev:${{ steps.getrefs.outputs.date }}-${{ steps.getrefs.outputs.branch}}-${{ steps.getrefs.outputs.sha8 }}
+            scipy/scipy-dev:latest
+      - name: Image digest
+        # Return details of the image build: sha and shell
+        run: echo ${{ steps.docker_build.outputs.digest }}
+
+  build-meson-base:
+    name: Build base Docker image
+    runs-on: ubuntu-latest
+    environment: scipy-dev
+    if: "github.repository_owner == 'scipy' && !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip github]')"
+    steps:
+      - name: Clone repository
+        uses: actions/checkout@v3
+        with:
+          submodules: recursive
+      - name: Lint Docker
+        uses: brpaz/hadolint-action@v1.2.1
+        with:
+          dockerfile: ./tools/docker_dev/meson.Dockerfile
+      - name: Get refs
+        shell: bash
+        run: |
+          export raw_branch=${GITHUB_REF#refs/heads/}
+          echo "::set-output name=branch::${raw_branch//\//-}"
+          echo "::set-output name=date::$(date +'%Y%m%d')"
+          echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
+        id: getrefs
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
       - name: Login to Docker Hub
         uses: docker/login-action@v1
         with:
@@ -55,7 +97,8 @@ jobs:
           cache-from: type=local,src=/tmp/.buildx-cache
           cache-to: type=local,dest=/tmp/.buildx-cache
           tags: |
-            scipy/scipy-dev:${{ steps.getrefs.outputs.date }}-${{ steps.getrefs.outputs.branch}}-${{ steps.getrefs.outputs.sha8 }}, scipy/scipy-dev:latest
+            scipy/scipy-meson:${{ steps.getrefs.outputs.date }}-${{ steps.getrefs.outputs.branch}}-${{ steps.getrefs.outputs.sha8 }}
+            scipy/scipy-meson:latest
       - name: Image digest
         # Return details of the image build: sha and shell
         run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/.github/workflows/gitpod.yml b/.github/workflows/gitpod.yml
index 09d386a8705d..dd5b37d183b9 100644
--- a/.github/workflows/gitpod.yml
+++ b/.github/workflows/gitpod.yml
@@ -27,12 +27,6 @@ jobs:
         id: getrefs
       - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v1
-      - name: Cache Docker layers
-        uses: actions/cache@v3
-        with:
-          path: /tmp/.buildx-cache
-          key: ${{ runner.os }}-buildx-${{ github.sha }}
-          restore-keys: ${{ runner.os }}-buildx-
       - name: Login to Docker Hub
         uses: docker/login-action@v1
         with:
@@ -47,8 +41,13 @@ jobs:
           push: ${{ github.event_name != 'pull_request' }}
           cache-from: type=local,src=/tmp/.buildx-cache
           cache-to: type=local,dest=/tmp/.buildx-cache
+          build-args: |
+            BASE_CONTAINER="scipy/scipy-meson:latest"
+            BUILD_ARG="python dev.py --build-only -j2
+            CONDA_ENV="scipy-meson"
           tags: |
-            scipy/scipy-gitpod:${{ steps.getrefs.outputs.date }}-${{ steps.getrefs.outputs.branch}}-${{ steps.getrefs.outputs.sha8 }}, scipy/scipy-gitpod:latest
+            scipy/scipy-gitpod:${{ steps.getrefs.outputs.date }}-${{ steps.getrefs.outputs.branch}}-${{ steps.getrefs.outputs.sha8 }}
+            scipy/scipy-gitpod:latest
       - name: Image digest 
         # Return details of the image build: sha and shell
         run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/.gitpod.yml b/.gitpod.yml
index 55cd1bd125ad..9e36f143881b 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -12,14 +12,13 @@ tasks:
     init: |
       mkdir -p .vscode
       cp tools/docker_dev/settings.json .vscode/settings.json
-      conda activate scipy-dev
+      conda activate scipy-meson
+      python -m pip install docutils
       git submodule update --init
-      python setup.py build_ext --inplace
+      python dev.py --build-only -j2
       echo "🛠 Completed rebuilding SciPy!! 🛠 "
-      conda develop .
       echo "📖 Building docs 📖 "
-      cd doc 
-      make html-scipyorg
+      python dev.py --doc
       echo "✨ Pre-build complete! You can close this terminal ✨ "
   
 # --------------------------------------------------------
@@ -33,13 +32,13 @@ ports:
 vscode:
   extensions:
     - eamodio.gitlens
-    - njpwerner.autodocstring
+    - bungcip.better-toml
     - lextudio.restructuredtext
-    - ritwickdey.liveserver
     - ms-python.python
+    - njpwerner.autodocstring
+    - ritwickdey.liveserver
+    - trond-snekvik.simple-rst
     - yzhang.markdown-all-in-one
-    - bungcip.better-toml
-    - mhutchie.git-graph
 
 # --------------------------------------------------------
 # using prebuilds for the container - note: atm this only
diff --git a/environment.yml b/environment.yml
index 15109d1aba97..4c49b8835c4c 100644
--- a/environment.yml
+++ b/environment.yml
@@ -42,5 +42,7 @@ dependencies:
   # For CLI
   - rich-click
   - click
+  # Else Docker raise a warning
+  - pip
   - pip:
       - doit==0.35.0
diff --git a/environment_meson.yml b/environment_meson.yml
index ac8cebb1f342..e1f56d154f3d 100644
--- a/environment_meson.yml
+++ b/environment_meson.yml
@@ -45,5 +45,7 @@ dependencies:
   # For CLI
   - rich-click
   - click
+  # Else Docker raise a warning
+  - pip
   - pip:
       - doit==0.35.0
diff --git a/tools/docker_dev/Dockerfile b/tools/docker_dev/Dockerfile
index 4e528f5cc2a8..477a059af48f 100644
--- a/tools/docker_dev/Dockerfile
+++ b/tools/docker_dev/Dockerfile
@@ -4,8 +4,8 @@
 # Usage: 
 # -------
 # 
-# To make a local build of the container, from the 'Docker-dev' directory:
-# docker build  --rm -f "Dockerfile" -t <build-tag> "."    
+# To make a local build of the container, from the root directory:
+# docker build  --rm -f "./tools/docker_dev/Dockerfile" -t <build-tag> "."   
 # 
 # To use the container use the following command. It assumes that you are in
 # the root folder of the scipy git repository, making it available as
diff --git a/tools/docker_dev/gitpod.Dockerfile b/tools/docker_dev/gitpod.Dockerfile
index d2b46596d5a6..9e8df9a9c905 100644
--- a/tools/docker_dev/gitpod.Dockerfile
+++ b/tools/docker_dev/gitpod.Dockerfile
@@ -1,5 +1,15 @@
+# Dockerfile for SciPy - gitpod-based development
+# Usage: 
+# -------
+# 
+# To make a local build of the container, from the root directory:
+# docker build --rm -f "./tools/docker_dev/gitpod.Dockerfile" -t <build-tag> "."    
+# docker build --rm -f "./tools/docker_dev/gitpod.Dockerfile" -t scipy/scipy-gitpod:latest "."  --build-arg BASE_CONTAINER="scipy/scipy-meson:latest" --build-arg CONDA_ENV="scipy-meson" --build-arg BUILD_ARG="python dev.py --build-only -j2"
+# 
 # Doing a local shallow clone - keeps the container secure
 # and much slimmer than using COPY directly or cloning a remote
+# To use the Meson container you'll need to use
+# --build-arg BASE_CONTAINER="scipy/scipy-meson:latest"
 ARG BASE_CONTAINER=scipy/scipy-dev:latest
 FROM ${BASE_CONTAINER} as clone
 
@@ -8,20 +18,27 @@ FROM ${BASE_CONTAINER} as clone
 COPY --chown=gitpod . /tmp/scipy_repo
 RUN git clone --depth 1 file:////tmp/scipy_repo /tmp/scipy
 
+# -----------------------------------------------------------------------------
 # Using the Scipy-dev Docker image as a base
 # This way, we ensure we have all the needed compilers and dependencies
-# while reducing the build time
+# while reducing the build time - making this a  build ARG so we can reuse for other images
+# to use the meson image instead --build-arg BASE_CONTAINER="scipy/scipy-meson:latest"
 ARG BASE_CONTAINER=scipy/scipy-dev:latest
 FROM ${BASE_CONTAINER} as build
 
+# Build argument - can pass Meson arguments during the build:
+# --build-arg BUILD_ARG="python dev.py --build-only -j2"
+# --build-arg CONDA_ENV="scipy-meson"
+ARG BUILD_ARG="python setup.py build_ext --inplace" \
+    CONDA_ENV=scipy-dev
+
 # -----------------------------------------------------------------------------
 USER root
 
 # -----------------------------------------------------------------------------
 # ---- ENV variables ----
 # ---- Directories needed ----
-ENV WORKSPACE=/workspace/scipy/ \
-    CONDA_ENV=scipy-dev
+ENV WORKSPACE=/workspace/scipy/ 
 
 # -----------------------------------------------------------------------------
 # Change default shell - this avoids issues with Conda later - note we do need
@@ -35,15 +52,18 @@ COPY --from=clone --chown=gitpod /tmp/scipy ${WORKSPACE}
 
 WORKDIR ${WORKSPACE}
 
-# Build scipy to populate the cache used by ccache
+# Build SciPy to populate the cache used by ccache
 # Must re-activate conda to ensure the ccache flags are picked up
-RUN git submodule update --init --depth=1 -- scipy/_lib/boost
-RUN git submodule update --init --depth=1 -- scipy/sparse/linalg/_propack/PROPACK
-RUN git submodule update --init --depth=1 -- scipy/_lib/unuran
-RUN git submodule update --init --depth=1 -- scipy/_lib/highs
+RUN git submodule update --init --depth=1 -- scipy/_lib/boost &&\ 
+    git submodule update --init --depth=1 -- scipy/sparse/linalg/_propack/PROPACK && \
+    git submodule update --init --depth=1 -- scipy/_lib/unuran && \
+    git submodule update --init --depth=1 -- scipy/_lib/highs
+
 RUN conda activate ${CONDA_ENV} && \
-    python setup.py build_ext --inplace && \
-    ccache -s
+    ${BUILD_ARG} && \
+    ccache -s && \ 
+    # needed for rst preview in gitpod
+    python3 -m pip install docutils
 
 # Gitpod will load the repository into /workspace/scipy. We remove the
 # directoy from the image to prevent conflicts
diff --git a/tools/docker_dev/meson.Dockerfile b/tools/docker_dev/meson.Dockerfile
new file mode 100644
index 000000000000..d5bd1eefa79a
--- /dev/null
+++ b/tools/docker_dev/meson.Dockerfile
@@ -0,0 +1,170 @@
+# 
+# Dockerfile for Scipy development 
+# Meson build system - https://scipy.github.io/devdocs/dev/contributor/meson.html#full-details-and-explanation
+# https://scipy.github.io/devdocs/dev/contributor/conda_guide.html#conda-guide
+# 
+# Usage: 
+# -------
+# 
+# To make a local build of the container, from the root directory:
+# docker build  --rm -f "./tools/docker_dev/meson.Dockerfile" -t <build-tag> "."  
+# 
+# To use the container use the following command. It assumes that you are in
+# the root folder of the scipy git repository, making it available as
+# /home/scipy in the container. Whatever changes you make to that directory
+# are visible in the host and container.
+# The docker image is retrieved from the scipy dockerhub repository
+#
+# docker run --rm -it -v $(pwd):/home/scipy scipy:<image-tag>
+# 
+# By default the container will activate the conda environment scipy-meson
+# which contains all the dependencies needed for SciPy development
+# 
+# To build Scipy run: python dev.py --build-only -j2 
+# For the all-in-one (configure,build,test SciPy and docs) use: python dev.py
+#
+# To run the tests use: python dev.py -n 
+# 
+# This image is based on: Ubuntu 20.04 (focal)
+# https://hub.docker.com/_/ubuntu/?tab=tags&name=focal
+# OS/ARCH: linux/amd64
+ARG ROOT_CONTAINER=gitpod/workspace-base:latest
+ARG BASE_CONTAINER=${ROOT_CONTAINER}
+
+# hadolint ignore=DL3006
+FROM ${BASE_CONTAINER}
+
+# -----------------------------------------------------------------------------
+# ---- Miniforge installer ----
+# Default values can be overridden at build time
+# (ARGS are in lower case to distinguish them from ENV)
+# Check https://github.com/conda-forge/miniforge/releases
+# Conda version
+ARG conda_version="4.9.2"
+# Miniforge installer patch version
+ARG miniforge_patch_number="5"
+# Miniforge installer architecture
+ARG miniforge_arch="x86_64"
+# Python implementation to use 
+# can be either Miniforge3 to use Python or Miniforge-pypy3 to use PyPy
+ARG miniforge_python="Miniforge3"
+
+# Miniforge archive to install
+ARG miniforge_version="${conda_version}-${miniforge_patch_number}"
+# Miniforge installer
+ARG miniforge_installer="${miniforge_python}-${miniforge_version}-Linux-${miniforge_arch}.sh"
+# Miniforge checksum
+ARG miniforge_checksum="49dddb3998550e40adc904dae55b0a2aeeb0bd9fc4306869cc4a600ec4b8b47c"
+
+# -----------------------------------------------------------------------------
+# ---- Python version to install ----
+# Currently Python 3.8
+ARG PYTHON_VERSION=default
+
+# ---- Configure environment ----
+ENV CONDA_DIR=/opt/conda \
+    SHELL=/bin/bash  \
+    GP_USER=gitpod \
+    GP_GROUP=gitpod \
+    GP_UID=33333 
+
+ENV CONDA_VERSION="${conda_version}" \
+    MINIFORGE_VERSION="${miniforge_version}" \
+    CONDA_ENV=scipy-meson \
+    PATH=${CONDA_DIR}/bin:$PATH 
+
+# -----------------------------------------------------------------------------
+# ---- OS dependencies ----
+ENV DEBIAN_FRONTEND noninteractive
+
+USER root
+
+# Change default shell - this avoids issues with Conda later
+SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
+
+# hadolint ignore=DL3008
+RUN apt-get update && \ 
+    apt-get install -yq --no-install-recommends \
+    ca-certificates \
+    ccache \
+    dirmngr \
+    gnupg \
+    gpg-agent \
+    libatlas-base-dev \
+    vim \
+    wget && \
+    # this needs to be done after installing dirmngr
+    apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 && \ 
+    apt-add-repository https://cli.github.com/packages && \ 
+    apt-get install -yq --no-install-recommends \
+    gh && \ 
+    locale-gen en_US.UTF-8 && \
+    apt-get clean && \
+    rm -rf /var/cache/apt/* &&\
+    rm -rf /var/lib/apt/lists/* &&\
+    rm -rf /tmp/*
+
+# -----------------------------------------------------------------------------
+# ---- Copy needed files ----
+# Copy multiple scripts - fix directory permissions and 
+# basic workspace configurations
+COPY ./tools/docker_dev/workspace_config /usr/local/bin/workspace_config
+COPY ./tools/docker_dev/fix_permissions /usr/local/bin/fix_permissions
+
+RUN chmod a+rx /usr/local/bin/workspace_config && \
+    chmod a+rx /usr/local/bin/fix_permissions 
+
+# -----------------------------------------------------------------------------
+RUN mkdir -p "${CONDA_DIR}" && \
+    # transfer conda path ownership and ensure it is user writable
+    chown -R ${GP_USER}:${GP_GROUP} ${CONDA_DIR} && \
+    fix_permissions ${CONDA_DIR} && \
+    workspace_config
+
+USER ${GP_USER}
+
+WORKDIR /tmp
+
+# -----------------------------------------------------------------------------
+# ---- Installing conda  ----
+RUN wget --quiet "https://github.com/conda-forge/miniforge/releases/download/${miniforge_version}/${miniforge_installer}" && \
+    echo "${miniforge_checksum} *${miniforge_installer}" | sha256sum --check && \
+    /bin/bash "${miniforge_installer}" -f -b -p $CONDA_DIR && \
+    rm "${miniforge_installer}" && \
+    # Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
+    echo "conda ${CONDA_VERSION}" >> $CONDA_DIR/conda-meta/pinned && \
+    conda config --system --set auto_update_conda false && \
+    conda config --system --set show_channel_urls true && \
+    # This allows to change the Python version installed by passing the arg `PYTHON_VERSION` at build time
+    # then version is added to conda-meta/pinned 
+    if [ ! $PYTHON_VERSION = 'default' ]; then conda install --yes python=$PYTHON_VERSION; fi && \
+    conda list python | grep '^python ' | tr -s ' ' | cut -d '.' -f 1,2 | sed 's/$/.*/' >> $CONDA_DIR/conda-meta/pinned && \
+    conda install --quiet --yes \
+    "conda=${CONDA_VERSION}" \
+    'pip' && \
+    conda update --all --quiet --yes && \
+    conda clean --all -f -y && \
+    fix_permissions ${CONDA_DIR}
+
+
+# -----------------------------------------------------------------------------
+# ---- Create conda environment ----
+# Install SciPy dependencies - since using miniforge no need to add 
+# conda-forge channel
+COPY environment_meson.yml /tmp/environment_meson.yml
+
+RUN conda env create -f /tmp/environment_meson.yml && \
+    conda activate ${CONDA_ENV} && \
+    # needed for docs rendering later on
+    python -m pip install --no-cache-dir sphinx-autobuild && \
+    conda install ccache -y && \
+    # need to use sudo to remove tmp files
+    sudo rm -rf /tmp/* && \
+    conda clean --all -f -y && \
+    # for good measure after installing things
+    fix_permissions ${CONDA_DIR} 
+
+# -----------------------------------------------------------------------------
+USER ${GP_USER}
+
+WORKDIR $HOME/scipy
\ No newline at end of file
diff --git a/tools/docker_dev/settings.json b/tools/docker_dev/settings.json
index ec5836092ec9..a79ba600f9a6 100644
--- a/tools/docker_dev/settings.json
+++ b/tools/docker_dev/settings.json
@@ -1,9 +1,10 @@
 {
-    "restructuredtext.languageServer.disabled": true,
-    "restructuredtext.builtDocumentationPath": "${workspaceRoot}/doc/build/html-scipyorg",
-    "restructuredtext.confPath": "",
+    "python.defaultInterpreterPath": "/opt/conda/envs/scipy-dev/bin/python",
+    // rst related - for the docs
+    "esbonio.sphinx.buildDir": "${workspaceRoot}/doc/build/html-scipyorg",
+    "esbonio.sphinx.confDir"  : "",
+    // will use docutils only
+    "esbonio.server.enabled": false,
     "restructuredtext.updateOnTextChanged": "true",
-    "restructuredtext.updateDelay": 300,
-    "restructuredtext.linter.disabled": true,
-    "python.pythonPath": "/opt/conda/envs/scipy-dev/bin/python"
+    "restructuredtext.updateDelay": 300
 }
\ No newline at end of file
diff --git a/tools/docker_dev/workspace_config b/tools/docker_dev/workspace_config
index fae619ac789b..812e014351f5 100644
--- a/tools/docker_dev/workspace_config
+++ b/tools/docker_dev/workspace_config
@@ -29,7 +29,17 @@ if [[ ! -f "/etc/profile.d/conda.sh" ]]; then
     ln -s ${CONDA_DIR}/etc/profile.d/conda.sh /etc/profile.d/conda.sh
 fi
 echo ". ${CONDA_DIR}/etc/profile.d/conda.sh" >>~/.bashrc
-echo "conda activate scipy-dev" >>~/.bashrc
+
+# Find env - TODO need to make this neater as it is a quick and dirty fix
+find_in_conda_env() {
+    conda env list | grep "${@}" >/dev/null 2>/dev/null
+}
+
+if find_in_conda_env ".*scipy-dev.*"; then
+    conda activate scipy-dev
+else
+    conda activate scipy-meson
+fi
 
 # Enable prompt color in the skeleton .bashrc
 # hadolint ignore=SC2016


Code review comments:
diff_hunk: @@ -12,14 +12,13 @@ tasks:
     init: |
       mkdir -p .vscode
       cp tools/docker_dev/settings.json .vscode/settings.json
-      conda activate scipy-dev
+      conda activate scipy-meson
+      python -m pip install docutils
path: .gitpod.yml
text: @user1:
```suggestion
```