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 always writes to pyproject.toml if it exists #1615

Closed
2 tasks done
pavelzw opened this issue Jul 15, 2024 · 1 comment · Fixed by #1640
Closed
2 tasks done

pixi init always writes to pyproject.toml if it exists #1615

pavelzw opened this issue Jul 15, 2024 · 1 comment · Fixed by #1640
Labels
🐞 bug Something isn't working ✨ enhancement Feature request 🗒️ configuration Issue related to configuration of project or global behavior

Comments

@pavelzw
Copy link
Contributor

pavelzw commented Jul 15, 2024

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

$ ls
pyproject.toml
$ cat pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "my-project"
version = "0.2.1"
requires-python = ">=3.9"
dependencies = [
    "polars >=0.14.24,<2",
]
$ pixi init
✔ Added package 'my-project' as an editable dependency.
✔ Initialized project in /private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.dYEm4nFQSn/.
$ ls
pyproject.toml
$ cat pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "my-project"
version = "0.2.1"
requires-python = ">=3.9"
dependencies = [
    "polars >=0.14.24,<2",
]


[tool.pixi.project]
channels = ["conda-forge", "https://conda.prod.quantco.cloud/get/qc-internal"]
platforms = ["osx-arm64"]

[tool.pixi.pypi-dependencies]
my-project = { path = ".", editable = true }

[tool.pixi.tasks]

Issue description

When executing pixi init, pixi doesn't create a pixi.toml but instead writes to pyproject.toml, even if I didn't specify it via --pyproject. I personally like to keep my pyproject.toml and pixi.toml configuration separate as I can ensure that I don't use pixi's pip functionality this way.

Expected behavior

I would expect that pixi always creates a pixi.toml and only adds to pyproject.toml if specified via --pyproject.
Alternatively, we could interactively prompt the user whether they want to have their pixi configuration in pixi.toml or pyproject.toml.

@pavelzw pavelzw added the 🐞 bug Something isn't working label Jul 15, 2024
@ruben-arts
Copy link
Contributor

I've found this to be wrong as well.
I was lately thinking of making the pixi init a more interactive tool. Allowing all settings to be set through cli as well. And possibly giving some tips.

e.g.

$ pixi init
Setting up a pixi project:
1. Which manifest format do you want to use?
  > `pixi.toml`
  - `pyproject.toml`
2. Do you want to use "folder name" as the project name? (enter for yes/ input other name for no)
3. Which platforms is your project going to support?
 [x] your platform
 [ ] linux-64
 [ ] osx-64
 [ ] etc
4. Possibly more options....

Created the following content for you: 
<cat of the added information to the manifest>

Next steps:
- Add packages with `pixi add`
- Run tasks in the environment with `pixi run`
- Add tasks with `pixi task add [name] [command]`
- More info in our documentation: https://pixi.sh

@ruben-arts ruben-arts added ✨ enhancement Feature request 🗒️ configuration Issue related to configuration of project or global behavior labels Jul 16, 2024
ruben-arts added a commit that referenced this issue Aug 5, 2024
…1640)

Adds a dialog for `pyproject.toml` use, and an option to overwrite the
dialog with `--format pixi`
```
> pixi init --format pixi # forces to always use pixi.toml
# And:
> touch pyproject.toml
> pixi init

A 'pyproject.toml' file already exists.
Do you want to extend it with the [tool.pixi] configuration? [y/N]
```

Fixes #1615 #1207

---------

Co-authored-by: Bas Zalmstra <[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 ✨ enhancement Feature request 🗒️ configuration Issue related to configuration of project or global behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants