I have the following folder structure
|
|- src
| |- mypackage
| | |- __init__.py
| | |- mymodule.py
| |- utils.egg
|- main.py
in mymodule.py
file I can import the egg adding it to the sys.path
as
import sys
sys.path.append('src/utils.egg')
import utils
When calling main.py
everything works fine (python -m main
).
The problem comes from pylint
. First, it shows the following message in mymodule.py
file
Unable to import 'utils' pylint(import-error)
if I ask for suggestions (CRTL + Space
) when importing I got
utils.build
.dist
.utils
.setup
# |- suggestions
And from utils.utils
I can acces the actual classes / functions in utils
module. Of course if I import utils.utils
, when executing the main
script, an importing error pops up.
In case you wonder the EGG-INFO/SOURCE.txt
file looks like
setup.py
utils/__init__.py
utils/functions.py
utils.egg-info/PKG-INFO
utils.egg-info/SOURCES.txt
utils.egg-info/dependency_links.txt
utils.egg-info/top_level.txt
utils/internals/__init__.py
utils/internals/somemodule.py
utils/internals/someothermodule.py
Also, there aren't build
nor dist
folder in the egg.
This is an issue with Pylint itself and not the Python extension, so it will come down to however you need to configure Pylint.
As for whether you should copy an egg around or install it, you should be installing it into your virtual environment, or at least copying over the appropriate .pth
file to make the egg directory work appropriately.