Import packages and modules from the root of a monorepo
Project description
Import packages and modules from the root of a monorepo
Instructions:
- First create a file named
.monorepo_root
at the root of your monorepo. - Use
monorepo.load_package
(ormonorepo.load_module
) to load packages (or modules) from anywhere in your monorepo.
Example usage for load_package
:
import monorepo
# The `load_package` function will search up from the current directory for a
# file named `.monorepo_root`, which is used to determine the root directory
# from which to load the package:
monorepo.load_package("pkg1")
# The pkg1 package can be used directly:
from pkg1 import mymodule1
# Also works with sub-packages:
monorepo.load_package("pkg1.pkg2")
from pkg2 import mymodule2
# Also works with renaming packages (useful for invalid package names or for name clashes):
monorepo.load_package("invalid-namge", package_name = "pkg3")
from pkg3 import mymodule3
Example usage for load_module
:
import monorepo
# The `load_module` function will search up from the current directory for a
# file named `.monorepo_root`, which is used to determine the root directory
# from which to load the module:
mymodule = monorepo.load_module("pkg1.module1")
mymodule.my_function()
mymodule2 = monorepo.load_module("pkg1.pkg2.module2")
mymodule2.my_function()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
monorepo-0.2.0.tar.gz
(2.7 kB
view hashes)