Skip to content

Commit

Permalink
chore: Use arm64 micromamba for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
corker committed Sep 13, 2024
1 parent 01dc123 commit 51ba280
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Bug-fixes within the same version aren't needed
## Master
-->
### 0.1.24

* Use arm64 micromamba for Linux

### 0.1.23

* Fix error when missing name in the environment file
Expand Down
44 changes: 28 additions & 16 deletions src/micromamba/downloadMicromamba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { URL } from 'url'
import sh from '../sh'
import * as os from 'os'

// See: https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html#linux-and-macos

const arch = os.arch()

export const _downloadMicromamba = async (url: string, tar: Writable): Promise<void> => {
try {
await _downloadMicromamba1(url, tar)
Expand Down Expand Up @@ -55,30 +59,38 @@ export const downloadMicromambaWin = async (cwd: string): Promise<void> => {
await _downloadMicromamba(url, stream)
}

const makeMacDownloadArch = (): string => {
const arch = os.arch()
switch (arch) {
case 'x64':
return '64'

case 'arm64':
return arch

default:
throw new Error(`${arch} CPU architecture is not supported by micromamba`)
}
}

export const downloadMicromambaMac = async (cwd: string): Promise<void> => {
const url = `https://micromamba.snakepit.net/api/micromamba/osx-${makeMacDownloadArch()}/latest`
function getUrl() {
switch (arch) {
case 'x64':
return `https://micromamba.snakepit.net/api/micromamba/osx-64/latest`
case 'arm64':
return `https://micromamba.snakepit.net/api/micromamba/osx-arm64/latest`
default:
throw new Error(`${arch} CPU architecture is not supported by micromamba`)
}
}
const url = getUrl()
const stream = tar.x({ cwd, strip: 1 }, ['bin/micromamba'])
await _downloadMicromamba(url, stream)
await sh.chmodR('755', cwd)
await sh.chmod('755', path.join(cwd, 'micromamba'))
}

export const downloadMicromambaLinux = async (cwd: string): Promise<void> => {
const url = 'https://micromamba.snakepit.net/api/micromamba/linux-64/latest'
function getUrl() {
switch (arch) {
case 'x64':
return `https://micromamba.snakepit.net/api/micromamba/linux-64/latest`
case 'arm64':
return `https://micromamba.snakepit.net/api/micromamba/linux-aarch64/latest`
case 'ppc64':
return `https://micromamba.snakepit.net/api/micromamba/linux-ppc64le/latest`
default:
throw new Error(`${arch} CPU architecture is not supported by micromamba`)
}
}
const url = getUrl()
const stream = tar.x({ cwd, strip: 1 }, ['bin/micromamba'])
await _downloadMicromamba(url, stream)
await sh.chmodR('755', cwd)
Expand Down

0 comments on commit 51ba280

Please sign in to comment.