Remove pendulum dependency
Hello, as discusses over in the pendulum repo that library is "on live support" with the owner being more or less absent. A big problem is, that there are no wheels for pendulum under Python 3.13. That means that rust/cargo is necessary to install/build pendulum (and in extension fastapi-cache) under that python versions. In my use case that is an additional bothersome complexity; that is why I am exploring ways to remedy this.
fastapi-cache only uses pendulum in one instance, for date/datetime encoding. Unfortunately I do not fully understand this use case.
- Why is this encoding here even necessary?
- Is it possible to remove this encoding, or replace it with something from the main library?
Hopefully pendulum can gain some active maintainers and provide wheels for current and future python versions but until then it might be smart to detach from that library.
@massi1008 After an admittedly cursory look, it would appear that Pendulum is used to parse and validate datetime.date and datetime.datetime objects during JSON encoding. It should, in principle, be possible to swap out Pendulum for python-dateutil's parsers.
A thing I observed is that, contrary to their documentation, pendulum is not a drop-in replacement for datetime.datetime, because it does not support naive timestamps:
It also removes the notion of naive datetimes: each DateTime instance is timezone-aware and by default in UTC for ease of use. (https://github.com/sdispater/pendulum?tab=readme-ov-file#why-pendulum)
I cannot understand their reason for this, but it's clearly a design decision and won't be changed there.
For fastapi_cache this means naive timestamps can never be (correctly) deserialized.
I.e. even in the most basic example
>>> t=pendulum.parse("2020-01-01 15:00:00")
>>> t
DateTime(2020, 1, 1, 15, 0, 0, tzinfo=Timezone('UTC')
pendulum hallucinates a UTC timezone out of nowhere.
So even without the maintainer problem of pendulum, this dependency is quite problematic.
is there any way around?\
Another problem with pendulum is the disk space it may "leak" for end users of fastapi-cache.
When installing fastapi-cache, the pendulum dependency installation process brings all the rustup/cargo/rustc/lib stuff to the business. This ends up consuming lots of disk space if you're not careful enough to delete it correctly after installation (specially in containerized environments, where docker build with pip install steps may add lots of useless space do the layer). In my case it's 550M ./.rustup which is just absurd for just some date/time processing.
I'm using fastapi and fastapi-cache using docker... now I need to alter my dockerfile pip install step to delete crazy unexpected rust toolchain cache dirs to safe 0.5GB in disk space.