-
Notifications
You must be signed in to change notification settings - Fork 17
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
npx nx generate @nxlv/python:uv-project
produces root pyproject.toml
#258
Comments
This was from an unexpected root level |
npx nx generate @nxlv/python:uv-project
affects apps outside the app being generatednpx nx generate @nxlv/python:uv-project
produces root pyproject.toml
And... now I know where the |
Hey @ahammond the root Is the If not, you could add |
I'm trying to add a containerized python lambda into an NX monorepo which already hosts a few hundred containerized node services. I can't reasonably follow an exclude pattern there. I could maybe have a separate directory instead of |
Got it, i guess you could add your python projects in a different folder (e.g apps/python) and change the root pyproject members to check only for this folder, instead of apps/* |
@ahammond I was playing with the uv workspaces, and I've noticed you can ignore the entire folder in the However, the way the uv workspace works, if you have a subfolder, like (e.g.
Which is pretty annoying btw. So, what I've noticed if you configure your root pyproject in this way:
it will only look for uv projects in the And if you have a subfolder in the python folder, you need to I guess that it is worth opening an issue in the uv github repo, because it seems wrong to me. Please let me know your thoughts about it. |
I'm thinking we'll just explicitly add every project we create instead of using any wildcards. |
That could a good option for your case, since your monorepo is mostly js libs/apps |
Hey @lucasvieirasilva .... thanks for the tip. This discussion essentially requires us to think about how we may want to organize code for a Python monorepo and I honestly don't know yet. This is the first and until we see a few more, it's difficult to establish a pattern. Having said that, it's an active discussion topic in both
Poetry seems ahead right now. My question for you though is - In the case of It seems possible with |
That seems like a reasonable approach! @avadhanij would this avoid us having a root level pyproject.toml? While the shared dev deps are nice, I'm not loving the idea of adding every python project in multiple places. For context, here's what our root level pyproject.toml looks like now:
That's with a single python lambda. Looks like we'd have to add it to
|
The more I read about workspaces, the more I believe that each |
Hmm, I'm not sure about that, the workspace helps to centralize the virtual environment, dev libraries, also more importantly, share the local libraries in easy way, If each app has its own workspace, you would need to install the dependencies for each app, Imagine installing ruff, pytest, autopep for several different apps, that would be bad for performance and also it would consume a lot of disk space. Nx with Js projects works in the same way, you don't need to have node_modules for each app with all the dependencies, even if you use npm workspaces, some dependencies would be installed at the root level. |
Hah, I agree. I was just expressing my apprehension to @ahammond privately. Couple of questions for you, and mainly because I am new to
|
About the root pyproject that you mentioned before, you don't need to keep adding them at the root pyproject if you place them in a different subfolder. I know it's not pretty to have a "apps/python" folder, but that would avoid the need to add them individually to the root pyproject, And uv should also improve their pattern to not force that every single folder in the member pattern is a uv project, it could be a docs folder that has nothing to with python. I'm going to find some time tomorrow to raise an issue in their repo asking about that. But until there, we had those 2 options, Add the members individually as you're doing. Or adding a different subfolder. |
Hi @avadhanij, yes, the plugin communicates to nx the dependency graph between the python projects, and if your lib1 changes, the app1 would be affected. You can run "nx graph" to see all the dependency graph. |
Really appreciate all the feedback, and testing for real the uv support so quickly. |
My major hesitation about sharing a lock file is the inevitable legacy app which demands an ancient version of a dependency and then holds back the upgrade for other apps. Maybe the answer there is to just bite the bullet and upgrade the legacy apps, but that’s never worked out for me in the past: we have always ended up forking things out or otherwise getting ugly. Huge appreciation for your responsiveness though! It’s really great to have this level of collaboration! |
That is fair point, I could mimic the way I did for Poetry and support both approaches, with and without shared virtual environment. It shouldn't be a big change from the existing code, I'll let you guys know once I have this supported. |
Hey @ahammond, @avadhanij I just merged a PR #260 to support You should start from scratch, delete the Python projects from your monorepo and start over. The If you decide to move to the workspace mode later you just need to run this command Please let me know if you have any questions. |
Current Behavior
Expected Behavior
Should not do things outside it's own
app/lambda-demo-module
directory.Steps to Reproduce
pyproject.toml
file which breaks non-python apps in monorepoNx Report
The text was updated successfully, but these errors were encountered: