Python Forum
Organization of project directories
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Organization of project directories
#1
Hi everyone! How do you organize your code? I like to separate everything into directories, preferably in the form of a monorepo. Custom libraries, services, etc. I then import everything using Poetry. An alternative is to keep either all scripts in one directory or in directories with the main script. I don't like this way of organizing, but unfortunately, my method (monorepo) causes a significant increase in memory usage. Each library and service has its own virtual environment, and many dependencies are repeated. Isn't there a better way?
Reply
#2
I fail to see why one method requires a virtual environment for each library/service, but the other does not. Can you explain why you think this is the case? Maybe you are wrong.

I don't think monorepo is a good way to organize code. I find them difficult to work with. But I don't see why a monorepo would not work for Python or why it would be any more inefficient than monorepos normally are.
Reply
#3
I think we might have misunderstood each other. I'm not saying that other approaches don't require a virtual environment or that they can't be used. I'm also not claiming that a monorepo doesn't work well for Python or that it's more or less efficient.

I'm simply asserting that if I use a monorepo and import my own libraries into other projects/services, I have dependencies redundancy.

Alternatively, I could create a simple directory structure like my_project/modules and my_project/main.py or app.py and import my modules in the app. But if I do it this way, and I have several independent sub-projects/services, each utilizing a script (with the same content) in modules, then I have code redundancy. I need to place the same code in each modules directory.

I hope this explanation is clear.

And one more thing - I assume upfront that I'm omitting something obvious. Blindsight ;p That's why I'm writing this here.
Reply
#4
FYI: I never start a bona fide project without first creating a virtual environment.

One of the main reasons is that each project can have it's own version of python.
There are many other benefits, such as keeping packages localized, and requirements to a minimum.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Listing directories (as a text file) kiwi99 1 848 Feb-17-2023, 12:58 PM
Last Post: Larz60+
  Virtual Environments - Organization (VS Code) JaysonWonder 11 1,870 Jan-26-2023, 11:34 PM
Last Post: Larz60+
  rename same file names in different directories elnk 0 720 Nov-04-2022, 05:23 PM
Last Post: elnk
  I need to copy all the directories that do not match the pattern tester_V 7 2,463 Feb-04-2022, 06:26 PM
Last Post: tester_V
  Python create directories within directories mcesmcsc 2 2,228 Dec-17-2019, 12:32 PM
Last Post: mcesmcsc
  Accessing files in various directories and folders ccuny 2 2,181 May-08-2019, 12:11 PM
Last Post: ccuny
  Creating directories from two lists QueenSveta 2 2,786 Jun-22-2018, 09:33 AM
Last Post: volcano63
  search file extention in sub directories mr_byte31 1 2,423 Feb-12-2018, 01:30 PM
Last Post: DeaD_EyE
  Decompressing bz2 in multiple sub-directories kiton 29 18,365 Apr-14-2017, 10:01 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020