Sorry for the simple question, but I’ve been through some tutorials and I’m still not sure what the best way is to solve my issue.
I’m trying to install my Python code locally to make it easier to import into other projects I’m developing (the core project is a simulator which I want to utilise in other applications).
I have the following package structure:
simulator/
+- simulator/
+- data/
+- model.yaml
+- __init__.py
+- sim.py
+- dynamics.py
+- config.py
+- setup.py
with this setup.py file:
from setuptools import setup, find_packages
setup(name='simulator',
version='0.1.0',
author='LC',
packages=find_packages(include=['simulator', 'simulator.*'])
)
Running pip install -e . --user
in the top-level simulator folder achieves the desired result of installing the package, e.g. I am able to use the statements
import simulator
from simulator.sim import run
from other code files on my system. But, say that sim
imports dynamics
. This breaks things – I get a ModuleNotFoundError
when the second statement is run.
What do I need to do to package the code when the files/modules within the package import each other in this way? I suppose I could import them all inside ‘init.py’, as in this article: https://changhsinlee.com/python-package/, but I don’t know if this will cause some circular import issues, or other unintended consequences.
(As an aside, how can I ensure the data folder and yaml file are included too?)