Skip to content

Commit ca301b3

Browse files
Merge pull request #14 from maxencefaldor/uv
Migrate from `pip` to `uv`
2 parents e955248 + a0da9c3 commit ca301b3

115 files changed

Lines changed: 2872 additions & 1119 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Deploy Package"
2+
3+
on:
4+
push:
5+
tags:
6+
# Publish on any tag starting with a `v`, e.g. v1.2.3
7+
- v*
8+
9+
jobs:
10+
run:
11+
name: "Deploy Package"
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write # IMPORTANT: mandatory for making GitHub Releases
16+
id-token: write # IMPORTANT: mandatory for sigstore
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: true
25+
26+
- name: Build
27+
run: uv build
28+
29+
- name: "Publish to PyPI"
30+
run: uv publish -t ${{ secrets.PYPI_API_TOKEN }}
31+
32+
- name: Sign the dists with Sigstore
33+
uses: sigstore/gh-action-sigstore-python@v3.0.0
34+
with:
35+
inputs: >-
36+
./dist/*.tar.gz
37+
./dist/*.whl
38+
- name: Create GitHub Release
39+
env:
40+
GITHUB_TOKEN: ${{ github.token }}
41+
# Repo clone is required for --notes-from-tag to work
42+
run: |
43+
gh repo clone '${{ github.repository }}'
44+
cd ${{ github.event.repository.name }}
45+
gh release create '${{ github.ref_name }}' --verify-tag --notes-from-tag --title '${{ github.ref_name }}' ${{ contains(github.ref_name, 'dev') && '--prerelease --latest=false' || '--latest=true' }}
46+
cd ..
47+
- name: Upload artifact signatures to GitHub Release
48+
env:
49+
GITHUB_TOKEN: ${{ github.token }}
50+
# Upload to GitHub Release using the `gh` CLI.
51+
# `dist/` contains the built packages, and the
52+
# sigstore-produced signatures and certificates.
53+
run: >-
54+
gh release upload
55+
'${{ github.ref_name }}' dist/**
56+
--repo '${{ github.repository }}'

.github/workflows/ruff.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Ruff
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.py"
7+
- "pyproject.toml"
8+
- ".github/workflows/ruff.yml"
9+
pull_request:
10+
paths:
11+
- "**.py"
12+
- "pyproject.toml"
13+
- ".github/workflows/ruff.yml"
14+
15+
jobs:
16+
ruff:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
# Use ruff twice for linting and formatting.
21+
# See https://github.com/astral-sh/ruff-action/issues/23#issuecomment-2525574730
22+
- uses: astral-sh/ruff-action@v3
23+
- uses: astral-sh/ruff-action@v3
24+
with:
25+
args: "format --check"

.github/workflows/tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.py"
7+
- "pyproject.toml"
8+
- ".github/workflows/tests.yml"
9+
pull_request:
10+
paths:
11+
- "**.py"
12+
- "pyproject.toml"
13+
- ".github/workflows/tests.yml"
14+
15+
jobs:
16+
tests:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
25+
- name: Install the project
26+
run: uv sync --all-extras --dev
27+
28+
- name: Run pytest
29+
run: uv run pytest tests/

.gitignore

Lines changed: 13 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,24 @@
1-
# Datasets
2-
data/
3-
1D-ARC/
4-
5-
# Byte-compiled / optimized / DLL files
1+
# Python-generated files
62
__pycache__/
7-
*.py[cod]
8-
*$py.class
9-
10-
# C extensions
11-
*.so
12-
13-
# Distribution / packaging
14-
.Python
3+
*.py[oc]
154
build/
16-
develop-eggs/
175
dist/
18-
downloads/
19-
eggs/
20-
.eggs/
21-
lib/
22-
lib64/
23-
parts/
24-
sdist/
25-
var/
266
wheels/
27-
share/python-wheels/
28-
*.egg-info/
29-
.installed.cfg
30-
*.egg
31-
MANIFEST
32-
33-
# PyInstaller
34-
# Usually these files are written by a python script from a template
35-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36-
*.manifest
37-
*.spec
38-
39-
# Installer logs
40-
pip-log.txt
41-
pip-delete-this-directory.txt
42-
43-
# Unit test / coverage reports
44-
htmlcov/
45-
.tox/
46-
.nox/
47-
.coverage
48-
.coverage.*
49-
.cache
50-
nosetests.xml
51-
coverage.xml
52-
*.cover
53-
*.py,cover
54-
.hypothesis/
55-
.pytest_cache/
56-
cover/
57-
58-
# Translations
59-
*.mo
60-
*.pot
61-
62-
# Django stuff:
63-
*.log
64-
local_settings.py
65-
db.sqlite3
66-
db.sqlite3-journal
67-
68-
# Flask stuff:
69-
instance/
70-
.webassets-cache
71-
72-
# Scrapy stuff:
73-
.scrapy
74-
75-
# Sphinx documentation
76-
docs/_build/
77-
78-
# PyBuilder
79-
.pybuilder/
80-
target/
81-
82-
# Jupyter Notebook
83-
.ipynb_checkpoints
7+
*.egg-info
848

85-
# IPython
86-
profile_default/
87-
ipython_config.py
88-
89-
# pyenv
90-
# For a library or package, you might want to ignore these files since the code is
91-
# intended to run in multiple environments; otherwise, check them in:
92-
# .python-version
93-
94-
# pipenv
95-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
97-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
98-
# install all needed dependencies.
99-
#Pipfile.lock
100-
101-
# poetry
102-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103-
# This is especially recommended for binary packages to ensure reproducibility, and is more
104-
# commonly ignored for libraries.
105-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106-
#poetry.lock
107-
108-
# pdm
109-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110-
#pdm.lock
111-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112-
# in version control.
113-
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
114-
.pdm.toml
115-
.pdm-python
116-
.pdm-build/
117-
118-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
119-
__pypackages__/
120-
121-
# Celery stuff
122-
celerybeat-schedule
123-
celerybeat.pid
124-
125-
# SageMath parsed files
126-
*.sage.py
127-
128-
# Environments
129-
.env
9+
# Virtual environments
13010
.venv
131-
env/
132-
venv/
133-
ENV/
134-
env.bak/
135-
venv.bak/
136-
137-
# Spyder project settings
138-
.spyderproject
139-
.spyproject
14011

141-
# Rope project settings
142-
.ropeproject
143-
144-
# mkdocs documentation
145-
/site
12+
# ruff
13+
.ruff_cache
14614

14715
# mypy
148-
.mypy_cache/
149-
.dmypy.json
150-
dmypy.json
151-
152-
# Pyre type checker
153-
.pyre/
154-
155-
# pytype static type analyzer
156-
.pytype/
16+
.mypy_cache
15717

158-
# Cython debug symbols
159-
cython_debug/
18+
# pytest
19+
.pytest_cache
16020

161-
# PyCharm
162-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
163-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
164-
# and can be added to the global gitignore or merged into this file. For a more nuclear
165-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
166-
#.idea/
21+
# Custom
22+
output/
23+
examples/1D-ARC/
24+
examples/data/

CONTRIBUTING.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ Follow these steps to contribute code:
1212

1313
1. Fork the CAX repository by clicking the Fork button on the repository page. This creates a copy of the CAX repository in your own account.
1414

15-
2. Install Python >= 3.10 locally in order to run tests.
15+
2. Clone your fork and go at the root of the repository.
1616

17-
3. `pip` installing your fork from source. This allows you to modify the code and immediately test it out:
17+
3. Install your fork from source using [https://docs.astral.sh/uv/](`uv`).
1818

1919
```bash
20-
git clone https://github.com/maxencefaldor/cax
21-
cd cax
22-
pip install -e ".[dev]" # Installs CAX from the current directory in editable mode.
20+
uv run python -c "import cax; print(cax.__doc__)"
2321
```
2422

2523
4. Add the CAX repository as an upstream remote, so you can use it to sync your changes.
@@ -39,8 +37,8 @@ And implement your changes using your favorite editor.
3937
6. Make sure your code passes CAX’s lint and type checks, by running the following from the top of the repository:
4038

4139
```bash
42-
ruff format .
43-
ruff check .
40+
uv ruff check . # Linting
41+
uv ruff format . # Formatting
4442
```
4543

4644
7. Make sure the tests pass by running the following command from the top of the repository:

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ Here, you can see the basic CAX API usage:
6666

6767
```python
6868
import jax
69+
from flax import nnx
70+
6971
from cax.core.ca import CA
7072
from cax.core.perceive import ConvPerceive
7173
from cax.core.update import NCAUpdate
72-
from flax import nnx
7374

7475
seed = 0
7576

@@ -105,16 +106,16 @@ For a more detailed overview, get started with this notebook [![Colab](https://c
105106

106107
## Installation ⚙️
107108

108-
You will need Python 3.10 or later, and a working JAX installation.
109+
You will need Python 3.10 or later, and a working JAX installation installed in a virtual environment.
109110

110-
Then, install CAX from PyPi:
111+
Then, install CAX from PyPi with `uv`:
111112
```
112-
pip install cax
113+
uv pip install cax
113114
```
114115

115-
To upgrade to the latest version of CAX, you can use:
116+
or with `pip`:
116117
```
117-
pip install --upgrade git+https://github.com/maxencefaldor/cax.git
118+
pip install cax
118119
```
119120

120121
## Citing CAX 📝

cax/core/__init__.py

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

cax/types.py

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

examples/00_getting_started.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@
738738
],
739739
"source": [
740740
"import PIL\n",
741+
"\n",
741742
"from cax.utils.emoji import get_emoji\n",
742743
"\n",
743744
"size = 40\n",

examples/10_elementary_ca.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@
6161
"source": [
6262
"import jax.numpy as jnp\n",
6363
"import mediapy\n",
64-
"from cax.models.elementary import ElementaryCA\n",
65-
"from flax import nnx"
64+
"from flax import nnx\n",
65+
"\n",
66+
"from cax.models.elementary import ElementaryCA"
6667
]
6768
},
6869
{

0 commit comments

Comments
 (0)