-
Notifications
You must be signed in to change notification settings - Fork 1k
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
universal-lock: clean up lock file format #3611
Comments
Another piece here: we currently lose the file size (reported by the registry), which is used in downloading to facilitate prioritization (i.e., we start larger downloads earlier). (Done in #3652.) |
## Summary This PR changes the lock-file format to use inline tables for wheels and source distributions, which currently use separate tables that make the file harder to follow. ```diff [[distribution]] name = "typing-extensions" version = "4.10.0" source = "registry+https://pypi.org/simple" - [distribution.sdist] - url = "https://files.pythonhosted.org/packages/16/3a/0d26ce356c7465a19c9ea8814b960f8a36c3b0d07c323176620b7b483e44/typing_extensions-4.10.0.tar.gz" - hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb" - size = 77558 - - [[distribution.wheel]] - url = "https://files.pythonhosted.org/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl" - hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475" - size = 33926 + sdist = { url = "https://files.pythonhosted.org/packages/16/3a/0d26ce356c7465a19c9ea8814b960f8a36c3b0d07c323176620b7b483e44/typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb", size = 77558 } + wheel = [{ url = "https://files.pythonhosted.org/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475", size = 33926 }] ``` The downside is that the inline-tables end up quite long and TOML doesn't support line breaks in inline tables, yet. Part of #3611.
…tion.optional-dependencies` and `distribution.dev-dependencies`. The new style is more concise (see examples below) and it makes the association between a distribution and its dependencies clearer (previously, they were both individual `[[...]]` blocks separated by newlines). The style is optimized for small, meaningful diffs by placing each dependency on a single line with a final trailing comma. Whenever a dependency is added, removed or changed, there should be a one line diff in `distribution.dependencies`. The final trailing comma ensures that adding a dependency doesn't change the line ahead. Part of #3611 ## Examples ### Simple workspace package Before: ```toml [[distribution]] name = "bird-feeder" version = "1.0.0" source = "editable+packages/bird-feeder" [[distribution.dependencies]] name = "anyio" [[distribution.dependencies]] name = "seeds" ``` After: ```toml [[distribution]] name = "bird-feeder" version = "1.0.0" source = "editable+packages/bird-feeder" dependencies = [ { name = "anyio" }, { name = "seeds" }, ] ``` ### Flask Before: ```toml [[distribution]] name = "flask" version = "3.0.2" source = "registry+https://pypi.org/simple" sdist = { url = "https://files.pythonhosted.org/packages/3f/e0/a89e8120faea1edbfca1a9b171cff7f2bf62ec860bbafcb2c2387c0317be/flask-3.0.2.tar.gz", hash = "sha256:822c03f4b799204250a7ee84b1eddc40665395333973dfb9deebfe425fefcb7d", size = 675248 } wheels = [{ url = "https://files.pythonhosted.org/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl", hash = "sha256:3232e0e9c850d781933cf0207523d1ece087eb8d87b23777ae38456e2fbe7c6e", size = 101300 }] [[distribution.dependencies]] name = "blinker" [[distribution.dependencies]] name = "click" [[distribution.dependencies]] name = "itsdangerous" [[distribution.dependencies]] name = "jinja2" [[distribution.dependencies]] name = "werkzeug" [distribution.optional-dependencies] [[distribution.optional-dependencies.dotenv]] name = "python-dotenv" ``` After: ```toml [[distribution]] name = "flask" version = "3.0.2" source = "registry+https://pypi.org/simple" sdist = { url = "https://files.pythonhosted.org/packages/3f/e0/a89e8120faea1edbfca1a9b171cff7f2bf62ec860bbafcb2c2387c0317be/flask-3.0.2.tar.gz", hash = "sha256:822c03f4b799204250a7ee84b1eddc40665395333973dfb9deebfe425fefcb7d", size = 675248 } dependencies = [ { name = "blinker" }, { name = "click" }, { name = "itsdangerous" }, { name = "jinja2" }, { name = "werkzeug" }, ] wheels = [{ url = "https://files.pythonhosted.org/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl", hash = "sha256:3232e0e9c850d781933cf0207523d1ece087eb8d87b23777ae38456e2fbe7c6e", size = 101300 }] [distribution.optional-dependencies] dotenv = [ { name = "python-dotenv" }, ] ``` ### Forking Before: ```toml [[distribution]] name = "project" version = "0.1.0" source = "editable+." [[distribution.dependencies]] name = "package-a" version = "4.3.0" source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/" marker = "sys_platform == 'darwin'" [[distribution.dependencies]] name = "package-a" version = "4.4.0" source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/" marker = "sys_platform == 'linux'" [[distribution.dependencies]] name = "package-b" marker = "sys_platform == 'linux'" [[distribution.dependencies]] name = "package-c" marker = "sys_platform == 'darwin'" ``` After: ```toml [[distribution]] name = "project" version = "0.1.0" source = "editable+." dependencies = [ { name = "package-a", version = "4.3.0", source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/", marker = "sys_platform == 'darwin'" }, { name = "package-a", version = "4.4.0", source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/", marker = "sys_platform == 'linux'" }, { name = "package-b", marker = "sys_platform == 'linux'" }, { name = "package-c", marker = "sys_platform == 'darwin'" }, ] ```
Use indented inline tables for `distribution.dependencies`, `distribution.optional-dependencies` and `distribution.dev-dependencies`. The new style is more concise (see examples below) and it makes the association between a distribution and its dependencies clearer (previously, they were both individual `[[...]]` blocks separated by newlines). The style is optimized for small, meaningful diffs by placing each dependency on a single line with a final trailing comma. Whenever a dependency is added, removed or changed, there should be a one line diff in `distribution.dependencies`. The final trailing comma ensures that adding a dependency doesn't change the line ahead. Part of #3611 ## Examples ### Simple workspace package Before: ```toml [[distribution]] name = "bird-feeder" version = "1.0.0" source = "editable+packages/bird-feeder" [[distribution.dependencies]] name = "anyio" [[distribution.dependencies]] name = "seeds" ``` After: ```toml [[distribution]] name = "bird-feeder" version = "1.0.0" source = "editable+packages/bird-feeder" dependencies = [ { name = "anyio" }, { name = "seeds" }, ] ``` ### Flask Before: ```toml [[distribution]] name = "flask" version = "3.0.2" source = "registry+https://pypi.org/simple" sdist = { url = "https://files.pythonhosted.org/packages/3f/e0/a89e8120faea1edbfca1a9b171cff7f2bf62ec860bbafcb2c2387c0317be/flask-3.0.2.tar.gz", hash = "sha256:822c03f4b799204250a7ee84b1eddc40665395333973dfb9deebfe425fefcb7d", size = 675248 } wheels = [{ url = "https://files.pythonhosted.org/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl", hash = "sha256:3232e0e9c850d781933cf0207523d1ece087eb8d87b23777ae38456e2fbe7c6e", size = 101300 }] [[distribution.dependencies]] name = "blinker" [[distribution.dependencies]] name = "click" [[distribution.dependencies]] name = "itsdangerous" [[distribution.dependencies]] name = "jinja2" [[distribution.dependencies]] name = "werkzeug" [distribution.optional-dependencies] [[distribution.optional-dependencies.dotenv]] name = "python-dotenv" ``` After: ```toml [[distribution]] name = "flask" version = "3.0.2" source = "registry+https://pypi.org/simple" sdist = { url = "https://files.pythonhosted.org/packages/3f/e0/a89e8120faea1edbfca1a9b171cff7f2bf62ec860bbafcb2c2387c0317be/flask-3.0.2.tar.gz", hash = "sha256:822c03f4b799204250a7ee84b1eddc40665395333973dfb9deebfe425fefcb7d", size = 675248 } dependencies = [ { name = "blinker" }, { name = "click" }, { name = "itsdangerous" }, { name = "jinja2" }, { name = "werkzeug" }, ] wheels = [{ url = "https://files.pythonhosted.org/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl", hash = "sha256:3232e0e9c850d781933cf0207523d1ece087eb8d87b23777ae38456e2fbe7c6e", size = 101300 }] [distribution.optional-dependencies] dotenv = [ { name = "python-dotenv" }, ] ``` ### Forking Before: ```toml [[distribution]] name = "project" version = "0.1.0" source = "editable+." [[distribution.dependencies]] name = "package-a" version = "4.3.0" source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/" marker = "sys_platform == 'darwin'" [[distribution.dependencies]] name = "package-a" version = "4.4.0" source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/" marker = "sys_platform == 'linux'" [[distribution.dependencies]] name = "package-b" marker = "sys_platform == 'linux'" [[distribution.dependencies]] name = "package-c" marker = "sys_platform == 'darwin'" ``` After: ```toml [[distribution]] name = "project" version = "0.1.0" source = "editable+." dependencies = [ { name = "package-a", version = "4.3.0", source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/", marker = "sys_platform == 'darwin'" }, { name = "package-a", version = "4.4.0", source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/", marker = "sys_platform == 'linux'" }, { name = "package-b", marker = "sys_platform == 'linux'" }, { name = "package-c", marker = "sys_platform == 'darwin'" }, ] ```
For testing whether conflicts happen with independent updates to the lock file, I did something like this. To start:
Then I made two branches from this point: one where I changed I then tried this same example with Poetry. Starting with:
I then repeated the same process as above: creating two different branches from master, updating
|
Use indented inline tables for `distribution.dependencies`, `distribution.optional-dependencies` and `distribution.dev-dependencies`. The new style is more concise (see examples below) and it makes the association between a distribution and its dependencies clearer (previously, they were both individual `[[...]]` blocks separated by newlines). The style is optimized for small, meaningful diffs by placing each dependency on a single line with a final trailing comma. Whenever a dependency is added, removed or changed, there should be a one line diff in `distribution.dependencies`. The final trailing comma ensures that adding a dependency doesn't change the line ahead. Part of #3611 ## Examples ### Simple workspace package Before: ```toml [[distribution]] name = "bird-feeder" version = "1.0.0" source = "editable+packages/bird-feeder" [[distribution.dependencies]] name = "anyio" [[distribution.dependencies]] name = "seeds" ``` After: ```toml [[distribution]] name = "bird-feeder" version = "1.0.0" source = "editable+packages/bird-feeder" dependencies = [ { name = "anyio" }, { name = "seeds" }, ] ``` ### Flask Before: ```toml [[distribution]] name = "flask" version = "3.0.2" source = "registry+https://pypi.org/simple" sdist = { url = "https://files.pythonhosted.org/packages/3f/e0/a89e8120faea1edbfca1a9b171cff7f2bf62ec860bbafcb2c2387c0317be/flask-3.0.2.tar.gz", hash = "sha256:822c03f4b799204250a7ee84b1eddc40665395333973dfb9deebfe425fefcb7d", size = 675248 } wheels = [{ url = "https://files.pythonhosted.org/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl", hash = "sha256:3232e0e9c850d781933cf0207523d1ece087eb8d87b23777ae38456e2fbe7c6e", size = 101300 }] [[distribution.dependencies]] name = "blinker" [[distribution.dependencies]] name = "click" [[distribution.dependencies]] name = "itsdangerous" [[distribution.dependencies]] name = "jinja2" [[distribution.dependencies]] name = "werkzeug" [distribution.optional-dependencies] [[distribution.optional-dependencies.dotenv]] name = "python-dotenv" ``` After: ```toml [[distribution]] name = "flask" version = "3.0.2" source = "registry+https://pypi.org/simple" sdist = { url = "https://files.pythonhosted.org/packages/3f/e0/a89e8120faea1edbfca1a9b171cff7f2bf62ec860bbafcb2c2387c0317be/flask-3.0.2.tar.gz", hash = "sha256:822c03f4b799204250a7ee84b1eddc40665395333973dfb9deebfe425fefcb7d", size = 675248 } dependencies = [ { name = "blinker" }, { name = "click" }, { name = "itsdangerous" }, { name = "jinja2" }, { name = "werkzeug" }, ] wheels = [{ url = "https://files.pythonhosted.org/packages/93/a6/aa98bfe0eb9b8b15d36cdfd03c8ca86a03968a87f27ce224fb4f766acb23/flask-3.0.2-py3-none-any.whl", hash = "sha256:3232e0e9c850d781933cf0207523d1ece087eb8d87b23777ae38456e2fbe7c6e", size = 101300 }] [distribution.optional-dependencies] dotenv = [ { name = "python-dotenv" }, ] ``` ### Forking Before: ```toml [[distribution]] name = "project" version = "0.1.0" source = "editable+." [[distribution.dependencies]] name = "package-a" version = "4.3.0" source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/" marker = "sys_platform == 'darwin'" [[distribution.dependencies]] name = "package-a" version = "4.4.0" source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/" marker = "sys_platform == 'linux'" [[distribution.dependencies]] name = "package-b" marker = "sys_platform == 'linux'" [[distribution.dependencies]] name = "package-c" marker = "sys_platform == 'darwin'" ``` After: ```toml [[distribution]] name = "project" version = "0.1.0" source = "editable+." dependencies = [ { name = "package-a", version = "4.3.0", source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/", marker = "sys_platform == 'darwin'" }, { name = "package-a", version = "4.4.0", source = "registry+https://astral-sh.github.io/packse/0.3.29/simple-html/", marker = "sys_platform == 'linux'" }, { name = "package-b", marker = "sys_platform == 'linux'" }, { name = "package-c", marker = "sys_platform == 'darwin'" }, ] ```
Hi, do you have any plan regarding locking of build dependencies (build-system.requires) for sdists and source trees ? |
Not currently, but it would be a natural thing for us to support... It's somewhat expensive because it means we have to download the source distribution for all packages regardless of whether we can extract the metadata from a wheel alone. |
And will there be a mean for the sync/install command to abort if it has to download a build dependency that is not locked? |
@sbidoul Could you add a separate issue with some background on the motivation? |
All the issues above have been crossed off. Lets close this out for now and we can track new issues separately as they come up. |
In #3314, an initial version of a universal lock file format was added. It came with a lot of TODOs in the code and some uncertainties with the data model. Before we declare the lock file ready to use by users, we should take another pass over it and smooth things out. Here is a non-exhaustive list of things:
wheel
table. The same happens for sdists I believe. I think we would ideally not havewheel
orsdist
tables for distributions that have apath
ordirectory
orgit
source. I think the rule should be that ansdist
andwheel
table are only present if it's possible for more than one of them to exist. I think that only happens with registry dependencies.[distribution.dependencies]
to make the file easier to scan.source = "editable+."
which looks bad.source
(and possibly alsoversion
) from adistribution.dependency
entry when there is only one distribution with that package name.The text was updated successfully, but these errors were encountered: