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

pixi init --pyproject does not work with existing pyproject.toml file but poetry check validates status... author's line from [tool.poetry] which matches pixi.toml author's spec does not work #1687

Closed
2 tasks done
2themaxx opened this issue Jul 27, 2024 · 6 comments · Fixed by #1732
Labels
🐞 bug Something isn't working 🗒️ configuration Issue related to configuration of project or global behavior 👋 good first issue Good for newcomers

Comments

@2themaxx
Copy link

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

git clone https://github.com/microsoft/graphrag
git checkout 9d99f323eaa101c10166260c11948850e8087059
poetry check
pixi init --pyproject


####===== output from above commands below:
C:\Users\jai_m>git clone https://github.com/microsoft/graphrag
Cloning into 'graphrag'...
remote: Enumerating objects: 6052, done.
remote: Counting objects: 100% (1180/1180), done.
remote: Compressing objects: 100% (812/812), done.
remote: Total 6052 (delta 505), reused 526 (delta 343), pack-reused 4872
Receiving objects: 100% (6052/6052), 142.26 MiB | 20.04 MiB/s, done.
Resolving deltas: 100% (2659/2659), done.

C:\Users\jai_m\graphrag>git checkout 9d99f323eaa101c10166260c11948850e8087059
Note: switching to '9d99f323eaa101c10166260c11948850e8087059'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 9d99f32 Add encoding model to entity/claim extraction config sections (#740)

C:\Users\jai_m\graphrag>poetry check
All set!

C:\Users\jai_m\graphrag>pixi init --pyproject
  × failed to parse project manifest
   ╭─[pyproject.toml:1:1]
 1 │ [tool.poetry]
   · ┬
   · ╰── Missing field `project`
 2 │ name = "graphrag"
   ╰────


C:\Users\jai_m\graphrag>pixi --version
pixi 0.26.1

Issue description

The documentation at pixi.sh says that pixi works with existing pyproject.toml files. Poetry check works with the latest (as of this date) pull of the project. pixi however cannot parse the file at least not on Windows (if that makes any difference).

Expected behavior

I'm assuming that poetry/poe using pyproject.toml files that work should be in-scope and add pixi to the manifest without complaining about something that poetry says is valid. I would expect pixi to add the relevant sections to the pyproject.toml

I got the same behavior for an older version of pixi (0.25) and an older pull (c8aefb23cb2297dca9fb10cedbb8266e59f7029c) of the same repo. Updating the repo to the latest pull (see above) and pixi to the latest version using self-update does not make a difference.

Also, if it makes any difference, poetry is globally installed by pixi and I'm operating in windows.

@2themaxx 2themaxx added the 🐞 bug Something isn't working label Jul 27, 2024
@olivier-lacroix
Copy link
Contributor

Currently, the init operation requires the pyproject.toml to have the [project] table defined.

This indeeds differs from the spec (where that table is optional).

This is to ensure we can get a project name (whoch is required by pixi). We could always relax this constraint, but that will create more cases to handle to infer project name from all possible situations.

What do you think @tdejager ?

@2themaxx
Copy link
Author

2themaxx commented Jul 28, 2024

Maybe just document that in the documentation as a requirement? Copying the [tool.poetry] section of the pyproject.toml up above urps on the authors field due to differing requirements:

pixi init --pyproject
  × failed to parse project manifest
    ╭─[pyproject.toml:10:5]
  9 │ authors = [
 10 │     "Alonso Guevara Fernández <[email protected]>",
    ·     ─────────────────────────┬────────────────────────
    ·                              ╰── invalid type: string "Alonso Guevara Fernández <[email protected]>", expected a table with 'name' and 'email' keys
 11 │     "Andrés Morales Esquivel <[email protected]>",
    ╰────

Not looking to add complexity or relax the design principles of pixi. However, my first instinct was to copy the [tool.poetry] and use that as the project. but the author's line included in the graphrag project's pyproject.toml [tool.poetry] appears to match the approriate spec at:

https://pixi.sh/latest/reference/project_configuration/#authors-optional

but generates an error above when copying in the pyproject.toml....

I can delete the authors line, but at that point, I'm starting to manually mess with an existing pyproject.toml and having to hand-jam something that appears it should be working.

@2themaxx 2themaxx changed the title pixi init --pyproject does not work with existing pyproject.toml file but poetry check validates status pixi init --pyproject does not work with existing pyproject.toml file but poetry check validates status... author's line from [tool.poetry] which matches pixi.toml author's spec does not work Jul 28, 2024
@olivier-lacroix
Copy link
Contributor

Yeah, poetry are doing their own thing...

@ruben-arts
Copy link
Contributor

I think it improves the experience to not error on the existing format and if it can't read it, just add what pixi needs. Later we might add the reading of poetry information if that improves it even more.

@tdejager
Copy link
Contributor

I agree :)

@ruben-arts ruben-arts added 👋 good first issue Good for newcomers 🗒️ configuration Issue related to configuration of project or global behavior labels Aug 1, 2024
@ruben-arts
Copy link
Contributor

Added good first issue to this.

If you want to get started on this, he let pyproject = PyProjectToml::from_toml_str(&file)?; should not just be an error, but you should match on that error and do the pixi addition anyway.

Then tell the users the pyproject.toml is still unreadable because of some issue which would have been the result of the previous from_toml_str(&file)?.

This way you can allow the user to get the info that pixi would add but allows them to manually edit the file to what they want / pixi needs.

ruben-arts added a commit that referenced this issue Aug 5, 2024
This Fixes #1687 and
#1207 by keeping the
`[project]` table optional in `pyproject.toml`.

The `[project]` table had been made mandatory to make sure a name was
defined. Now, the project name is read from, in order of priority
 - the `[tool.pixi.project]` table
 - the `[project]` table
 - the `[tool.poetry]` table

The same is done for project description, version and authors.

During init, if the name cannot be read from the `[project]` table or
the `[tool.poetry]` table, a default name (inferred from the directory
name) is added to the `[tool.pixi.project]`

This PR also refactors handling of `pyproject.toml`: both pixi and
non-pixi `pyproject.toml` are now read into the same `PyProjectManifest`
struct, with existence checking of the `[tool.pixi.project]` table
managed outside of serde when necessary.

---------

Co-authored-by: Ruben Arts <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🗒️ configuration Issue related to configuration of project or global behavior 👋 good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants