prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
2.88k stars 156 forks source link

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

Closed pavelzw closed 1 month ago

pavelzw commented 1 month ago

Checks

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.

ruben-arts commented 1 month ago

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