rye icon indicating copy to clipboard operation
rye copied to clipboard

Replace pip-tools with Monotrail or Similar

Open mitsuhiko opened this issue 1 year ago • 7 comments

The use of pip-tools in rye is because this is what we use at @getsentry. It's however by no means perfect, among other things it does not have proper locking support and the resolver is very hacky. I would like to investigate alternatives. Options that might exist:

Related issues that this would close:

  • #82
  • https://github.com/mitsuhiko/rye/issues/200

mitsuhiko avatar May 18 '23 18:05 mitsuhiko

Hi 👋

Maybe you find this Makefile useful :) it uses pipgrip to to create (and later commit) a lockfile, and then uses that lockfile with pip's -c/--constraint flag in make install and in our Dockerfile. So the python package just has open version ranges, and the corresponding lockfile lives next to it.

.PHONY: lint
## Run linting
lint:
	pre-commit run --all-files

.PHONY: test
## Run tests
test:
	python -m pytest

.PHONY: install
## Install this repo, plus dev requirements, in editable mode
install:
	test -e requirements/pipgrip.lock || make lockfile
	pip install -r requirements/ci.txt -e . --constraint=requirements/pipgrip.lock
	pre-commit install

.PHONY: lockfile
## Create a lockfile for all python requirements.
lockfile:
	pip install -U pipgrip
	pipgrip -vv --sort --lock --tree .
	mv pipgrip.lock requirements/pipgrip.lock

.PHONY: help
## Print Makefile documentation
help:
	@perl -0 -nle 'printf("%-25s - %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w-]+):[^=]/gm' $(MAKEFILE_LIST) | sort
.DEFAULT_GOAL := help

in Github Actions, we block PRs if they updated prod.txt (which is read into the package's install_requires), but they forgot to run make lockfile:

    - name: Check whether requirements/prod.txt changed
      id: requirements-changed
      uses: tj-actions/changed-files@v34
      with:
        files: |
          requirements/prod.txt

    - name: Check whether make lockfile was forgotten
      if: steps.requirements-changed.outputs.any_changed == 'true'
      env:
        PIP_INDEX_URL: ${{ secrets.PIP_INDEX_URL }}
      run: |
        make lockfile
        test ! "$(git diff)" && echo "no changes" || ( git diff && exit 1 )

ddelange avatar May 23 '23 07:05 ddelange

That might be an interesting alternative to try.

mitsuhiko avatar May 23 '23 09:05 mitsuhiko

Hi,

You also might look at rustine and pubgrub-pyo3 but this is a rather quick hack, nothing production ready :-)

Regards, Charbel

charbeljc avatar May 29 '23 00:05 charbeljc

See also the prefix.dev resolver

tekumara avatar Sep 18 '23 12:09 tekumara

See also the prefix.dev resolver

There's also a noteworthy blog post from the developers of Rattler Resolver which is a port of libsolv to Rust. They started with conda package support and they have set their eyes on PyPI packages support next.

axel-kah avatar Oct 11 '23 19:10 axel-kah

There's also a noteworthy blog post from the developers of Rattler Resolver which is a port of libsolv to Rust. They started with conda package support and they have set their eyes on PyPI packages support next.

Seems like they already delivered: RIP (pip in Rust) 🦀

axel-kah avatar Oct 11 '23 22:10 axel-kah

I think this can be closed now

GeorchW avatar Mar 28 '24 09:03 GeorchW

xref https://github.com/astral-sh/rye/issues/1185

astrojuanlu avatar Jul 14 '24 22:07 astrojuanlu

Yes sorry -- we now use uv here.

charliermarsh avatar Jul 14 '24 22:07 charliermarsh