Skip to content

Commit 392cf34

Browse files
authored
Enable ARM64 on macOS for Miniforge and Mambaforge. (#331)
1 parent 2946f44 commit 392cf34

File tree

7 files changed

+140
-12
lines changed

7 files changed

+140
-12
lines changed

.github/workflows/example-13.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: "Example 13: Apple Silicon"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "*"
7+
push:
8+
branches:
9+
- "develop"
10+
- "main"
11+
- "master"
12+
schedule:
13+
# Note that cronjobs run on master/main by default
14+
- cron: "0 0 * * *"
15+
16+
jobs:
17+
example-13:
18+
# prevent cronjobs from running on forks
19+
if:
20+
(github.event_name == 'schedule' && github.repository ==
21+
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
22+
name: Ex13 (os=${{ matrix.os }} variant=${{ matrix.variant }})
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: ["macos-14"]
28+
variant: ["Miniforge3", "Mambaforge", "Miniconda", "no-variant"]
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: ./
32+
if: matrix.variant == 'Miniforge3' || matrix.variant == 'Mambaforge'
33+
id: setup-miniforge
34+
continue-on-error: true
35+
with:
36+
auto-update-conda: true
37+
architecture: arm64
38+
miniforge-variant: ${{ matrix.variant }}
39+
miniforge-version: latest
40+
- uses: ./
41+
if: matrix.variant == 'Miniconda'
42+
id: setup-miniconda
43+
continue-on-error: true
44+
with:
45+
auto-update-conda: true
46+
miniconda-version: latest
47+
- uses: ./
48+
if: matrix.variant == 'no-variant'
49+
id: setup-miniconda2
50+
continue-on-error: true
51+
with:
52+
miniforge-version: latest
53+
- name: Conda info
54+
shell: bash -el {0}
55+
run: conda info
56+
- name: Conda list
57+
shell: bash -el {0}
58+
run: conda list
59+
- name: Environment
60+
shell: bash -el {0}
61+
run: printenv | sort
62+
- name: Create an environment
63+
shell: bash -el {0}
64+
run: conda create -n unused --dry-run zlib
65+
- name: Run mamba
66+
if: matrix.variant != 'Miniconda'
67+
shell: bash -el {0}
68+
run: mamba --version
69+
- name: Install Python
70+
shell: bash -el {0}
71+
run: conda install -y python
72+
- name: Check arm64
73+
shell: bash -el {0}
74+
run: |
75+
python -c "import platform; assert platform.machine() == 'arm64', platform.machine()"

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# CHANGELOG
22

3+
## [v3.0.2] (2024-02-22)
4+
5+
### Fixes
6+
7+
- [#312] Enable ARM64 on macOS for Miniforge and Mambaforge including automatic
8+
architecture detection.
9+
10+
### Tasks and Maintenance
11+
12+
- [#327] Bump conda-incubator/setup-miniconda from 3.0.0 to 3.0.1
13+
- [#330] Bump actions/cache from 3 to 4
14+
- [#334] Bump undici from 5.27.2 to 5.28.3
15+
16+
[v3.0.2]: https://github.com/conda-incubator/setup-miniconda/releases/tag/v3.0.2
17+
[#312]: https://github.com/conda-incubator/setup-miniconda/pull/312
18+
[#327]: https://github.com/conda-incubator/setup-miniconda/pull/327
19+
[#330]: https://github.com/conda-incubator/setup-miniconda/pull/330
20+
[#334]: https://github.com/conda-incubator/setup-miniconda/pull/334
21+
322
## [v3.0.1] (2023-11-29)
423

524
### Fixes

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ possibility of automatically activating the `test` environment on all shells.
5858
| [Configure conda solver](#example-12-configure-conda-solver) | [![Configure conda solver][ex12-badge]][ex12] |
5959
| [Caching packages](#caching-packages) | [![Caching Example Status][caching-badge]][caching] |
6060
| [Caching environments](#caching-environments) | [![Caching Env Example Status][caching-env-badge]][caching-env] |
61+
| [Apple Silicon](#example-13-apple-silicon) | [![Apple Silicon][ex13-badge]][ex13] |
6162

6263
[ex1]:
6364
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml
@@ -107,6 +108,10 @@ possibility of automatically activating the `test` environment on all shells.
107108
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-12.yml
108109
[ex12-badge]:
109110
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-12.yml/badge.svg?branch=main
111+
[ex13]:
112+
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml
113+
[ex13-badge]:
114+
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml/badge.svg?branch=main
110115

111116
## Other Workflows
112117

@@ -596,6 +601,31 @@ jobs:
596601
python-version: "3.9"
597602
```
598603

604+
### Example 13: Apple Silicon
605+
606+
```yaml
607+
jobs:
608+
example-13:
609+
name: Ex13 (os=${{ matrix.os }})
610+
runs-on: ${{ matrix.os }}
611+
strategy:
612+
fail-fast: false
613+
matrix:
614+
os: ["macos-14"]
615+
steps:
616+
- uses: actions/checkout@v4
617+
- uses: ./
618+
id: setup-miniconda
619+
continue-on-error: true
620+
with:
621+
miniconda-version: latest
622+
- name: Check arm64
623+
shell: bash -el {0}
624+
run: |
625+
conda install -y python
626+
python -c "import platform; assert platform.machine() == 'arm64', platform.machine()"
627+
```
628+
599629
## Caching
600630

601631
### Caching packages

action.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,11 @@ inputs:
242242
default: "libmamba"
243243
architecture:
244244
description:
245-
'Architecture of Miniconda that should be installed. Default is "x64". The
246-
CPU architecture of the runner is not detected by the workflow.'
245+
'Architecture of Miniconda that should be installed. This is automatically
246+
detected by the runner. If you want to override it, you can use "x64",
247+
"x86", "arm64", "aarch64", "s390x".'
247248
required: false
248-
default: "x64"
249+
default: ""
249250
clean-patched-environment-file:
250251
description:
251252
"Whether a patched environment-file (if created) should be cleaned"

dist/setup/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -48605,8 +48605,6 @@ const RULES = [
4860548605
(i) => !!(i.installerUrl &&
4860648606
!constants.KNOWN_EXTENSIONS.includes(urlExt(i.installerUrl))) &&
4860748607
`'installer-url' extension '${urlExt(i.installerUrl)}' must be one of: ${constants.KNOWN_EXTENSIONS}`,
48608-
(i) => !!(!i.minicondaVersion && i.architecture !== "x64") &&
48609-
`'architecture: ${i.architecture}' requires "miniconda-version"`,
4861048608
(i) => !!(i.architecture === "x86" && !constants.IS_WINDOWS) &&
4861148609
`'architecture: ${i.architecture}' is only available for recent versions on Windows`,
4861248610
(i) => !!(!["latest", ""].includes(i.minicondaVersion) &&
@@ -48620,7 +48618,7 @@ function parseInputs() {
4862048618
return __awaiter(this, void 0, void 0, function* () {
4862148619
const inputs = Object.freeze({
4862248620
activateEnvironment: core.getInput("activate-environment"),
48623-
architecture: core.getInput("architecture"),
48621+
architecture: core.getInput("architecture") || process.arch,
4862448622
condaBuildVersion: core.getInput("conda-build-version"),
4862548623
condaConfigFile: core.getInput("condarc-file"),
4862648624
condaVersion: core.getInput("conda-version"),
@@ -48665,6 +48663,9 @@ function parseInputs() {
4866548663
if (errors.length) {
4866648664
throw Error(`${errors.length} errors found in action inputs`);
4866748665
}
48666+
if (core.isDebug()) {
48667+
core.info(JSON.stringify(inputs));
48668+
}
4866848669
return inputs;
4866948670
});
4867048671
}
@@ -49009,7 +49010,7 @@ function downloadMiniforge(inputs, options) {
4900949010
return __awaiter(this, void 0, void 0, function* () {
4901049011
const tool = inputs.miniforgeVariant.trim() || constants.MINIFORGE_DEFAULT_VARIANT;
4901149012
const version = inputs.miniforgeVersion.trim() || constants.MINIFORGE_DEFAULT_VERSION;
49012-
const arch = constants.MINIFORGE_ARCHITECTURES[inputs.architecture];
49013+
const arch = constants.MINIFORGE_ARCHITECTURES[inputs.architecture.toLowerCase()];
4901349014
// Check valid arch
4901449015
if (!arch) {
4901549016
throw new Error(`Invalid 'architecture: ${inputs.architecture}'`);

src/input.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ const RULES: IRule[] = [
6060
`'installer-url' extension '${urlExt(i.installerUrl)}' must be one of: ${
6161
constants.KNOWN_EXTENSIONS
6262
}`,
63-
(i) =>
64-
!!(!i.minicondaVersion && i.architecture !== "x64") &&
65-
`'architecture: ${i.architecture}' requires "miniconda-version"`,
6663
(
6764
i, // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015)
6865
) =>
@@ -84,7 +81,7 @@ const RULES: IRule[] = [
8481
export async function parseInputs(): Promise<types.IActionInputs> {
8582
const inputs: types.IActionInputs = Object.freeze({
8683
activateEnvironment: core.getInput("activate-environment"),
87-
architecture: core.getInput("architecture"),
84+
architecture: core.getInput("architecture") || process.arch,
8885
condaBuildVersion: core.getInput("conda-build-version"),
8986
condaConfigFile: core.getInput("condarc-file"),
9087
condaVersion: core.getInput("conda-version"),
@@ -136,5 +133,9 @@ export async function parseInputs(): Promise<types.IActionInputs> {
136133
throw Error(`${errors.length} errors found in action inputs`);
137134
}
138135

136+
if (core.isDebug()) {
137+
core.info(JSON.stringify(inputs));
138+
}
139+
139140
return inputs;
140141
}

src/installer/download-miniforge.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export async function downloadMiniforge(
1616
inputs.miniforgeVariant.trim() || constants.MINIFORGE_DEFAULT_VARIANT;
1717
const version =
1818
inputs.miniforgeVersion.trim() || constants.MINIFORGE_DEFAULT_VERSION;
19-
const arch = constants.MINIFORGE_ARCHITECTURES[inputs.architecture];
19+
const arch =
20+
constants.MINIFORGE_ARCHITECTURES[inputs.architecture.toLowerCase()];
2021

2122
// Check valid arch
2223
if (!arch) {

0 commit comments

Comments
 (0)