Skip to content

Commit

Permalink
Switch from make to just (#167)
Browse files Browse the repository at this point in the history
This reworks Markus to use uv and just for project commands. This
simplifies a lot of things like dealing with virtual environments.
  • Loading branch information
willkg committed Jan 2, 2025
1 parent 7ae69d2 commit 299aaba
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build/
dist/
.eggs/
.python-version
uv.lock
26 changes: 17 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ If you encounter any bugs, please write up an issue in the issue tracker.
Writing up issues
=================

Please write up issues in the `issue tracker
<https://github.com/willkg/markus/issues>`_.
Please write up issues in the
`issue tracker <https://github.com/willkg/markus/issues>`__.

If the issue is about a bug in Markus, please specify:

Expand All @@ -30,30 +30,38 @@ These things will help me figure out the problem faster.
Install for hacking
===================

Requirements:

* `uv <https://docs.astral.sh/uv/>`__
* `just <https://just.systems/>`__

Run::

# Clone the repository
$ git clone https://github.com/willkg/markus

# Create a virtualenvironment
...
# Create virtual environment and install Markus and dev requirements
$ just devenv

# Install Markus and dev requirements
$ pip install -e '.[dev,datadog,statsd]'
# View project commands
$ just


Documentation
=============

Documentation is written in reStructuredText and is in the ``docs/``
directory. We use `Sphinx <http://www.sphinx-doc.org/en/stable/>`_
directory. We use `Sphinx <http://www.sphinx-doc.org/en/stable/>`__
to build documentation.


Tests
=====

Run tests with `tox <https://tox.readthedocs.io/en/latest/>`_. This
will run all tests across all supported Python versions.
Test environments are defined with
`tox <https://tox.readthedocs.io/en/latest/>`_. This will run all tests across
all supported Python versions.

Tests are implemented with `pytest <https://docs.pytest.org/en/stable/>`__.

Tests are located in the ``tests/`` directory.
41 changes: 41 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Relative to docs/ directory
sphinxbuild := "../.venv/bin/sphinx-build"

@_default:
just --list

# Build a development environment
devenv:
uv sync --extra dev --extra datadog --extra statsd --refresh --upgrade

# Run tests and linting
test *args: devenv
tox {{args}}

# Format files
format: devenv
uv run tox exec -e py39-lint -- ruff format

# Lint files
lint: devenv
uv run tox -e py39-lint

# Build docs
docs: devenv
SPHINXBUILD={{sphinxbuild}} make -e -C docs/ clean
SPHINXBUILD={{sphinxbuild}} make -e -C docs/ doctest
SPHINXBUILD={{sphinxbuild}} make -e -C docs/ html

# Wipe dev environment and build artifacts
clean:
rm -rf .venv uv.lock
rm -rf build dist src/markus.egg-info .tox
rm -rf docs/_build/*
find src/markus/ tests/ -name __pycache__ | xargs rm -rf
find src/markus/ tests/ -name '*.pyc' | xargs rm -rf

# Build files for relase
build: devenv
rm -rf build/ dist/
uv run python -m build
uv run twine check dist/*
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dev = [
"tomli>=1.1.0; python_version < '3.11'",
"tox",
"tox-gh-actions",
"tox-uv",
"twine",
"wheel",
]
Expand Down Expand Up @@ -83,6 +84,7 @@ envlist =
py311
py312
py313
uv_python_preferences = only-managed
[gh-actions]
python =
Expand Down

0 comments on commit 299aaba

Please sign in to comment.