1

Warning: Python newbie.

I have two Python projects A and B.

A depends on B.

I'm using PyBuilder to build both projects and I am struggling to link B into A.

My thoughts are I somehow need to install project B via pip or some-other method in the same way I would install pandas.

Then in A, declare B as a module dependency and I can then import it.

Does this make sense in the world of Python? I have a setup.py for each project but they prob need some changes or PyBuilder needs to be told that module B is located in XYZ private git repo. When I run pyb --debug I can see all dependencies are looked for in a location where by module is not present.

Please advise, thanks.

JARC
  • 5,288
  • 8
  • 38
  • 43
  • Is there any need to build the projects seperately? If not, simply import B into A and make A a module. Furthermore: On which platform are you? – Dschoni Feb 09 '17 at 16:16
  • Most probably you can locally install module B using your `setup.py` file with `python setup.py install` and then use that to import it into A. – Dschoni Feb 09 '17 at 16:18
  • @Dschoni yes this is why I believe is the approach, its just getting that to work nicely – JARC Feb 09 '17 at 16:44
  • Mac, but will be deployed on ubuntu within a Docker container. – JARC Feb 09 '17 at 16:45
  • Can you expand a little, why you want to build the projects at all? Is there a need for the inclusion of unit tests? Complicated compiling of header files? Dependency handling? – Dschoni Feb 09 '17 at 16:58
  • So A is a module of quant/math functions, and B is really just an i.o gateway containing Kafka or whatever. I want the quant lib to be just that, a re-usable library just like pandas and for B to say I depend on A and treat it like it in the same way it would handle any other 3rd party python module. – JARC Feb 10 '17 at 14:58
  • That sounds as in your use case building of A is a little over-the-top for what you want to achieve. Just keep the python file of A at some location and import it whenever you need it. If you distribute B, bundle up A with it and build them together as one module or package (mind the difference). However. If you want to keep things tidy and modular (and e.g. want to distribute A without B), build and install A and introduce the dependency in B. Handle that inside pybuilder or distutils etc. – Dschoni Feb 13 '17 at 11:19
  • 1
    Ok got this figured out as I initially wanted - having two projects but one depending on the other. I used pybuilder to make the setup.py files and docker to for deployment which make life very simple (in the end). – JARC Feb 20 '17 at 17:17
  • @Dschoni So to answer the earlier question. Yes pybuilder for structure, unit testing, dependencies, distribution zip and auto setup.py creation. I didn't to bundle them up bec I wanted separate Git repos for the core and others for IO such as Kafka or REST. Keeps the projects smaller and focused. In the end Docker makes this very achievable due to the nature of Python modules being installed. – JARC Feb 24 '17 at 08:57

0 Answers0