sdispater / pendulum

Python datetimes made easy
https://pendulum.eustace.io
MIT License
6.21k stars 384 forks source link

Unable to build pendulum for 32bit #784

Open hesstobi opened 9 months ago

hesstobi commented 9 months ago

Issue

Trying to build pendulum for a 32bit system fails:

-> src/helpers.rs:59:20
         |
      59 |         seconds += ((146_097 - 10957) * SECS_PER_DAY as usize) as isize;
         |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `135140_usize * 86400_usize`, which would overflow
         |
         = note: `#[deny(arithmetic_overflow)]` on by default

usize is only a 32 uint on 32 bit systems, thus this is not working.

Secrus commented 9 months ago

Unless you are up to making the change required for this to work on 32 bit system, I doubt it will change.

hesstobi commented 9 months ago

This was my concern.

As far I understand it would work, if the seconds variable in is changed to i64.

I can try to start with rust programming and prepare a PR for that.

gazpachoking commented 9 months ago

Is there a way to force the install to fall back to the pure python implementation?

EDIT: Or could a pure python wheel be published to pypi to fall back on?

edgarrmondragon commented 9 months ago

Is there a way to force the install to fall back to the pure python implementation?

EDIT: Or could a pure python wheel be published to pypi to fall back on?

@gazpachoking maybe the PENDULUM_EXTENSIONS=0 env var?

gazpachoking commented 9 months ago

I tried that env var. It seems that only disables the extensions at run time. I don't see a way to install without building the rust extensions at all.

On Tue, Dec 26, 2023, 23:53 Edgar Ramírez Mondragón < @.***> wrote:

Is there a way to force the install to fall back to the pure python implementation?

EDIT: Or could a pure python wheel be published to pypi to fall back on?

@gazpachoking https://github.com/gazpachoking maybe the PENDULUM_EXTENSIONS=0 env var?

— Reply to this email directly, view it on GitHub https://github.com/sdispater/pendulum/issues/784#issuecomment-1869946396, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABNV7PWBYEX6GTPUVRMX2TYLOSURAVCNFSM6AAAAABA3EREWCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRZHE2DMMZZGY . You are receiving this because you were mentioned.Message ID: @.***>

gazpachoking commented 9 months ago

We added pendulum as a dependency in our project and are now having multiple reports of people who can't install on their platform because either it's 32 bit, or they don't have rust tooling and there isn't a prebuilt wheel for their platform. I really hope official way is added such that pendulum can fall back to the pure python implementation in those cases.

Secrus commented 9 months ago

We added pendulum as a dependency in our project and are now having multiple reports of people who can't install on their platform because either it's 32 bit, or they don't have rust tooling and there isn't a prebuilt wheel for their platform. I really hope official way is added such that pendulum can fall back to the pure python implementation in those cases.

Other than 32-bit, could you maybe come up with a list of platforms we don't cover?

gazpachoking commented 9 months ago

I'll try to collect some data from our users with troubles. It's possible it's just 32bit users on raspberry pi like systems.

gazpachoking commented 9 months ago

Other than 32-bit, could you maybe come up with a list of platforms we don't cover?

Looks like linux aarch64 at least. (If that's not the detail needed there is more here) EDIT: Hmm, I may not have read that log closely enough. That might be a different issue.

JakFrost commented 9 months ago

Same problem as original poster when running on Ubuntu 18.04.6 LTS and 32-bit.

Cannot update Pendulum package since it required Rust and Cargo so installed those packages rustc and cargo just fine. Then it gets the same error as above.

I also noticed that the line PYO3_ENVIRONMENT_SIGNATURE="cpython-3.8-64bit" is set to 64-bit instead of 32-bit.

I'm not sure why all of a sudden a new language is required to be installed for this package dependency and it is now failing for 32-bit systems since it appears that the build for Rust -> Cargo -> Maturin makes the hardcoded assumption that the system is always 64-bit.

Linux Info

root@host:~# uname -a
Linux host 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:29:48 UTC 2023 i686 i686 i686 GNU/Linux

Distro

root@host:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"

Version

root@host:/tmp# which python3
/usr/bin/python3

root@host:/tmp# ll /usr/bin/python3
lrwxrwxrwx 1 root root 25 May 26  2023 /usr/bin/python3 -> /etc/alternatives/python3*

root@host:/tmp# ll /etc/alternatives/python3
lrwxrwxrwx 1 root root 18 May 26  2023 /etc/alternatives/python3 -> /usr/bin/python3.8*

root@host:/tmp# python3 --version
Python 3.8.18

root@host:/tmp# rustc --version
rustc 1.67.1 (d5a82bbd2 2023-02-07) (built from a source tarball)

root@host:/tmp# cargo --version
cargo 1.67.0

root@host:/tmp# pip --version
pip 23.3.2 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

Error - PYO3_ENVIRONMENT_SIGNATURE="cpython-3.8-64bit"

Caused by: Cargo build finished with "exit status: 101": `PYO3_ENVIRONMENT_SIGNATURE="cpython-3.8-64bit" PYO3_PYTHON="/usr/bin/python3" PYTHON_SYS_EXECUTABLE="/usr/bin/python3" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/pip-install-k8toz2qx/pendulum_1a784c65d6ec494c90a21ee7d6fe09b8/rust/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib"`

Errors

2024-01-03T04:58:05,343 Building wheels for collected packages: pendulum
2024-01-03T04:58:05,346   Created temporary directory: /tmp/pip-wheel-fc4artfx
2024-01-03T04:58:05,346   Destination directory: /tmp/pip-wheel-fc4artfx
2024-01-03T04:58:05,349   Running command Building wheel for pendulum (pyproject.toml)
2024-01-03T04:58:05,702   Running `maturin pep517 build-wheel -i /usr/bin/python3 --compatibility off`
2024-01-03T04:58:06,314   🍹 Building a mixed python/rust project
2024-01-03T04:58:06,315   🔗 Found pyo3 bindings
2024-01-03T04:58:06,619   🐍 Found CPython 3.8 at /usr/bin/python3
2024-01-03T04:58:07,363      Compiling target-lexicon v0.12.6
2024-01-03T04:58:07,363      Compiling python3-dll-a v0.2.9
2024-01-03T04:58:07,364      Compiling libc v0.2.139
2024-01-03T04:58:07,365      Compiling autocfg v1.1.0
2024-01-03T04:58:12,558      Compiling once_cell v1.17.1
2024-01-03T04:58:14,852      Compiling proc-macro2 v1.0.51
2024-01-03T04:58:16,655      Compiling unicode-ident v1.0.6
2024-01-03T04:58:17,528      Compiling quote v1.0.23
2024-01-03T04:58:20,869      Compiling syn v1.0.109
2024-01-03T04:58:24,872      Compiling pyo3-build-config v0.19.1
2024-01-03T04:58:24,968      Compiling lock_api v0.4.9
2024-01-03T04:58:27,400      Compiling parking_lot_core v0.9.7
2024-01-03T04:58:32,301      Compiling cc v1.0.79
2024-01-03T04:58:38,172      Compiling memoffset v0.9.0
2024-01-03T04:58:40,518      Compiling smallvec v1.10.0
2024-01-03T04:58:43,899      Compiling cfg-if v1.0.0
2024-01-03T04:58:44,059      Compiling scopeguard v1.1.0
2024-01-03T04:58:54,954      Compiling parking_lot v0.12.1
2024-01-03T04:59:00,301      Compiling libmimalloc-sys v0.1.35
2024-01-03T04:59:09,199      Compiling pyo3-ffi v0.19.1
2024-01-03T04:59:12,630      Compiling pyo3 v0.19.1
2024-01-03T04:59:16,143      Compiling unindent v0.1.11
2024-01-03T04:59:21,784      Compiling indoc v1.0.9
2024-01-03T04:59:29,569      Compiling mimalloc v0.1.39
2024-01-03T04:59:39,815      Compiling pyo3-macros-backend v0.19.1
2024-01-03T05:00:50,569      Compiling pyo3-macros v0.19.1
2024-01-03T05:02:20,322      Compiling _pendulum v3.0.0 (/tmp/pip-install-k8toz2qx/pendulum_1a784c65d6ec494c90a21ee7d6fe09b8/rust)
2024-01-03T05:02:25,221   error: this arithmetic operation will overflow
2024-01-03T05:02:25,222     --> src/helpers.rs:59:20
2024-01-03T05:02:25,222      |
2024-01-03T05:02:25,223   59 |         seconds += ((146_097 - 10957) * SECS_PER_DAY as usize) as isize;
2024-01-03T05:02:25,223      |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `135140_usize * 86400_usize`, which would overflow
2024-01-03T05:02:25,224      |
2024-01-03T05:02:25,225      = note: `#[deny(arithmetic_overflow)]` on by default

2024-01-03T05:04:17,959   error: could not compile `_pendulum` due to previous error
2024-01-03T05:04:17,974   💥 maturin failed
2024-01-03T05:04:17,975     Caused by: Failed to build a native library through cargo
2024-01-03T05:04:17,975     Caused by: Cargo build finished with "exit status: 101": `PYO3_ENVIRONMENT_SIGNATURE="cpython-3.8-64bit" PYO3_PYTHON="/usr/bin/python3" PYTHON_SYS_EXECUTABLE="/usr/bin/python3" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/pip-install-k8toz2qx/pendulum_1a784c65d6ec494c90a21ee7d6fe09b8/rust/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib"`
2024-01-03T05:04:17,976   Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/usr/bin/python3', '--compatibility', 'off'] returned non-zero exit status 1
2024-01-03T05:04:18,009   ERROR: Building wheel for pendulum (pyproject.toml) exited with 1
2024-01-03T05:04:18,049   [bold magenta]full command[/]: [blue]/usr/bin/python3 /usr/local/lib/python3.8/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmp3ztdwcg3[/]
2024-01-03T05:04:18,050   [bold magenta]cwd[/]: /tmp/pip-install-k8toz2qx/pendulum_1a784c65d6ec494c90a21ee7d6fe09b8
2024-01-03T05:04:18,052   ERROR: Failed building wheel for pendulum
2024-01-03T05:04:18,056 Failed to build pendulum
2024-01-03T05:04:18,058 ERROR: Could not build wheels for pendulum, which is required to install pyproject.toml-based projects
2024-01-03T05:04:18,060 Exception information:
2024-01-03T05:04:18,060 Traceback (most recent call last):
2024-01-03T05:04:18,060   File "/usr/local/lib/python3.8/dist-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
2024-01-03T05:04:18,060     status = run_func(*args)
2024-01-03T05:04:18,060   File "/usr/local/lib/python3.8/dist-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
2024-01-03T05:04:18,060     return func(self, options, args)
2024-01-03T05:04:18,060   File "/usr/local/lib/python3.8/dist-packages/pip/_internal/commands/install.py", line 429, in run
2024-01-03T05:04:18,060     raise InstallationError(
2024-01-03T05:04:18,060 pip._internal.exceptions.InstallationError: Could not build wheels for pendulum, which is required to install pyproject.toml-based projects
2024-01-03T05:04:18,154 Remote version of pip: 23.3.2
2024-01-03T05:04:18,155 Local version of pip:  23.3.2
jschlyter commented 5 months ago

Any updates on this issue @sdispater?

bdrung commented 3 weeks ago

pendulum 3.0.0-1 fails to build on armhf on Ubuntu 24.04 due to that: https://bugs.launchpad.net/ubuntu/+source/pendulum/+bug/2079029