I'm working on a project that has a distinct folder structure with separate /frontend and /backend directories. My backend has a `pyproject.toml` file which kind of looks like this:
[project]
name = "backend"
version = "0.1.0"
requires-python = ">=3.9,=0.7.3,<0.8.0"]
build-backend = "uv_build"
However, when I run `uv run start`, it only works if I keep the structure as /backend/src/backend. If I try to remove that /src from the structure, I get an error saying:
Failed to build `backend @ /file:******/backend` The build backend returned an error Call to `uv_build.build_editable` failed (exit status: 1)
[stderr]
Error: Missing source directory at: `src`
hint: This usually indicates a problem with the package or the build environment.
I'm hoping to have UV recognize everything in the root /backend folder instead. Is it possible to change this source structure?
3 Answers
You’re right about needing the src folder for library structures, but if you're building an app, there's flexibility! You can run UV with tools like Arkalos that set up a more suitable project structure for apps without forcing the src setup.
It looks like the default behavior of UV expects that src folder structure to properly locate your packages. However, you can customize it by tweaking your build-backend settings. Check out the documentation I found for setting the module root!
Thanks! I’ll look into that documentation. Is it straightforward?
Honestly, if you’re organizing your backend and frontend separately, maybe you should think about whether they should be two different projects. It might help keep things cleaner and easier to manage.
Just to clarify, that means the src structure is kind of just for libraries, right? Thanks for breaking that down!