AcademySoftwareFoundation / AcademySoftwareFoundation/rez

[Feature] Min/Max/Preferred Versions

Open
#631 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
1.1k
Forks
369
Avg merge
12d 3h
Merged PRs (30d)
5

Description

### Goal

Facilitate experimental and development overrides.

### Motivation

- Sometimes, asking for `rez>=2.28` and getting `2.30.0` if available is expected.
- Other times, asking for `maya` and getting `2018` despite `2019` being available is expected.

### Implementation

Normally, when you specify a minimum, it or a later available version is picked.

**pipeline/package.py**

```python
requires = ["rez>=2.28"]
```

If `2.29` is found, it gets picked. If `2.30` is found, it gets picked.

```bash
$ rez env pipeline # rez-2.30
$ rez env pipeline rez-2.28 # rez-2.28.3
$ rez env pipeline rez-2.21 # Not allowed
```

But what about the other way?

**pipeline/package.py**

```python
requires = ["maya>=2017"]
```

In this case, I'd like for `2017` to get picked, unless a newer version is explicitly asked for.

```bash
$ rez env pipeline # maya-2017
$ rez env pipeline maya-2019 # maya-2019
$ rez env pipeline maya-2016 # Not allowed
```

In some cases, the former is expected, and in others the latter is.

### Syntax

Some food for thought, this could be specified at the package-level.

**rez/package.py**

```python
version = "2.30.0"
order = "latest"
```

**maya/package.py**

```python
version = "2016.0.0"
order = "earliest"
```

Although for that to work we'd need to determine which of the released versions get to decide the order when two or more differ; e.g. the first found, the last released or via e.g. `rezconfig.py` which would strip away some of the nice compartmentalisation.

Furthermore, in addition to min/max, what about specifying a "preferred" version, such as..

```bash
$ rez env maya # 2017
$ rez env maya-2016 # 2016
$ rez env maya-2018 # 2018
$ rez env maya-2015 # Not allowed
$ rez env maya-2019 # Not allowed
```

Whereby 2017 is "preferred", minimum is 2016, and maximum is 2018.

E.g.

**pipeline/package.py**

```python
requires = ["maya>=2016,<=2018"]
preferred = ["maya-2016"]
```

In this case, the order is specified in a library requiring another library which might make actually be possible without using `rezconfig.py`. A package would know whether any of its requirements are defined as min/max or preferred.

### Alternative Syntax

More food for thought, what if the request format could capture whether one wanted a latest or earliest version using plus and minus signs?

**Latest**

```bash
$ rez env maya>=2018+ # 2019
```

The default, get me 2018 or later please.

**Earliest**

```bash
$ rez env maya>=2018- # 2018
```

The alternative, get me 2018 or earlier please.

**With Minimum**

```bash
$ rez env maya>2015,2018- # 2018
```

A minimum is included, which when used as a `requires` could be used like this:

```bash
$ rez env pipeline # maya-2018
$ rez env pipeline maya-2019 # maya-2019
$ rez env pipeline maya-2016 # maya-2016
```

**And Maximum**

```bash
$ rez env maya>2015,<2020,2018-
```

Let me know your thoughts.

Contributor guide

Open the contributing guide

Research direction

The issue names pipeline/package.py, rez/package.py, and rezconfig.py; begin by tracing how requirements are resolved for the shown rez env commands. Before implementation, settle whether package-level ordering, preferred versions, or +/- request syntax is intended. Done means one agreed version-selection behavior is specified and verified for minimum, maximum, and preferred-version cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.