sanders41 / python-project-generator

Generates a Python project structure for starting new projects
MIT License
4 stars 2 forks source link

Add Pixi as an option for project manager #465

Open apcamargo opened 5 hours ago

apcamargo commented 5 hours ago

Pixi offers great convenience for people who rely on the Conda ecosystem, particularly for projects that depend on non-Python packages. Since Pixi supports pyproject.toml files, creating a Pixi project becomes as simple as including a [tool.pixi.project] section in the pyproject.toml file and populating it. The default configuration might look like this:

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"]

Users can then add other sections as needed, such as [tool.pixi.dependencies] for non-PyPI dependencies.

sanders41 commented 5 hours ago

I'm assuming there would also need to be updates to the dependencies section of the pyproject.toml? I don't use conda, and therefore don't use pixi, so I don't know enough about it to add it myself. If you want to create a PR to add it I'll accept it.

apcamargo commented 4 hours ago

The dependency section and the dependencies in pyproject.toml would remain unchanged, with all dependencies being pulled from PyPI. The only addition would be the [tool.pixi.project] section.

On second thought, since Pixi is agnostic to the Python build system the user chooses (setuptools, hatchling, etc.), it might not be ideal to present it as an alternative to existing options. Instead, it could be a simple Yes/No (by default, No) question that adds the following to pyproject.toml:

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"]
sanders41 commented 4 hours ago

I have never used conda so a question, are there now or possibly in the future other things conda users would want? If so maybe the yes/no question could be something like "add conda extras" or something like that? If pixi is the only thing you can think of it could just be something like "include pixi".

Again knowing nothing about conda, would platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"] include all of these platorms, or only the platform the user is on?

apcamargo commented 4 hours ago

Having these platforms specified will prompt Pixi to search for Conda packages built for each one. For instance, if you are using a macOS machine and the project specifies platforms = ["linux-64", "win-64"], Pixi will raise an error if you attempt to install the project:

  × The current platform does not satisfy the minimal virtual package requirements
  ╰─▶ the project does not support 'osx-64'

To ensure compatibility, it is advisable to include the four major platforms. You can find more details in the documentation: https://pixi.sh/latest/features/multi_platform_configuration/

Regarding channels, conda-forge is a reliable default as it contains packages that cater to the needs of the majority. Those working in bioinformatics can easily add Bioconda manually as needed.

sanders41 commented 4 hours ago

Got it. I'm fine with adding this if you want to make a PR.

sanders41 commented 3 hours ago

Also, if you get stuck and need help let me know and I can help you through it.