scrapinghub / scrapinghub/dateparser
PyInstaller Compatibility Issue: Missing dateparser_tz_cache.pkl in Frozen Applications
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
Summary
#1250 introduced a new data file dateparser/data/dateparser_tz_cache.pkl that is not automatically included when freezing applications with PyInstaller, causing runtime failures in previously working deployments.
Problem Description
The introduction of the timezone cache file dateparser/data/dateparser_tz_cache.pkl in #1250 has created a breaking change for users who package their applications using PyInstaller. This file is not automatically detected and included by PyInstaller's dependency analysis, resulting in FileNotFoundError exceptions when the frozen application attempts to access the cache file.
- https://github.com/aws/aws-sam-cli/issues/8139
- https://github.com/aws/aws-sam-cli/issues/8140
- https://github.com/aws/aws-sam-cli/issues/8141
- https://github.com/aws/aws-sam-cli/issues/8143
Steps to Reproduce
- Create a Python application that uses dateparser
- Package the application using PyInstaller:
pyinstaller --onefile your_app.py - Run the frozen executable
- Observe the runtime error when dateparser attempts to access the cache file
Expected Behavior
The frozen application should work without additional configuration, maintaining backward compatibility with existing PyInstaller workflows.
Actual Behavior
The application fails at runtime with a FileNotFoundError when trying to access dateparser/data/dateparser_tz_cache.pkl.
Current Workaround
Users must manually configure PyInstaller to include the data file by:
- Creating a PyInstaller hook file or
- Using the
--add-dataflag:pyinstaller --add-data "path/to/dateparser/data/dateparser_tz_cache.pkl:dateparser/data/" your_app.py - Or adding the file to a custom hook in their build process
- Or revert back to 1.2.1
Impact Assessment
This change breaks existing production deployments and CI/CD pipelines that use PyInstaller without warning. Users upgrading dateparser may experience unexpected deployment failures.
Suggested Solutions
Short-term
- Documentation Update: Add clear instructions in the README and documentation about PyInstaller compatibility requirements
- PyInstaller Hook: Include a proper PyInstaller hook file (
hook-dateparser.py) in the package to automatically handle data file inclusion - Runtime Fallback: Implement graceful fallback behavior when the cache file is missing
Long-term
- Version Bump Consideration: This type of breaking change typically warrants a major version increment to signal potential compatibility issues to users
Proposed PyInstaller Hook
# hook-dateparser.py
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('dateparser')
Environment
- dateparser version: 1.2.2
- PyInstaller version: [various versions affected]
- Python version: [various versions]
- Operating System: Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the PyInstaller command from the issue and inspect dateparser/data/dateparser_tz_cache.pkl plus the proposed hook-dateparser.py approach. Done means a frozen application can access the cache file without manual --add-data configuration, with the README or documentation explaining any remaining packaging requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100