Skip to main content

FindFQPath

PyPI Python License: MIT

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

  1. Saved path: if the path saved for this file still exists and is newer than num_days_valid days, it's returned straight away.
  2. Re-search: if 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.
  3. First search: for a file it hasn't seen before, it checks:
    • your PATH (macOS and Linux only);
    • the usual install folders: Program Files, Program Files (x86) and AppData\Local\Programs on Windows; /Applications and Homebrew on macOS; /usr/bin, /opt, /snap/bin and ~/.local/bin on Linux;
    • the whole drive, as a last resort.
  4. 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.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 findfqpath 1.0.6
File Size Uploaded Provenance Actions
findfqpath-1.0.6.tar.gz 6.1 kB Without provenance Details for findfqpath-1.0.6.tar.gz

Built distribution (wheel)

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

Total release size: 12.5 kB

Release files / findfqpath-1.0.6.tar.gz

Download URL findfqpath-1.0.6.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d545429223e9b474924fd72625a55e08bc852577e29daebd0d2a0ccb49647bb8
BLAKE2b-256 checksum
How to use checksums
b541efc73f8cb76365e55b65fc28665ff4cdbb086f111541a9670121241d5a08
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.6-py3-none-any.whl

Download URL findfqpath-1.0.6-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61fff549a56585473e8485fa8368353951e5a1c65f8b6ca57ec6692657b6c720
BLAKE2b-256 checksum
How to use checksums
3accf3d8e4364808179d08d84e4c152c095cb105312050c141f9073faa9255d1
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.6

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.

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