Skip to main content

A function that locates files in python environments and compiled exe files (Nuitka)

nuitka is certainly the best py2exe- compiler, but it is not always easy to include additional files. 

The first time I tried that, the compiled EXE wasn't able to find the included files, and it took me some time to make all the necessary code adjustments.  This is why I wrote a little function that locates files in the most likely locations (python env/nuikta exe).

pip install getfilenuitkapython

This module contains a function called get_filepath which returns the full path to a file, given its filename. It uses the os and sys modules to search for the file in multiple locations.

Parameters
----------
filename: A string representing the name of the file to locate.

Returns
----------
A string representing the full path to the file, if it is found.
If the file is not found in any of the locations, the function returns the filename itself.

Description
----------
The get_filepath function searches for the file in the following locations:

1. The directory containing the script that was invoked from the command line.
2. The directory containing the current module file (__file__).
3. The parent directory of the directory containing the script that was invoked from the command line.
4. The parent directory of the directory containing the current module file (__file__).
5. The directory containing the calling function (sys._getframe(1)).
6. The parent directory of the directory containing the calling function.
7. Search in PATH
8. Search in every folder in basedirs 

If the file is found in any of these locations, the function returns the full path to the file. If the file is not found in any of these locations, the function returns the filename itself.


from getfilenuitkapython import get_filepath
get_filepath('pythonw.exe')
Out[3]: 'C:\\ProgramData\\anaconda3\\envs\\dfdir\\pythonw.exe'

Metadata

Release files for getfilenuitkapython 0.11

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

Source distribution (sdist)

Source distribution for getfilenuitkapython 0.11
File Size Uploaded Provenance Actions
getfilenuitkapython-0.11.tar.gz 4.1 kB Without provenance Details for getfilenuitkapython-0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for getfilenuitkapython 0.11
File Interpreter ABI Platform Actions
getfilenuitkapython-0.11-py3-none-any.whl Python 3 none any Details for getfilenuitkapython-0.11-py3-none-any.whl

Total release size: 10.1 kB

Release files / getfilenuitkapython-0.11.tar.gz

Download URL getfilenuitkapython-0.11.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2b6add986a3f371a16c40e1584379092acd0227f2d7e00227afab9717698618a
BLAKE2b-256 checksum
How to use checksums
2c8b0eceb1082ecf8417ca880df229c868f632e522383b7eeadff5279b75adb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / getfilenuitkapython-0.11-py3-none-any.whl

Download URL getfilenuitkapython-0.11-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4bf84dbc078e4f868d44a798165656611b2445f22d746f5ed22fb95ea4517d0
BLAKE2b-256 checksum
How to use checksums
86767fe9320d03af1cc6f178228ca18cb56503634fdfc10c189e67f0c6f98516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for getfilenuitkapython 0.11

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.

Release history Release notifications | RSS feed

This release

0.11 This release

2 release files No provenance

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