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

PyPI (pip) #1

Open
yarikoptic opened this issue Apr 15, 2024 · 4 comments
Open

PyPI (pip) #1

yarikoptic opened this issue Apr 15, 2024 · 4 comments
Labels
solution A solution for some distribution/platform/OS

Comments

@yarikoptic
Copy link
Member

https://pypi.org/project/pypi-timemachine/

@yarikoptic yarikoptic added the solution A solution for some distribution/platform/OS label Apr 15, 2024
@matrss
Copy link

matrss commented Aug 21, 2024

The pixi package manager has support for using packages from PyPI in addition to conda channels now. See e.g. here for more info: https://prefix.dev/blog/using_python_projects_with_pixi

This makes it possible to have one unified lock file for your dependencies from both PyPI and e.g. conda-forge. So it could support both #1 and #2.

@yarikoptic
Copy link
Member Author

@matrss thanks for the pointer! Do you know is there is some way to pin to a specific state/date of the entire pypi distribution? (To a degree that's what time machine would achieve)

@matrss
Copy link

matrss commented Aug 22, 2024

Sort of, but not exactly.

The workflow with pixi looks like this:

  1. pixi init a directory to turn it into a pixi project
  2. pixi add your dependencies, e.g. to get python and matplotlib from PyPI: pixi add python; pixi add --pypi matplotlib
  3. pixi shell to start a shell with the installed packages present, or pixi run <command> to execute a command in that environment

This will produce a pixi.toml file like this:

$ cat pixi.toml 
[project]
authors = ["Matthias Riße <m.risse@fz-juelich.de>"]
channels = ["conda-forge"]
description = "Add a short description here"
name = "pixi-demo"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[dependencies]
python = ">=3.12.5,<4"

[pypi-dependencies]
matplotlib = ">=3.9.2, <4"

which list a bit of metadata about the project and the dependencies that were added. At the same time, the pixi add commands will create an accompanying pixi.lock file, which describes the solved environment.

Now, as long as pixi.lock is not modified, all future invocations of pixi shell or pixi run will use the same environment. This file can be checked into version control and shared with others. To get an updated environment with the version constraints specified in pixi.toml the lock file must be recreated.

This isn't exactly what you were asking for, but I'd imagine it solves the same issue for which you would want to pin a state of PyPI. Does it?

@matrss
Copy link

matrss commented Aug 22, 2024

Ah, I just realized that pypi-timemachine behaves as an alternative server to point pip to. I'd imagine you could also just point pixi to that: https://pixi.sh/v0.27.1/reference/project_configuration/#alternative-registries. But again, I suspect that most issues this would solve are already addressed by the existence of the lock file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution A solution for some distribution/platform/OS
Projects
None yet
Development

No branches or pull requests

2 participants