astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

Creating multiple lock files #1138

Open djagoda881 opened 3 months ago

djagoda881 commented 3 months ago

Hello, I'm using Rye in a repository where I have a few optional dependencies group. I'm using this group depending on docker image that I want to create. So, for example:

[project]
name = "test"
version = "1.1.0"

dependencies = [
    "pandas>=2.2.2",
    "pyarrow>=16.1.0",

]
requires-python = ">=3.10"
readme = "README.md"

[project.optional-dependencies]

group1 = [
    "azure-core==1.30.1",
    "azure-storage-blob==12.20.0",
    "adlfs==2024.4.1",
]
group2 = [
    "awswrangler==3.7.3",
    "s3fs==2024.6.0",
]

I'd like to create my own custom .lock file, which I can use in my docker image. It will be cool to have an optional flag during execution of rye lock --fatures group1 for example --lock-file where I could specify a new lock file with default dependencies and dependencies from group1.

Whole command rye lock --fatures group1 --lock-file requirements-group1.

Files in the root repository folder after execution:

├── requirements-dev.lock
├── requirements-group1.lock
├── requirements.lock
chetangangappa94 commented 2 months ago

I second this, especially in cloud workflows such as lambdas where you will have multiple of them in a single repo, the ability to generate one lock file each for the respective lambdas greatly useful. PDM and Poetry both support these features. A syntax example to support this is as given below

rye lock --features group1 group2 --lock-file requirements-consolidated