(DEPRECATED) module_path
Python does not use filenames anymore to support reading from a zip file. This library is deprecated and has been removed from pypi.
Provided functions
files - importlib.resources files this function is the standard for retrieving resources for Python 3.9+
as_file - context manager for retrieving a true filepath for Python 3.9+.
my_dir - Return the directory this module is in. This should exist even in an executable.
my_path - Return the path to the module that called this method. This may not exist in an executable
Example
# my_interface.py
# sdl2 with sld2.dll in package
# File Structure:
# my_sdl/
# sdl2_dll_path/
# SDL2.dll
# __init__.py
# my_interface.py
import os
from module_path import files, as_file
with as_file(files('my_sdl').joinpath('sdl2_dll_path/SDL2.dll')) as sdl_path:
os.environ.setdefault('PYSDL2_DLL_PATH', os.path.dirname(str(sdl_path)))
import sdl2
# Use sdl2
assert sdl2 is not None
check_path/
__init__.py
main.py
check_sub_path
__init__.py
fakedata.txt
# check_path/check_sub_path/__init__.py
import os
import module_path
MY_DIR = module_path.my_dir()
DATA = os.path.join(MY_DIR, 'fakedata.txt')
EXISTS = os.path.exists(DATA)
# check_path/main.py
import module_path
try:
from check_path.check_sub_path import MY_DIR, DATA, EXISTS
except (ImportError, Exception):
from check_sub_path import MY_DIR, DATA, EXISTS
if __name__ == '__main__':
path = module_path.my_path()
directory = module_path.my_dir()
print('path \t', path, module_path.exists(path)) # Should be false with executable
print('dir \t', directory, module_path.exists(directory))
print('sub_dir\t', MY_DIR, module_path.exists(MY_DIR))
print('DATA \t', DATA, EXISTS)
Build the executable with
pyinstaller --name check_path -y --add-data "check_path/check_sub_path/fakedata.txt;check_path/check_sub_path/" check_path/main.py
After pyinstaller builds you will have a dist directory. The data for this example should be stored in dist/check_path/check_path/check_sub_path/fakedata.txt
Metadata
Release files for module-path 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| module_path-1.0.1.tar.gz | 4.8 kB | Without provenance | Details for module_path-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| module_path-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for module_path-1.0.1-py3-none-any.whl |
Total release size: 11.2 kB
Release files / module_path-1.0.1.tar.gz
| Download URL | module_path-1.0.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9520c328eec33fdfa82ae26c52ec748755de3505d901e98ab4a5010a106f1840
|
|
BLAKE2b-256 checksum How to use checksums |
61e046411ec387217d119d2d2763d54e6510dbf13078ece1ea07c584d71117c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.8
|
Release files / module_path-1.0.1-py3-none-any.whl
| Download URL | module_path-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0d13df260c13803a03689366f35b114e15bbb15e086a5a7073f9220f2abb047
|
|
BLAKE2b-256 checksum How to use checksums |
1870c5968c1c2f31ae829550d6e0fdf0d714a04acb76ebc34db8703f6aa3fbc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.8
|
Security for module-path 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.