Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi @DavidVujic ,

We migrated our polylith monorepo a couple of months ago from Poetry to uv, and had this issue with a new joiner setting up our repo that python would not find the modules in bases and components folder.

I suspect Poetry polylith plugins had created the required pythonpath additions for python to find these modules, but as UV only uses the client, these did not get created.

I went through documentation and did not find any step for UV, would you be able to clarify if this is missing from documentation or we missed a specific section in it?

Thx in advance

You must be logged in to vote

Replies: 1 comment · 9 replies

Comment options

Hi @yann-combarnous, do you use the hatch build backend or the uv build backend?

You must be logged in to vote
9 replies
@DavidVujic
Comment options

I could add a "manual hook" in the poly tool that does things as for the PDM tool (linked in previous mesage).

uv build backend users could then run a second command after the "uv sync" to get their environment set up (i.e. autocomplete and navigate through the code base as expected).

The workflow would be something like this:

uv sync
uv run poly <a-new-command>

Would that be useful @yann-combarnous? Otherwise, you can have the hatch backend in the root pyproject.toml and the uv build backend in the projects. Then there won't be any need to add this.

@yann-combarnous
Comment options

I think a new command would be useful for these systems that do not support hooks, indeed. Hopefully you already have the logic in place, and this would just be extending the public API available through CLI ?

@DavidVujic
Comment options

Yes, I'm thinking about something in the existing CLI. I'll have a look at it within the next few days.

Meanwhile, for your team to not be blocked, you can "hack" the existing ".pth" file that is isn the venv folder (python3.xx/site-packages":
In that file, you probably have an absolute path to the root of the repo. Just add two additional rows in there: the absolute path to "bases" and "components".

I think that should work. If uv sync cleans that out on each run, then you can create an additional file in that folder "python_polylith.pth" with those paths. That's basically how I intend to solve it with the command.

@yann-combarnous
Comment options

Yes, we hacked a script to edit Python path rather atm, instead of using .pth files, so no hurry. Thx for the support

@DavidVujic
Comment options

I have added a new command, that I believe will solve this: poly env setup. Use this with the uv sync command:

uv sync
uv run poly env setup

Announced here #404

Please let me know how this works out for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.