-
Notifications
You must be signed in to change notification settings - Fork 479
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.
- Bug: Release 1.142.0 fails to deploy aws/aws-sam-cli#8139
- Bug: Error: [Errno 2] No such file or directory: '/opt/hostedtoolcache/sam/1.142.0/x64/dist/_internal/dateparser/data/dateparser_tz_cache.pkl' aws/aws-sam-cli#8140
- Bug: sam deploy - FileNotFoundError aws/aws-sam-cli#8141
- Bug: sam deploy - FileNotFoundError aws/aws-sam-cli#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-data
flag: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