Skip to content

Commit 957a4db

Browse files
committed
sync with main
2 parents 5058eca + 12f94dc commit 957a4db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1004
-88
lines changed

.github/workflows/docker.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- "**.rst"
1212
- ".github/workflows/*"
1313
- "!.github/workflows/docker.yml"
14+
- ".pre-commit-config.yaml"
1415
push:
1516
paths-ignore:
1617
- "docs/**"
1718
- "**.md"
1819
- "**.rst"
1920
- ".github/workflows/*"
2021
- "!.github/workflows/docker.yml"
22+
- ".pre-commit-config.yaml"
2123
branches-ignore:
2224
- "dependabot/**"
2325
- "pre-commit-ci-update-config"

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- "**.rst"
1212
- ".github/workflows/*"
1313
- "!.github/workflows/release.yml"
14+
- ".pre-commit-config.yaml"
1415
push:
1516
paths-ignore:
1617
- "docs/**"
1718
- "**.md"
1819
- "**.rst"
1920
- ".github/workflows/*"
2021
- "!.github/workflows/release.yml"
22+
- ".pre-commit-config.yaml"
2123
branches-ignore:
2224
- "dependabot/**"
2325
- "pre-commit-ci-update-config"
@@ -55,7 +57,7 @@ jobs:
5557
# all previous steps always run in order to exercise them
5658
- name: Publish distribution to PyPI
5759
if: startsWith(github.ref, 'refs/tags')
58-
uses: pypa/gh-action-pypi-publish@v1.5.1
60+
uses: pypa/gh-action-pypi-publish@v1.6.4
5961
with:
6062
password: ${{ secrets.PYPI_PASSWORD }}
6163

@@ -125,6 +127,6 @@ jobs:
125127
uses: docker/build-push-action@v3
126128
with:
127129
context: .
128-
platforms: linux/amd64
130+
platforms: linux/amd64,linux/arm64
129131
push: true
130132
tags: ${{ env.TAGS }}

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- "**.rst"
1212
- ".github/workflows/*"
1313
- "!.github/workflows/test.yml"
14+
- ".pre-commit-config.yaml"
1415
push:
1516
paths-ignore:
1617
- "docs/**"
1718
- "**.md"
1819
- "**.rst"
1920
- ".github/workflows/*"
2021
- "!.github/workflows/test.yml"
22+
- ".pre-commit-config.yaml"
2123
branches-ignore:
2224
- "dependabot/**"
2325
- "pre-commit-ci-update-config"

.gitpod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
tasks:
22
- init: |
33
pip3 install sphinx-autobuild
4+
pip3 install -r dev-requirements.txt
45
pip3 install -r docs/requirements.txt
56
pip3 install -e .
67
command: |
78
sphinx-autobuild docs/source/ docs/_build/html/
89
name: Sphinx preview
10+
911
ports:
1012
- port: 8000

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
repos:
1212
# Autoformat: Python code, syntax patterns are modernized
1313
- repo: https://github.com/asottile/pyupgrade
14-
rev: v3.2.2
14+
rev: v3.3.1
1515
hooks:
1616
- id: pyupgrade
1717
args:
@@ -23,7 +23,7 @@ repos:
2323

2424
# Autoformat: Python code
2525
- repo: https://github.com/psf/black
26-
rev: 22.10.0
26+
rev: 23.1.0
2727
hooks:
2828
- id: black
2929
args:
@@ -36,7 +36,7 @@ repos:
3636

3737
# Autoformat: Python code
3838
- repo: https://github.com/pycqa/isort
39-
rev: 5.10.1
39+
rev: 5.12.0
4040
hooks:
4141
- id: isort
4242
args:
@@ -48,3 +48,7 @@ repos:
4848
hooks:
4949
- id: prettier
5050
files: ".md"
51+
52+
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
53+
ci:
54+
autoupdate_schedule: monthly

Dockerfile

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
11
# syntax = docker/dockerfile:1.3
22
ARG ALPINE_VERSION=3.16
3-
FROM alpine:${ALPINE_VERSION} AS builder
3+
FROM alpine:${ALPINE_VERSION}
44

55
RUN apk add --no-cache git python3 python3-dev py-pip build-base
66

7-
# set pip's cache directory using this environment variable, and use
8-
# ARG instead of ENV to ensure its only set when the image is built
9-
ARG PIP_CACHE_DIR=/tmp/pip-cache
10-
117
# build wheels in first image
128
ADD . /tmp/src
139
RUN cd /tmp/src && git clean -xfd && git status
14-
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
15-
mkdir /tmp/wheelhouse \
10+
RUN mkdir /tmp/wheelhouse \
1611
&& cd /tmp/wheelhouse \
1712
&& pip3 install wheel \
18-
&& pip3 wheel /tmp/src \
13+
&& pip3 wheel --no-cache-dir /tmp/src \
1914
&& ls -l /tmp/wheelhouse
2015

2116
FROM alpine:${ALPINE_VERSION}
2217

2318
# install python, git, bash, mercurial
2419
RUN apk add --no-cache git git-lfs python3 py-pip bash docker mercurial
2520

26-
# repeat ARG from above
27-
ARG PIP_CACHE_DIR=/tmp/pip-cache
21+
# install hg-evolve (Mercurial extensions)
22+
RUN pip3 install hg-evolve --user --no-cache-dir
2823

2924
# install repo2docker
30-
# and hg-evolve (Mercurial extensions)
31-
# mount /tmp/wheelhouse from build stage
32-
# avoids extra layer when using COPY --from
33-
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
34-
--mount=type=cache,from=builder,source=/tmp/wheelhouse,target=/tmp/wheelhouse \
35-
pip3 install --ignore-installed --no-deps /tmp/wheelhouse/*.whl \
36-
&& pip3 install hg-evolve \
25+
COPY --from=0 /tmp/wheelhouse /tmp/wheelhouse
26+
RUN pip3 install --no-cache-dir --ignore-installed --no-deps /tmp/wheelhouse/*.whl \
3727
&& pip3 list
3828

3929
# add git-credential helper

docs/source/howto/user_interface.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ http://mybinder.org/v2/gh/binder-examples/r/HEAD?urlpath=rstudio
9797
Shiny
9898
=====
9999

100-
`Shiny lets you create interactive visualizaions with R <https://shiny.rstudio.com/>`_.
100+
`Shiny lets you create interactive visualizations with R <https://shiny.rstudio.com/>`_.
101101
Shiny is automatically enabled if a configuration file for
102102
R is detected (i.e. an R version specified in ``runtime.txt``). If
103103
this is detected, Shiny will be accessible by appending

repo2docker/app.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
import tempfile
1717
import time
18+
import warnings
1819
from urllib.parse import urlparse
1920

2021
import entrypoints
@@ -36,7 +37,7 @@
3637
RBuildPack,
3738
)
3839
from .engine import BuildError, ContainerEngineException, ImageLoadError
39-
from .utils import ByteSpecification, R2dState, chdir
40+
from .utils import ByteSpecification, R2dState, chdir, get_platform
4041

4142

4243
class Repo2Docker(Application):
@@ -250,6 +251,27 @@ def _user_name_default(self):
250251
config=True,
251252
)
252253

254+
platform = Unicode(
255+
config=True,
256+
help="""
257+
Platform to build for, linux/amd64 (recommended) or linux/arm64 (experimental).
258+
""",
259+
)
260+
261+
@default("platform")
262+
def _platform_default(self):
263+
"""
264+
Default platform
265+
"""
266+
p = get_platform()
267+
if p == "linux/arm64":
268+
warnings.warn(
269+
"Building for linux/arm64 is experimental. "
270+
"To use the recommended platform set --Repo2Docker.platform=linux/amd64. "
271+
"To silence this warning set --Repo2Docker.platform=linux/arm64."
272+
)
273+
return p
274+
253275
extra_build_args = Dict(
254276
{},
255277
help="""
@@ -778,6 +800,7 @@ def build(self):
778800
else:
779801
picked_buildpack = self.default_buildpack()
780802

803+
picked_buildpack.platform = self.platform
781804
picked_buildpack.appendix = self.appendix
782805
# Add metadata labels
783806
picked_buildpack.labels["repo2docker.version"] = self.version
@@ -819,6 +842,7 @@ def build(self):
819842
build_args,
820843
self.cache_from,
821844
self.extra_build_kwargs,
845+
platform=self.platform,
822846
):
823847
if docker_client.string_output:
824848
self.log.info(l, extra=dict(phase=R2dState.BUILDING))

repo2docker/buildpacks/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def __init__(self):
229229
"Windows environment detected. Note that Windows "
230230
"support is experimental in repo2docker."
231231
)
232+
self.platform = ""
232233

233234
def get_packages(self):
234235
"""
@@ -559,6 +560,7 @@ def build(
559560
build_args,
560561
cache_from,
561562
extra_build_kwargs,
563+
platform=None,
562564
):
563565
tarf = io.BytesIO()
564566
tar = tarfile.open(fileobj=tarf, mode="w")
@@ -613,6 +615,7 @@ def _filter_tar(tar):
613615
buildargs=build_args,
614616
container_limits=limits,
615617
cache_from=cache_from,
618+
platform=platform,
616619
)
617620

618621
build_kwargs.update(extra_build_kwargs)

repo2docker/buildpacks/conda/__init__.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class CondaBuildPack(BaseImage):
3535
# extra pip requirements.txt for the notebook env
3636
_nb_requirements_file = ""
3737

38+
def _conda_platform(self):
39+
"""Return the conda platform name for the current platform"""
40+
if self.platform == "linux/amd64":
41+
return "linux-64"
42+
if self.platform == "linux/arm64":
43+
return "linux-aarch64"
44+
raise ValueError(f"Unknown platform {self.platform}")
45+
3846
def get_build_env(self):
3947
"""Return environment variables to be set.
4048
@@ -59,6 +67,7 @@ def get_build_env(self):
5967
# this exe should be used for installs after bootstrap with micromamba
6068
# switch this to /usr/local/bin/micromamba to use it for all installs
6169
("MAMBA_EXE", "${CONDA_DIR}/bin/mamba"),
70+
("CONDA_PLATFORM", self._conda_platform()),
6271
]
6372
if self._nb_requirements_file:
6473
env.append(("NB_REQUIREMENTS_FILE", self._nb_requirements_file))
@@ -160,13 +169,18 @@ def get_build_script_files(self):
160169
# major Python versions during upgrade.
161170
# If no version is specified or no matching X.Y version is found,
162171
# the default base environment is used.
163-
frozen_name = "environment.lock"
172+
frozen_name = f"environment-{self._conda_platform()}.lock"
164173
pip_frozen_name = "requirements.txt"
165174
if py_version:
166175
if self.python_version == "2.7":
176+
if "linux-64" != self._conda_platform():
177+
raise ValueError(
178+
f"Python version 2.7 {self._conda_platform()} is not supported!"
179+
)
180+
167181
# python 2 goes in a different env
168182
files[
169-
"conda/environment.py-2.7.lock"
183+
"conda/environment.py-2.7-linux-64.lock"
170184
] = self._kernel_environment_file = "/tmp/env/kernel-environment.lock"
171185
# additional pip requirements for kernel env
172186
if os.path.exists(os.path.join(HERE, "requirements.py-2.7.txt")):
@@ -176,12 +190,16 @@ def get_build_script_files(self):
176190
self._kernel_requirements_file
177191
) = "/tmp/env/kernel-requirements.txt"
178192
else:
179-
py_frozen_name = f"environment.py-{py_version}.lock"
193+
py_frozen_name = (
194+
f"environment.py-{py_version}-{self._conda_platform()}.lock"
195+
)
180196
if os.path.exists(os.path.join(HERE, py_frozen_name)):
181197
frozen_name = py_frozen_name
182198
pip_frozen_name = f"requirements.py-{py_version}.pip"
183199
else:
184-
raise ValueError(f"Python version {py_version} is not supported!")
200+
raise ValueError(
201+
f"Python version {py_version} {self._conda_platform()} is not supported!"
202+
)
185203
files[
186204
"conda/" + frozen_name
187205
] = self._nb_environment_file = "/tmp/env/environment.lock"
@@ -366,6 +384,10 @@ def get_env_scripts(self):
366384
""",
367385
)
368386
)
387+
if self.platform != "linux/amd64":
388+
raise RuntimeError(
389+
f"RStudio is only available for linux/amd64 ({self.platform})"
390+
)
369391
scripts += rstudio_base_scripts(self.r_version)
370392
scripts += [
371393
(

0 commit comments

Comments
 (0)