Skip to main content

Import packages and modules from the root of a monorepo

Project description

Import packages and modules from the root of a monorepo

Instructions:

  1. First create a file named .monorepo_root at the root of your monorepo.
  2. Use monorepo.load_package (or monorepo.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


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 details)

Uploaded Source

Built Distribution

monorepo-0.2.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file monorepo-0.2.0.tar.gz.

File metadata

  • Download URL: monorepo-0.2.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for monorepo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9eaa97b35df5b45f6102faf41d6238b19ac0ff909e237ffd1c27f11f25993c12
MD5 76c215cd40e3d22db49bbb3291536366
BLAKE2b-256 9bd374b0b68d3d3280643a18b7f1c8abfdc1635b0e5b8d5288aae4a3f0b91bd4

See more details on using hashes here.

File details

Details for the file monorepo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: monorepo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for monorepo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00172b14c2e78f09271eac5689f187c46604817cc5662681b2e3c4c0e8fc22d2
MD5 77d17475bf9007553a8fa124e2e40518
BLAKE2b-256 59dbe855a2c22fcd43fd996f0dadcd7ad99b5a2d1a5e6acb5ba16bb60013ace5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page