Suppose a large-scale project is being developed in Python 3.7. Some layered architecture is chosen: "clean architecture", "onion" or "hexagonal". The Dependency rule in it only allows inward-looking dependencies; http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html.
In some languages this rule is supported by build tools (e.g., gradle, maven or sbt), which define explicit dependencies between sub-projects; e.g., https://stackoverflow.com/questions/27984854/enforcing-layered-architecture-in-java. This, however, doesn't seem possible in Python 3. The only solutions I've come up with, like a separate Python project or a microservice per layer, seem overly complicated.
Specifically, suppose the Application layer can depend on the Domain layer, but not vice versa.
- What can be a solution in Python 3.7 to maintain this dependency structure?
- How could modules in Domain be technically disallowed to import from Application modules ?
Extra: My current solution is to emulate sub-projects by defining top-level packages APP and DOMAIN. This capitalisation serves as a flag in import statements.