Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add justfile #1244

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ instance/

# Sphinx documentation
docs/_build/
docs/build/
docs/source/sg_execution_times.rst

# PyBuilder
target/
Expand Down
31 changes: 18 additions & 13 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
Types of contributions
----------------------

Report Bugs
Report bugs
~~~~~~~~~~~

Report bugs
Expand All @@ -24,26 +24,26 @@ If you are reporting a bug, please include:
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
Fix bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.

Implement Features
Implement features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.

Write Documentation
Write documentation
~~~~~~~~~~~~~~~~~~~

TorchIO could always use more documentation, whether as part of the
official TorchIO docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
Submit feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/fepegar/torchio/issues.
Expand All @@ -55,7 +55,7 @@ If you are proposing a feature:
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
Get started!
------------

Ready to contribute? Here's how to set up ``torchio`` for local development.
Expand All @@ -80,12 +80,12 @@ already be implemented.
4) Install your local copy into a virtual environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you use ``conda``, this is how you can set up your fork for local development::
`uv <https://docs.astral.sh/uv/>`_ is recommended for development.
You can use `just <https://just.systems/>`_ to set up the development environment.
This will 1) install ``uv`` if not found and 2) install ``torchio`` and all its
dependencies::

conda create --name torchioenv python --yes
conda activate torchioenv
pip install --editable ".[all]"
pre-commit install
just setup

5) Create a branch for local development using the issue number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -102,7 +102,7 @@ Now you can make your changes locally.
When you're done making changes, check that your changes pass the tests
using ``pytest``::

pytest -x
uv run pytest -x

7) Commit your changes and push your branch to GitHub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -130,6 +130,11 @@ time you modify them and reload them in the browser::

make livehtml

If you prefer to activate your environment manually or not use ``uv``,
add ``PREFIX=""`` to the command::

make html PREFIX=""

9) Submit a pull request on GitHub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
16 changes: 9 additions & 7 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXAUTOBUILD = sphinx-autobuild
SOURCEDIR = source
BUILDDIR = build
PREFIX = uv run

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(PREFIX) $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(PREFIX) $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

livehtml:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(PREFIX) $(SPHINXAUTOBUILD) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20 changes: 20 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
clean:
rm -rf .mypy_cache
rm -rf .pytest_cache
rm -rf .tox
rm -rf .venv
rm -rf dist
rm -rf **/__pycache__
rm -rf src/*.egg-info
rm -f .coverage
rm -f coverage.*

@install_uv:
if ! command -v uv >/dev/null 2>&1; then \
echo "uv is not installed. Installing..."; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
fi

setup: install_uv
uv sync --all-extras --all-groups
uv run pre-commit install
Loading