I like approaches of local package management in Flutter/Dart and Rust very well, and hope there could exist some similar solution in Python.
For example, I have a utility
python package at /path/of/the/utility
containing dozens of python files, and a myapp
package at /path/to/my/app
. For myapp
to depend on utility
, if I were using Flutter/Dart or using Rust, I could write down a line like:
utility:
path: /path/of/the/utility
And then happily import it like import 'package:utility/somefile.dart
. (The Rust case is similar so I do not repeat.)
However, with Python, I have not found out such solution (pip
does not seem to know this; neither is conda
). Currently I have to use the following ugly approach:
// myapp/somefile.py
import sys
sys.path.append('/path/of/the/utility')
import utility
and also manipulate my IDE (Intellij IDEA in my case) such that it understands this myapp
package depends on utility
package and do not give me a big red underline.
Remark: It may not be possible (is it?) to let /path
to be the package root and myapp
to be a subpackage, because: (1) The myapp
, for example, can be a Django project. (2) It will be hard to configure the ide (Intellij IDEA in my case) if the huge project is one Python package since it is mixed with other languages.
Question: Can I do something like the Flutter/Dart or Rust approach? Thanks!