0

I'm not a Python packing/building expert but was trying to generate an executable for an application I wrote (targeting a Windows executable). Did some research and found PyInstaller very useful for a little project of mine, since it was basically including an external "cli.py" script along with a "setup.py" and running pyinstall on that directory to do the trick.

It comes out that now I have to do the same for a more "complex structured project". The project uses a git-submodule to point to another repo (of a Python module) and I should not be changing that folder code. The structure follows:

/my_app
|__ /moduleA (git_submodule)
|    |
|    |__/subModuleA1
|    |   |__ __init__.py
|    |   |__ <bunch of py scrips>
|    | 
|    |__ __init__.py
|    |__ scriptA.py
|
|__ /my_app_module
|    |
|    |__ __init__.py
|    |__ <couple of py scripts that imports moduleA stuff and should be made an executable app>
|
|__ cli.py (call a main from my_app_module)
|__ setup.py (point to a main from my_app_module)

My problem: not sure if it is a PyCharm issue as asked here (Pycharm imports from Git Submodule), but when I open this "my_app" folder as a Project in PyCharm it requires me to update all the internal imports of that git-submodule. For example:

  • The scriptA.py imports something from subModuleA1 like:
    • from subModuleA1 import abc
  • Now that the submodule is included, I do have to update it to
    • from moduleA.subModuleA1 import abc

I just wanted to import some "moduleA" stuff to use in "my_app_module"

The problem is that I'm having to change another repo code just so PyCharm does not complain on my imports but I should not have to change that submodule internal code to use it, right?

Not sure if it's PyCharm stuff, or my lack of knowledge on Python modules/packing but would be ver helpful if someone has a suggestion on how to organise this project the best way.

Thanks in advance :)

Thales
  • 63
  • 1
  • 7

1 Answers1

1

In PyCharm, you can right click on your moduleA and click "Mark Directory as" => "Source Root".

But I am not sure if this will work after you created an executable. There are multiple Questions to this issue and I am fighting with this myself. Maybe it can help if you to add moduleA to the python path inside /my_app_module before you import it:

import sys
sys.path.append("moduleA")
from subModuleA1 import abc

See this Question for more Infos.

CodePrinz
  • 445
  • 5
  • 8