Skip to content

Add pixi support #319

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

Merged
merged 8 commits into from
Feb 5, 2025
Merged

Conversation

FloLangenfeld
Copy link
Contributor

@FloLangenfeld FloLangenfeld commented Jan 30, 2025

This PR adds support for the pixi as a potential backend. This would allow users to use packages from the conda ecosystem.

Description

Pixi manages a lockfile in a similar fashion as poetry, except it works with packages from both PyPI and conda. The main difference is the lockfil format, as pixi's lockfile format is YAML. The main changes will be to:

  • support yaml files parsing
  • parse the pixi lockfile
  • add pixi.lock to the python-polylith list of lock files
  • add the yaml component to the python-polylith-cli project and the new dependency to pyyaml to the corresponding pyproject.toml files
  • add a unit-test for the new feature
  • update the documentation accordingly

Motivation and Context

All current backends supported by python-polylith are PyPI-based. Some packages are only available through the conda ecosystem, though. This PR would solve this limitation.

How Has This Been Tested?

So far, I've made a prototype of the changes envisioned, and tested it with the poly libs and poly check commands to ensure that the third-party libraries are either found or missing as one may expect.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

@DavidVujic DavidVujic self-requested a review January 30, 2025 10:04
@FloLangenfeld
Copy link
Contributor Author

Still need to add a few things (a unit test and a proper documentation, mostly)

Not source whether the brand new yaml component is required as it only contains a single function...

@DavidVujic
Copy link
Owner

Great! ⭐

I will be away for a few days, attending FOSDEM 25. But will have a closer look when I'm back (next week).

@DavidVujic
Copy link
Owner

This project is a Polylith project itself ♾️ and you can use the poly commands to check things if you like (using poetry poly ...)

@FloLangenfeld
Copy link
Contributor Author

FloLangenfeld commented Jan 31, 2025

Hello @DavidVujic ,

Seems ok for my point of view.

Regarding the docs, do you want me to open a PR in the python-polylity-docs repo? And to create an example python-polylith-example-pixi repo? Let me know your thoughts on these points ;-)

Happy FOSDEM

@DavidVujic
Copy link
Owner

Hello @DavidVujic ,

Seems ok for my point of view.

Regarding the docs, do you want me to open a PR in the python-polylity-docs repo? And to create an example python-polylith-example-pixi repo? Let me know your thoughts on these points ;-)

Happy FOSDEM

An example repo would be great!

@FloLangenfeld
Copy link
Contributor Author

Hello @DavidVujic ,
Seems ok for my point of view.
Regarding the docs, do you want me to open a PR in the python-polylity-docs repo? And to create an example python-polylith-example-pixi repo? Let me know your thoughts on these points ;-)
Happy FOSDEM

An example repo would be great!

Agreed. I'll made an example, working pixi repo based on the other example repos (uv, rye, pants, etc) and with the same components, etc

Copy link

sonarqubecloud bot commented Feb 5, 2025

Copy link
Owner

@DavidVujic DavidVujic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thank you! 👏 ⭐

@DavidVujic DavidVujic merged commit 3e0ade0 into DavidVujic:main Feb 5, 2025
3 checks passed
@FloLangenfeld
Copy link
Contributor Author

Hello @DavidVujic,

Thanks for merging this PR.

I'm currently working on a pixi-based python-polylith-example repositore, but the package building feature (using the pixi build command) is still experimental and has limited capabilities. So far, I wasn't able to add a polylith plugin to the build backend, hence I cannot use the hooks or list the required bricks to package.

I was able to generate a conda package by copying the required bricks folder in the project directory (i.e. copying bases/example/consumer, components/example/log and components/example/kafka into the directory projects/consumer_project/consumer_project) prior to run pixi build, though. So a workaround would be to define a couple of pixi tasks to handle the copy (and removing) of the bricks as well as the building process. That might be enough for an example repo, but not enough for a production repository.

What do you think about that?

@DavidVujic
Copy link
Owner

DavidVujic commented Feb 12, 2025 via email

@FloLangenfeld
Copy link
Contributor Author

Looks like that's exactly what I need! Nice! Let me toy a bit with that. I'll let you know when I had something polished enough.

Thank you very much for that hint ;-)

@FloLangenfeld
Copy link
Contributor Author

Here is the example repository adapted to pixi. The poly build setup / teardown commands are indeed helpfull!

I've tested all projects I can (except for the AWS lambda project) using a local Quetz instance. The basic workflow I've followed

  • build a conda package from the project folder
pixi run poly build setup
pixi build
pixi run poly build teardown
  • upload the conda package to my quetz instance and add my quetz instance to the list of channels from which packages can be downloaded and installed
  • install the project package
pixi add my_package
  • test (using the entrypoint, or a pixi task)
pixi run start  # whenever a pixi task is defined
# or
pixi run consumer  # whenever an entrypoint is defined

I've changed the projects' README accordingly. So far, I'm not aware of a way to install a conda package from a local file, so I could not fit to the docker examples and I turned them into full pixi examples (but I could turn them into docker as a docker image for pixi exists.

Let me know what think!

PS: I'll be completely offline till Monday so I would not be able keep working on that for the next 3-4 days ;-)

@DavidVujic
Copy link
Owner

This is great! ⭐ I would like to link to your example repo from the readme and also in the docs, would that be ok with you?

@FloLangenfeld
Copy link
Contributor Author

Yes, sure! I will try to update it once the pixi build feature will be stabilized (hopefully soon)

@DavidVujic
Copy link
Owner

I've added the Pixi repo to the docs here: https://davidvujic.github.io/python-polylith-docs/examples/

@FloLangenfeld
Copy link
Contributor Author

Thanks for letting me know! Awesome!

There is just a typo in my last name (Langenfeld instead of Lagenfeld) and it will be perfect ;-)

@DavidVujic
Copy link
Owner

My apologies! 🙇 I have updated the page now 🙏

@FloLangenfeld
Copy link
Contributor Author

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants