3

Short Story:

I have a very big python project

It is comprised of
ServiceA, ServiceB, ServiceC and so on.

For modularity, each service has its own virtual environment.
Each service needs some foo() from each other service.

ServiceA does import package_a
ServiceB does import package_b
ServiceC does import package_c
and so on.

I don't want to make a single environment for all services, as it would make maintenance very cumbersome.

What is a good way to integrate such a project to work together, while keeping modularity?


Long Story:

I have a very big project with 25+ big modules which communicate with one another.
They all use a single, extremely large environment for all dependencies.

It has come to a point where upgrading a package in one module can (and often does) break other modules.
Pycharm's indexing also takes much longer then it should.
Installing packages on a new machine takes much longer than it should
The worst is of course the fear of upgrading, due to the increased chance of breaking everything.

Most of the modules only need a subset of all the installed packages.

All of this is in python 2.7, and we want to upgrade to python 3, which can't be done all at once, due to project size.
We would have to migrate one module at a time, while maintaining system functionality along the way, for business purposes, and for test-ability purposes.

I believe this would require some modules having their own interpreter, while still somehow working with the others.


How can it be done?

Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • Did you managed to solve that? I would like hear about it. – S.B Oct 22 '21 at 23:35
  • 1
    @SorousHBakhtiary I did not. One possible way is to define an API for each service, and run it independently of the others, either in different processes or in different servers. Have them communicate via that API. importing and function calling is not available AFAIK – Gulzar Oct 24 '21 at 08:51

1 Answers1

0

I think there is no term 'Module' in Pycharm as shown in the following screenshot. What we can do is to add multiple folders under the project. However, python interpreter can only be bundled to the project, other than each folder.

Pycharm ScreenShot

Eric Yu
  • 441
  • 3
  • 8
  • My "modules" are already in folders, all using the same interpreter. How can I make them independent of the global environment, while still working together? – Gulzar May 19 '19 at 14:52