Skip to content

Commit

Permalink
Update makefile and docs (#2432)
Browse files Browse the repository at this point in the history
Closes #2431

Relevant to #2425 because it removes `setuptools_scm` from docs.

Also brings in the `pyproject.toml` changes needed for #2386
  • Loading branch information
luizirber authored Feb 18, 2023
1 parent 48bc344 commit 7f9ca67
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ sourmash.egg-info
src/sourmash/version.py
*.DS_Store
.tox
src/sourmash/_lowlevel*.py
src/sourmash/_lowlevel/*
.env
Pipfile
Pipfile.lock
target/
.eggs
.asv
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ members = [
"src/core",
]
default-members = ["src/core"]

[profile.test]
opt-level = 1
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ all: build
.PHONY:

build: .PHONY
$(PYTHON) setup.py build_ext -i
$(PYTHON) -m pip install -e .

clean:
$(PYTHON) setup.py clean --all
rm -f src/sourmash/*.so
$(PYTHON) -m pip uninstall -y sourmash
rm -rf src/sourmash/_lowlevel
cd doc && make clean

install: all
$(PYTHON) setup.py install
install: build

dist: FORCE
$(PYTHON) -m build --sdist

test: .PHONY
tox -e py38
tox -e py39
cargo test

doc: .PHONY
Expand Down
25 changes: 16 additions & 9 deletions doc/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ for setting up Nix in your system (Linux or macOS).

Once Nix is installed, run
```
nix-shell
nix develop
```
to start an environment ready for [running tests and checks](#running-tests-and-checks).

Expand Down Expand Up @@ -121,11 +121,17 @@ There are three main components in the sourmash repo:
- The command-line interface (in `src/sourmash/cli`)
- The Rust core library (in `src/core`)

`setup.py` has all the configuration to prepare a Python package containing these three components.
`pyproject.toml` has all the configuration to prepare a Python package containing these
three components.
First it compiles the Rust core component into a shared library,
which is wrapped by [CFFI] and exposed to the Python module.
which is wrapped by [cffi] and exposed to the Python module.
These steps are executed by [maturin],
a modern [PEP 517]-compatible build backend for Python projects containing Rust
extensions.

[CFFI]: https://cffi.readthedocs.io/
[cffi]: https://cffi.readthedocs.io/
[maturin]: https://www.maturin.rs/
[PEP 517]: https://peps.python.org/pep-0517/

A short description of the high-level files and dirs in the sourmash repo:
```
Expand All @@ -150,14 +156,13 @@ A short description of the high-level files and dirs in the sourmash repo:
├── Makefile | Entry point for most development tasks
├── MANIFEST.in | Describes what files to add to the Python package
├── matplotlibrc | Configuration for matplotlib
├── shell.nix | Nix configuration for creating a dev environment
├── flake.nix | Nix definitions (package, dev env)
├── shell.nix | Nix config for creating a dev env (backward-compatible)
├── paper.bib | References in the JOSS paper
├── paper.md | JOSS paper content
├── pyproject.toml | Python project definitions (build system and tooling)
├── README.md | Info to get started
├── requirements.txt | Python dependencies for development
├── setup.py | Entry point for Python package setup
├── setup.cfg | Python package definitions
└── tox.ini | Configuration for test automation
```

Expand Down Expand Up @@ -253,7 +258,6 @@ including some tools for evaluating performance changes.

## Versioning

We use [`setuptools_scm`] to generate versions based on git tags.
Versions are tagged in a `vMAJOR.MINOR.PATH` format,
following the [Semantic Versioning] convention.
From their definition:
Expand All @@ -264,11 +268,14 @@ From their definition:
> MINOR version when you add functionality in a backwards compatible manner, and
> PATCH version when you make backwards compatible bug fixes.
[`setuptools_scm`]: https://github.com/pypa/setuptools_scm
[Semantic Versioning]: https://semver.org/

The Python version is not automated,
and must be bumped in `pyproject.toml` and `flake.nix`.

For the Rust core library we use `rMAJOR.MINOR.PATCH`
(note it starts with `r`, and not `v`).

The Rust version is not automated,
and must be bumped in `src/core/Cargo.toml`.

Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"maturin>=0.14.7,<0.15",
"maturin>=0.14.13,<0.15",
"cffi",
]
build-backend = 'maturin'
Expand Down Expand Up @@ -103,6 +103,7 @@ test = [
"pyyaml>=6,<7",
"recommonmark",
"hypothesis",
"build",
]
demo = [
"jupyter",
Expand Down Expand Up @@ -133,6 +134,10 @@ manifest-path = "src/core/Cargo.toml"
bindings = "cffi"
include = [
{ path = "include/sourmash.h", format = ["sdist","wheel"] },
{ path = "requirements.txt", format = ["sdist"] },
{ path = "Cargo.*", format = ["sdist"] },
{ path = "tests/*.py", format = ["sdist"] },
{ path = "citation.cff", format = ["sdist", "wheel"] },
]
features = ["maturin"]
locked = true
Expand Down

0 comments on commit 7f9ca67

Please sign in to comment.