Skip to main content

import your library without __init__.py

Project description

dirimport: convenient library importer

Install

  • python -m venv your-dir
  • cd your-dir
  • ./bin/pip install dirimport

Install (devel)

Use

  • import dirimport
  • mod = dirimport.importall("/path/to/dirname")

import rules

  • file.py -> from .file import *
  • subpkg/ -> from . import subpkg
  • do it recursively

then, all symbols will be accessible after import.

example:

  • layout
    • symbol1 in dir1/file1.py
    • symbol2 in dir1/file2.py
    • symbol3 in dir1/pkg/file1.py
  • import
    • import dir1 with generated init.py
    • or dir1 = dirimport.importall("dir1") without init.py
  • result
    • symbol1 -> dir1.symbol1
    • symbol2 -> dir1.symbol2
    • symbol3 -> dir1.pkg.symbol2

CLI tools

# ./bin/dirimport
Usage: dirimport [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  diff
  eval
  generate
  • diff __init__.py
    • ./bin/dirimport diff your-library-dir
  • import and evaluate expression
    • ./bin/dirimport eval your-library-dir 'expression'
  • generate __init__.py
    • ./bin/dirimport generate your-library-dir

examples

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dirimport, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size dirimport-0.0.6-py3-none-any.whl (5.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page