Reputation: 639
I am having some trouble understanding how to manage this code for my project. Due to how imports work in python, it's hard for me to have ONE git repo for all of my classes.
The directory layout is like this :
(ASSIGNMENT 3 GIT REPO)
Project/
Client/
Main.py
ClientHandler.py
ClientSoundManager.py
Server/
Main.py
ServerHandle.py
ServerUtil.py
Shared/
MathProcessor.py
DrawHandler.py
SoundProcessor.py
I have one git project -- "Assignment 3." In python I can't import MathProcessor in ServerHandle.py, and same for ClientHandler.py. My other option is to create separate repositories for each... and make it look like this --
(ASSIGNMENT 3 GIT REPO)
Project/
Client/
Shared/ (SHARED GIT REPO)
MathProcessor.py
DrawHandler.py
SoundProcessor.py
Main.py
CLientHandler.py
ClientSoundManager.py
Server/
Shared/ (SHARED GIT REPO)
MathProcessor.py
DrawHandler.py
SoundProcessor.py
Main.py
ServerHandle.py
ServerUtil.py
If I do that, then I'll have a GIT repo inside of a GIT repo... What is the proper way to manage this project so python imports don't have to be hacked in?
Upvotes: 2
Views: 1841
Reputation: 77902
This has nothing to do with git. You just need to have /path/to/wherever/you/cloned/Project
your sys.path
AND add the necessaries __init__.py
files in Project/Client
, Project/Server
and Project/Shared
to make the Python packages.
You'll find most relevant infos about imports, sys.path and packages here : http://docs.python.org/2/tutorial/modules.html
Upvotes: 4