FindFQPath
Find the fully qualified path of the most recent installed copy of a file, such as a browser executable, even when updates keep moving it to a new versioned folder.
Many tools need the full path to an executable. Selenium's binary_location is a common example. Programs like Opera install each update into a new folder, so a hard-coded path breaks every time the program updates. find_fq_path searches for the file once, remembers where it was, and returns that path on later calls in well under a second. When the saved path goes missing or gets older than you allow, it searches again and picks the newest copy.
This will run slow the FIRST time a new file is requested as it may search the entire drive. However, it will look through the Program* directories before searching the entire drive. Subsequent usage for the same file will be sub-second.
Works on Windows, macOS and Linux.
Install
pip install findfqpath
Usage
from findfqpath import find_fq_path
opera_path = find_fq_path("opera.exe", num_days_valid=1)
With Selenium:
from selenium import webdriver
from findfqpath import find_fq_path
options = webdriver.ChromeOptions()
options.binary_location = find_fq_path("opera.exe", num_days_valid=1)
Parameters
| Parameter | Description |
|---|---|
find_file |
Name of the file to find. Use the name for the OS: opera.exe on Windows, opera on Linux, Opera on macOS (the program inside Opera.app). |
num_days_valid |
Search again if the saved path is older than this many days. 0 always searches. |
scope |
"Shared" (default) saves the path in your user cache folder so every script that uses "Shared" reuses it. "Local" saves it in the calling script's folder, so each script keeps its own. |
Returns the full path as a string, or None if the file can't be found.
How it works
-
Saved path: if the path saved for this file still exists and is newer than
num_days_validdays, it's returned straight away. -
PATH: otherwise it checks your
PATHfirst. That's instant and finds anything the OS itself would run, such assvchost.exeorpython. -
Re-search: if the file isn't on
PATHand the saved path is missing or too old, the search starts two folders above where the file was last found, then moves up one folder at a time. A new version installed next to the old one is usually found quickly. -
First search: for a file it hasn't seen before, it checks:
- the usual install folders:
Program Files,Program Files (x86)andAppData\Local\Programson Windows;/Applicationsand Homebrew on macOS;/usr/bin,/opt,/snap/binand~/.local/binon Linux; - the whole drive, as a last resort.
Searches skip folders that hold duplicate or deleted copies (
C:\Windows\WinSxSand the Recycle Bin on Windows) and system folders such as/procon Linux. - the usual install folders:
-
If several copies are found, the most recently modified one wins.
The first search for a file can take a while if it has to scan the whole drive. Later calls for the same file are fast.
The shared cache is stored in the per-user cache folder from platformdirs, for example %LOCALAPPDATA%\findfqpath\Cache on Windows or ~/.cache/findfqpath on Linux.
License
MIT
Metadata
Release files for findfqpath 1.0.7
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 |
|---|---|---|---|---|
| findfqpath-1.0.7.tar.gz | 6.4 kB | Without provenance | Details for findfqpath-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| findfqpath-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for findfqpath-1.0.7-py3-none-any.whl |
Total release size: 13.1 kB
Release files / findfqpath-1.0.7.tar.gz
| Download URL | findfqpath-1.0.7.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb54bea7600e674178ca2179d66135d33c5ce2ee351350996b2eaa996b8ee905
|
|
BLAKE2b-256 checksum How to use checksums |
9df708baa33f8ed83f0fce3c8a59dcfad1dd21876cfff79db3908e9f86126d34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / findfqpath-1.0.7-py3-none-any.whl
| Download URL | findfqpath-1.0.7-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
181bb11e87e5ae1a93c5955eabfa2fe4763486c16f3a5e3d774ad2c0ed68c24e
|
|
BLAKE2b-256 checksum How to use checksums |
95e96c101bf89d3aba56affa414fad50198b2bc80c07c2acd8deab737f6c2501
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for findfqpath 1.0.7
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.