Вопрос

I have a virturalenv for a network application. It has the following directory structure :

.
|-- main.py
|-- modules //(The name modules is domain specific, don't confuse with python modules)
|   |-- __init__.py
|   `-- plotter.py
|-- network
|   |-- __init__.py
|   |-- socket
|   |   |-- server.py
|   |   `-- tcp_server.py
|   `-- SocketServer
|       |-- tcp.py
|       `-- udp.py
|-- README.md
`-- r-ve (this is the virtualenv container)

The network folder handles connnection managament and modules folder depend on network to consume network data.

This project is version controlled via git-scm. Now I also have a dependency called gramme. I installed gramme via pip and it is present in r-ve(in the virtualenv). All modules depend on gramme (each module file uses import gramme)

To match the needs of the project, I'm hacking gramme as I'm coding modules(I have forked gramme on github). I want this hacked gramme available to the team and not the one that is available on pip. Also I want to version control gramme seperately on git (as a standalone repo)

Question 1) Is there a better way to import gramme in all files in the modules folder, rather than importing it in each file individually.

UPDATE : I was confused regarding question 1. Now its clear :)

Question 2) Where do I put the modified gramme library, so it can be version controlled seperately.

Это было полезно?

Решение

I don't really understand your first question. You always need to import a module in each file that uses it, that's just how Python works. But you would only install the dependency once, and since you're using virtualenv you can install your working version of gramme without any conflicts. Although I don't understand why you've got your "virtualenv container" separately from your code: your project should go inside the virtualenv, that's the whole point.

For your second question, you can install the dependency in "editable" mode inside your virtualenv by pointing pip to your github fork and using -e:

pip install -e git+git://github.com/shivek/gramme.git
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top