Can I Change the Default Source Structure in UV for My Backend App?

0
7
Asked By CuriousCoder42 On

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

Answered By DevAdviceGuy On

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.

NewbieDeveloper -

Just to clarify, that means the src structure is kind of just for libraries, right? Thanks for breaking that down!

Answered By CodeExplorer98 On

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!

TechBeginner01 -

Thanks! I’ll look into that documentation. Is it straightforward?

Answered By FrontendFanatic On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.