Skip to main content

Find project module directory relative to the running script.

This module will search the currently runnings script’s parent directory, and all successive parent directories up to the root directory for a module matching the base argument. If found, the directory is added to sys.path.

This is useful for sets of scripts that use custom project-specific modules that you don’t want to install into the system python modules folders.

Example usage:

import findmodules
findmodules.init(base='modules', realpath=True)

This example will search for a folder called “modules” in the current script’s directory, and all parent directories. Symlinks will be resolved first. If the directory is found, it will be appended to sys.path.

Parameters:

  • bin: Path to script file. Default is currently running script file

  • base: Name of base module directory to add to sys.path. Default is “lib”.

  • append: Append module directory to the end of sys.path, or insert at the beginning? Default is to append.

  • ignore: List of directories to ignore during the module search. Default is to ignore “/” and “/usr”.

  • realpath: Should symlinks be resolved first? Default is False.

  • pythonpath: Should the modules directory be added to the PYTHONPATH environment variable? Default is False.

  • throw: Should an exception be thrown if no modules directory was found? Default is False.

Returns:
  • The path to the modules directory if it was found, otherwise None.

Release files for findmodules 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for findmodules 0.6
File Size Uploaded
findmodules-0.6.tar.gz 2.1 kB Details

Release files / findmodules-0.6.tar.gz

Download URL findmodules-0.6.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
00b875a366f4f75a5c622694bb8e6e7b570b2ab2fa9c648d91666fec6e0faac4
BLAKE2b-256 checksum
How to use checksums
ecd00fd50aa7c86b7d6e8420d9deb3dd0ce02e4fedf0f2d4fadb36d9851b0820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.6 This release

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page