Skip to content

Commit fd82601

Browse files
authored
[pixi] Change magic to pixi for environment and package management (#86)
This pull request introduces a migration from the `magic` CLI to the `pixi` CLI across various files and workflows, updating commands, configuration, and documentation to reflect the new tool. The changes ensure compatibility with `pixi` and streamline its integration into the project. ### Migration to `pixi` CLI #### Workflow Updates: * [`.github/workflows/run_tests.yaml`](diffhunk://#diff-cca7006f0f22de4c44b7c5ddeb1f17086a578485f0c98c49e644f6df601439eaL32-R61): Replaced all instances of `magic` commands with their `pixi` equivalents, including installation, adding paths, running tests, and pre-commit hooks. [[1]](diffhunk://#diff-cca7006f0f22de4c44b7c5ddeb1f17086a578485f0c98c49e644f6df601439eaL32-R61) [[2]](diffhunk://#diff-cca7006f0f22de4c44b7c5ddeb1f17086a578485f0c98c49e644f6df601439eaL71-R70) #### Configuration Updates: * [`.pre-commit-config.yaml`](diffhunk://#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9L6-R6): Updated the `mojo-format` hook to use `pixi run mojo format` instead of `magic run mojo format`. * `mojoproject.toml` → `pixi.toml`: Fully migrated the project configuration from `mojoproject.toml` to `pixi.toml`, reflecting changes in tasks, dependencies, and CLI commands. [[1]](diffhunk://#diff-1b0ef62120bccf4c05a76e60e13fe686f33eb92d5897b3f05e0c3f8d737fc5c0L1-L41) [[2]](diffhunk://#diff-b092682f0ad15a352f9fa2b0a67c992454b586275ee76b74a5839ab9afdf9894R1-R41) #### Documentation Updates: * [`README.md`](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L40-R51): Modified installation instructions and examples to use `pixi` commands instead of `magic`. Updated version compatibility table for clarity. [[1]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L40-R51) [[2]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L206-R208) * [`docs/readme_zht.md`](diffhunk://#diff-f1e4893f3ad60ada766d21c944cb25f9b07b6eb6343fb3225c2912bbf767849dL21-R23): Translated documentation updates to reflect the switch to `pixi` in Chinese-language instructions. [[1]](diffhunk://#diff-f1e4893f3ad60ada766d21c944cb25f9b07b6eb6343fb3225c2912bbf767849dL21-R23) [[2]](diffhunk://#diff-f1e4893f3ad60ada766d21c944cb25f9b07b6eb6343fb3225c2912bbf767849dL206-R207)
1 parent a1a1137 commit fd82601

File tree

8 files changed

+79
-73
lines changed

8 files changed

+79
-73
lines changed

.github/workflows/run_tests.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,36 @@ jobs:
2929
- name: Checkout repo
3030
uses: actions/checkout@v4
3131

32-
- name: Install magic
32+
- name: Install pixi
3333
run: |
34-
curl -ssL https://magic.modular.com/ | MAGIC_VERSION=0.7.0 bash
34+
curl -fsSL https://pixi.sh/install.sh | sh
3535
3636
- name: Add path
3737
run: |
38-
echo "MODULAR_HOME=$HOME/.modular" >> $GITHUB_ENV
39-
echo "$HOME/.modular/bin" >> $GITHUB_PATH
40-
echo "$HOME/.modular/pkg/packages.modular.com_mojo/bin" >> $GITHUB_PATH
38+
echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV
39+
echo "$HOME/.pixi/bin" >> $GITHUB_PATH
4140
4241
- name: Activate virtualenv
4342
run: |
4443
python3 -m venv $HOME/venv/
4544
. $HOME/venv/bin/activate
4645
echo PATH=$PATH >> $GITHUB_ENV
4746
48-
- name: Magic install
47+
- name: Pixi install
4948
run: |
50-
magic install
49+
pixi install
5150
5251
- name: Build package
5352
run: |
54-
magic run mojo package src/decimojo
55-
magic run mojo package src/tomlmojo
53+
pixi run mojo package src/decimojo
54+
pixi run mojo package src/tomlmojo
5655
cp decimojo.mojopkg tests/
5756
cp decimojo.mojopkg benches/
5857
mv tomlmojo.mojopkg tests/
5958
6059
- name: Run tests
6160
run: |
62-
magic run mojo test tests
61+
pixi run mojo test tests
6362
6463
- name: Install pre-commit
6564
run: |
@@ -68,5 +67,5 @@ jobs:
6867
6968
- name: Run pre-commit
7069
run: |
71-
magic install
70+
pixi install
7271
pre-commit run --all-files

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
# pixi environments
33
.pixi
4+
pixi.lock
45
*.egg-info
56
# magic environments
67
.magic

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
hooks:
44
- id: mojo-format
55
name: mojo-format
6-
entry: magic run mojo format
6+
entry: pixi run mojo format
77
language: system
88
files: '\.(mojo|🔥|py)$'
99
stages: [pre-commit]

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ This repository includes [TOMLMojo](https://github.com/forfudan/decimojo/tree/ma
3737

3838
DeciMojo is available in the [modular-community](https://repo.prefix.dev/modular-community) package repository. You can install it using any of these methods:
3939

40-
From the `magic` CLI, simply run ```magic add decimojo```. This fetches the latest version and makes it immediately available for import.
40+
From the `pixi` CLI, simply run ```pixi add decimojo```. This fetches the latest version and makes it immediately available for import.
4141

42-
For projects with a `mojoproject.toml`file, add the dependency ```decimojo = ">=0.3.0"```. Then run `magic install` to download and install the package.
42+
For projects with a `mojoproject.toml`file, add the dependency ```decimojo = ">=0.3.1"```. Then run `pixi install` to download and install the package.
4343

4444
For the latest development version, clone the [GitHub repository](https://github.com/forfudan/decimojo) and build the package locally.
4545

46-
| `decimojo` | `mojo` |
47-
| ---------- | ------ |
48-
| v0.1.0 | >=25.1 |
49-
| v0.2.0 | >=25.2 |
50-
| v0.3.0 | >=25.2 |
46+
| `decimojo` | `mojo` | package manager |
47+
| ---------- | ------------- | --------------- |
48+
| v0.1.0 | ==25.1 | magic |
49+
| v0.2.0 | ==25.2 | magic |
50+
| v0.3.0 | ==25.2 | magic |
51+
| v0.3.1 | >=25.2, <25.4 | pixi |
5152

5253
## Quick start
5354

@@ -203,8 +204,8 @@ Regular benchmarks against Python's `decimal` module are available in the `bench
203204

204205
After cloning the repo onto your local disk, you can:
205206

206-
- Use `magic run test` to run tests.
207-
- Use `magic run bench_decimal` to generate logs for benchmarking tests against `python.decimal` module. The log files are saved in `benches/decimal/logs/`.
207+
- Use `pixi run test` to run tests.
208+
- Use `pixi run bench_decimal` to generate logs for benchmarking tests against `python.decimal` module. The log files are saved in `benches/decimal/logs/`.
208209

209210
## Citation
210211

@@ -216,7 +217,7 @@ If you find DeciMojo useful for your research, consider listing it in your citat
216217
year = {2025},
217218
title = {An arbitrary-precision decimal and integer mathematics library for Mojo},
218219
url = {https://github.com/forfudan/decimojo},
219-
version = {0.3.0},
220+
version = {0.3.1},
220221
note = {Computer Software}
221222
}
222223
```

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This is a list of RELEASED changes for the DeciMojo Package. For the unreleased changes, please refer to **[changelog_unreleased](https://zhuyuhao.com/decimojo/docs/changelog_unreleased.html)**.
44

5+
## 06/06/2025 (v0.3.1)
6+
7+
DeciMojo v0.3.1 updates the codebase to Mojo 25.3 and replaces the `magic` package manager with `pixi`. This release enables you to use DeciMojo with the latest Mojo features and the new package manager.
8+
59
## 15/04/2025 (v0.3.0)
610

711
DeciMojo v0.3.0 introduces the arbitrary-precision `BigDecimal` type with comprehensive arithmetic operations, comparisons, and mathematical functions (`sqrt`, `root`, `log`, `exp`, `power`). A new `tomlmojo` package supports test refactoring. Improvements include refined `BigUInt` constructors, enhanced `scale_up_by_power_of_10()` functionality, and a critical multiplication bug fix.

docs/readme_zht.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ DeciMojo 爲 Mojo 提供了全面的定點數和整數運算庫,專爲處理
1818

1919
DeciMojo 可在 [modular-community](https://repo.prefix.dev/modular-community) 包倉庫中獲取。您可以使用以下任一方法進行安裝:
2020

21-
`magic` CLI,只需運行 ```magic add decimojo```。這會獲取最新版本並使其立即可用於導入。
21+
`pixi` CLI,只需運行 ```pixi add decimojo```。這會獲取最新版本並使其立即可用於導入。
2222

23-
對於帶有 `mojoproject.toml` 文件的項目,添加依賴 ```decimojo = ">=0.3.0"```。然後運行 `magic install` 來下載並安裝包。
23+
對於帶有 `mojoproject.toml` 文件的項目,添加依賴 ```decimojo = ">=0.3.1"```。然後運行 `pixi install` 來下載並安裝包。
2424

2525
如需最新的開發版本,請克隆 [GitHub 倉庫](https://github.com/forfudan/decimojo) 並在本地構建包。
2626

27-
| `decimojo` | `mojo` |
28-
| ---------- | ------ |
29-
| v0.1.0 | >=25.1 |
30-
| v0.2.0 | >=25.2 |
31-
| v0.3.0 | >=25.2 |
27+
| `decimojo` | `mojo` | 包管理 |
28+
| ---------- | ------------- | ------ |
29+
| v0.1.0 | >=25.1 | magic |
30+
| v0.2.0 | >=25.2 | magic |
31+
| v0.3.0 | >=25.2 | magic |
32+
| v0.3.1 | >=25.2, <25.4 | pixi |
3233

3334
## 快速入門
3435

@@ -203,8 +204,8 @@ DeciMojo 相較於 Python 的 `decimal` 模塊提供了卓越的性能,同時
203204

204205
在將倉庫克隆到本地磁盤後,您可以:
205206

206-
- 使用 `magic run test`(或 `maigic run t`)運行測試。
207-
- 使用 `magic run bench`(或 `magic run b`)生成對比 `python.decimal` 模塊的基準測試日誌。日誌文件保存在 `benches/logs/` 中。
207+
- 使用 `pixi run test`(或 `pixi run t`)運行測試。
208+
- 使用 `pixi run bench`(或 `pixi run b`)生成對比 `python.decimal` 模塊的基準測試日誌。日誌文件保存在 `benches/logs/` 中。
208209

209210
## 引用
210211

@@ -216,7 +217,7 @@ DeciMojo 相較於 Python 的 `decimal` 模塊提供了卓越的性能,同時
216217
year = {2025},
217218
title = {DeciMojo: A fixed-point decimal arithmetic library in Mojo},
218219
url = {https://github.com/forfudan/decimojo},
219-
version = {0.3.0},
220+
version = {0.3.1},
220221
note = {Computer Software}
221222
}
222223
```

mojoproject.toml

Lines changed: 0 additions & 41 deletions
This file was deleted.

pixi.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[project]
2+
authors = ["ZHU Yuhao 朱宇浩 <dr.yuhao.zhu@outlook.com>"]
3+
channels = ["https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
4+
# channels = ["https://conda.modular.com/max-nightly", "https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
5+
description = "An arbitrary-precision decimal and integer mathematics library for Mojo"
6+
license = "Apache-2.0"
7+
name = "decimojo"
8+
platforms = ["osx-arm64", "linux-64"]
9+
readme = "README.md"
10+
version = "0.3.1"
11+
12+
[dependencies]
13+
max = ">=25.2, <25.4"
14+
15+
[tasks]
16+
# format the code
17+
format = "pixi run mojo format ./"
18+
19+
# compile the package
20+
package_decimojo = "pixi run mojo package src/decimojo && cp decimojo.mojopkg tests/ && cp decimojo.mojopkg benches/ && rm decimojo.mojopkg"
21+
package_tomlmojo = "pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/"
22+
package = "pixi run format && pixi run package_decimojo && pixi run package_tomlmojo"
23+
p = "clear && pixi run package"
24+
25+
# clean the package files in tests folder
26+
clean = "rm tests/decimojo.mojopkg && rm benches/decimojo.mojopkg && rm tests/tomlmojo.mojopkg"
27+
c = "clear && pixi run clean"
28+
29+
# tests (use the mojo testing tool)
30+
test = "pixi run package && pixi run mojo test tests --filter"
31+
t = "clear && pixi run package && pixi run mojo test tests --filter"
32+
33+
# benches
34+
bench_decimal = "clear && pixi run package && cd benches/decimal && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
35+
bench_bigint = "clear && pixi run package && cd benches/bigint && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
36+
bench_biguint = "clear && pixi run package && cd benches/biguint && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
37+
bench_bigdecimal = "clear && pixi run package && cd benches/bigdecimal && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
38+
bench_dec = "pixi run bench_decimal"
39+
bench_bint = "pixi run bench_bigint"
40+
bench_buint = "pixi run bench_biguint"
41+
bench_bdec = "pixi run bench_bigdecimal"

0 commit comments

Comments
 (0)