Git/Version Control and Python Confusion

Hi,

I’m fairly new to the idea of version control, as for me it’s just a way to publicly store my code and allow contributors. However, I’m working on a large project and I’m getting very confused.

How is the actual code supposed to work with the project? I’m trying to access a custom module from dep/, but is my code actually supposed to look into dep/ and import the module, and are custom modules even supposed to be inside of dep/?

Also, I was looking at this guide on structuring a repository, but the same thing occurs but with different folders like res/. I have absolutely no idea if I am doing this correctly, or if version control is even worth it. I’ve looked at some examples, but they aren’t actual professional projects, just tutorials and whatnot.

Can someone please explain this to me? A hierarchical representation would be very helpful, and is the code even supposed to access these folders in the first place? If it does, refactoring my code will be fairly tedious, and I might need some help.

Thank you!

1 Like

what do you mean? In python you could just do:

from myFolderName.myModuleName import foo, bar

Is that what you are asking?

2 Likes

Not really, My dep/ folder would store multiple different packaged modules. Here’s an example.

dep -
    randomModule -
        __init__.py
        func.py
        anotherfunc.py
    anotherModule -
        __init__.py
        moreFunc.py
src -
    main.py

The code that would be inside src/ would have to go back to a parent directory, into dep/, choose a package, and import a file or even a specific function from that file. It just doesn’t seem right, even though I know dep/ and src/ folders are supposed to exist.

I never have seen any big open source python libraries use dep/ and src/, all the modules just go in src/. I recommend just putting everything inside src/

Can you link this guide and ensure it is for python? Remember a lot is up to preference.

2 Likes

That seems a lot more simple. Thank you! I’m still wondering, what would be the best way to structure it then? Does absolutely everything your project needs gets stored in src/?

Here’s Microsoft’s Terminal repository, which does use these dep/ and res/ folders that I’m getting confused about. It is in a different language though, so what would be the best structure for a Python project?

Linked the guide here and in the OP. I might be misinterpreting things, I’m still pretty new to version control and its practices.

Language matters a lot when configuring your code structure, especially for C and C related languages (as they don’t have easy to use imports and have more complex structures). The worst part is most tutorials about this kind of stuff assume C of C++ if you do not specify, probably because it is is more complex. For a python project, I recommend first:

  1. Decide the scale of the project
  2. Small project, do whatever you want
  3. Big project, format things properly, use the src directory for your library, and possibly a bin directory for your CLI tools. Also remember to clean out your poetry and .gitignore settings when using replit

Also, see my in-depth post about python coding standards: How to make a python library in replit

5 Likes

Thank you! This was really confusing to me and this really helps clarify. I’ll take a look at your post too, packages have been really annoying. Thanks again!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.