spkenv / spk

A Package Manager for high velocity software environments, built on spfs.
https://spkenv.dev
Apache License 2.0
40 stars 6 forks source link

Adds support to spk commands for requests files #1130

Closed dcookspi closed 2 weeks ago

dcookspi commented 2 months ago

This adds support to spk commands (bake, env, and explain) to let them take files of package requests with a ` request on their command lines.

The aim is to allow a larger number of package requests to be passed to spk command than would normally fit on a single command line. We're seeing examples of tools calling spk bake or spk explain with 350+ detailed package requests, e.g. python/3.10.8+r3/ABCDEF or my-long-tool-name:{run,build,with-some-feature}/==1.2.3.4+r1, not just python or mypkg. Some of them are starting to hit command line limits and/or are becoming unwieldy to edit.

Each file must a yaml formatted list of package or var requests.

Example file (can have whatever is valid for a package request, json blob, '@' specifier, etc.):

- python-pytest-watch/4
- python-pytest-cov/>=3.0.0
- python-pytest-asyncio/~1.0.0
- python-pytest-timeout
- mypkg@build
- { pkg: python-pylint/2.0.0, preReleasePolicy: IncludeAll }

Example command lines:

# 2 packages on the command line
> spk explain python/3 python-pytest

# a number of packages in a file
> spk explain myfile.spk.yaml

# mixing packages on the command line and from files
> spk explain python myfile.spk.yaml python-pytest myotherfile.spk.yaml

The package requests in the requests files are added to the list of requests first, before the ones on the command line.

See also:

rydrman commented 2 months ago

From the meeting today:

dcookspi commented 1 month ago

Updated this from the last meeting's feedback. Both pkg and var requests are supported now. The var requests are also used to make options for future templating renders inside parse_requests. The conversion from a var request to an OptionMap entry is a bit forced. Another way of doing that would be to separate out options into another field inthe requests file. I've put two commented out ways of doing that in the requests file struct as a starting point for further discussion on the options.

rydrman commented 1 month ago

From the meeting today:

Example:

api: v0/requirements
options: 
  pypk.version: 1.0.0
  python.abi: cp39
requirements:
  - pkg: python/3
  # we can't do this yet... but should be able to once #1135 is done
  - var: '{{ opts.python.abi }}' 
  - var: python.abi/cp39
  - {pkg: other, fromBuildEnv: true} # this is already an issue #1137
dcookspi commented 1 month ago

I've added the options field to the requests/requirements files, and updated the processing to keep command line opts as overrides with priority for templating and solver options. I've removed the lines that turned the command line options into var requests, and confirmed these options don't seem to influence the solve now.

This should be ready for another review.