Reputation: 1261
I have a project that uses a git submodule to import a python package from a private repository, which is then installed via pip. The structure is something like this:
my_project
_submodules
prvt_pkg
prvt_pkg
lib
__init__.py
types.py
__init__.py
prvt_pkg.py
setup.py
requirements.txt
app.py
(not sure if this makes a difference, but setup.py
looks like this:
import setuptools
from setuptools import find_packages
with open("readme.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name='prvt_pkg',
version='0.0.1',
author='...',
author_email='...',
description='...',
long_description=long_description,
long_description_content_type="text/markdown",
url='...',
project_urls={
"Bug Tracker": "..."
},
packages=find_packages(),
install_requires=[],
)
I am able to import the main class from prvt_pkg.py
like
from prvt_pkg.prvt_pkg import my_prvt_class
however, I would also like to import the pydantic types defined in _submodules/prvt_pkg/prvt_pkg/lib/types.py
like
from prvt_pkg.lib.types import MyType
but PyCharm is telling me that won't work
All of the __init__.py
files are empty.
Is there a way that I can achieve this? Thanks in advance
Upvotes: 0
Views: 49
Reputation: 1261
While writing up this question I found the solution, so decided to post anyway and provide that here.
What ended up fixing the problem was after running git submodule update --remote --merge
to pull in the changes (including the lib/types.py file), I needed to then run pip install _submodules/prvt_pkg
again to install the new version.
Upvotes: 1