sdispater / pendulum

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

Could not build wheels for pendulum which use PEP 517 #454

Closed weskerfoot closed 4 years ago

weskerfoot commented 4 years ago

Issue

I get an error about PEP 517 when trying to install Pendulum. The following Dockerfile (run with docker build .) reproduces the issue.

The error is ERROR: Could not build wheels for pendulum which use PEP 517 and cannot be installed directly

FROM python:3.7-alpine3.11
RUN apk update \
    && apk add gcc musl-dev python3-dev py3-setuptools libffi libffi-dev openssl-dev \
    && pip3 install pendulum==2.1.0
altendky commented 4 years ago

My quick looking suggests...

1) It's Alpine so the pendulum wheels aren't used so that explains the issue not being as wide spread as it might be 2) The poetry tarball doesn't list setuptools as an install_requires and thus the isolated build env doesn't have setuptools (the poetry .whl should be used but I know where to look in the tarball...)

Now I'm not sure of the nuances here and I haven't tested my theory quite yet but... FWIW.

weskerfoot commented 4 years ago

Workaround (for this situation, running in Docker with Alpine)

FROM python:3.7-alpine3.11
RUN apk update \
    && apk add gcc musl-dev python3-dev py3-setuptools libffi libffi-dev openssl-dev \
    && pip3 install poetry \
    && pip3 install --no-build-isolation pendulum==2.1.0
aniljaiswal commented 4 years ago

Any workarounds for people using pipenv? I'm using the same docker setup but using pipenv and lock files.

Hellowlol commented 4 years ago

I'm having the same issue in the home assistant 107.7 (hassio)

weskerfoot commented 4 years ago

Any workarounds for people using pipenv? I'm using the same docker setup but using pipenv and lock files.

Does pipenv have a similar option to disable build isolation? That would most likely work, though I'm not really familiar with how pipenv does things.

davegallant commented 4 years ago
❯ colordiff pendulum-2.0.5/setup.py pendulum-2.1.0/setup.py
2c2
< from distutils.core import setup
---
> from setuptools import setup

Does anyone know where this setup.py is being generated? It has changed in 2.1.0 https://files.pythonhosted.org/packages/e5/dc/d79687e49cafbdee73078b28c57d2a2555735c88d672239e4cb19a6a141a/pendulum-2.1.0.tar.gz

altendky commented 4 years ago

Poetry would be building it I would think. But, pyproject.toml will get hit first (for 517-compatible pips) and that specifies poetry as the build backend not setuptools. And poetry is missing an install_requires for setuptools afaict thus causing the error. So it seems to me that either that needs to be addressed or pendulum needs to build a pyproject.toml with a build-system requires including setuptools and the corresponding build-backend.

altendky commented 4 years ago

@davegallant, commit-wise it looks to be: https://github.com/python-poetry/poetry/commit/f759876231ca6c0910ad823f0ba405e21b3f1c4b

altendky commented 4 years ago

I just realized we don't have a full log here. @weskerfoot, could you add that?

weskerfoot commented 4 years ago

@altendky done docker_build.log

aniljaiswal commented 4 years ago

Any update on the above issue?

altendky commented 4 years ago

I think python-poetry/core#24 (also mentioned at https://github.com/python-poetry/poetry/pull/2262/files/ad2c8d80f4f04a95769a5955e4367f1351aaca76#diff-d4e7f533c342aecaeb13b29ca6c1bf24) should resolve this. I have not tested at all, just getting the cross-references added.

Thanks @abn.

nathan5280 commented 4 years ago

I was able to get this to work in my dockerfile by downgrading my version of pip. I didn't keep track of all the details, but it seems that up to about version 1.0.4 it works with pip 19.x. After that we get the issue listed above.

pip install pip==18.1
ThanhTuNguyen commented 4 years ago

Please fix this issue, thanks

gmr commented 4 years ago

Why is poetry required to install pendulum?

altendky commented 4 years ago

Poetry is required to build pendulum. If you are on a system for which wheels (prebuilt packages) are not provided then it needs to be built from the source distribution. This can also happen if you tell pip not to use wheels. If you can and do use the wheels then poetry should not be required.

enercalc commented 4 years ago

Windows: Install (python -m pip install pendulum) works on pip 18.1, doesnt work on pip 19.2.3.

Wasn't clear if you folks had the log you needed, so...

C:\python>python -m pip install pendulum Collecting pendulum Using cached https://files.pythonhosted.org/packages/e5/dc/d79687e49cafbdee73078b28c57d2a2555735c88d672239e4cb19a6a141a/pendulum-2.1.0.tar.gz Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Collecting pytzdata>=2018.3 (from pendulum) Using cached https://files.pythonhosted.org/packages/7f/f9/cdd39831b0465285c02ed90cfbf0db25bb951cb2a35ded0e69222375bea3/pytzdata-2019.3-py2.py3-none-any.whl Requirement already satisfied: python-dateutil<3.0,>=2.6 in c:\python\lib\site-packages (from pendulum) (2.8.1) Requirement already satisfied: six>=1.5 in c:\python\lib\site-packages (from python-dateutil<3.0,>=2.6->pendulum) (1.15.0) Building wheels for collected packages: pendulum Building wheel for pendulum (PEP 517) ... error ERROR: Command errored out with exit status 1: command: 'C:\python\python.exe' 'C:\python\lib\site-packages\pip_vendor\pep517_in_process.py' build_wheel 'C:\Users\Frame\AppData\Local\Temp\1\tmpo6145lzs' cwd: C:\Users\Frame\AppData\Local\Temp\1\pip-install-nkecq6bf\pendulum Complete output (24 lines): Traceback (most recent call last): File "setup.py", line 2, in from setuptools import setup ModuleNotFoundError: No module named 'setuptools' Traceback (most recent call last): File "C:\python\lib\site-packages\pip_vendor\pep517_in_process.py", line 207, in main() File "C:\python\lib\site-packages\pip_vendor\pep517_in_process.py", line 197, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "C:\python\lib\site-packages\pip_vendor\pep517_in_process.py", line 140, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "C:\Users\Frame\AppData\Local\Temp\1\pip-build-env-h1_o3poz\overlay\Lib\site-packages\poetry\core\masonry\api.py", line 57, in build_wheel return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory))) File "C:\Users\Frame\AppData\Local\Temp\1\pip-build-env-h1_o3poz\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 56, in make_in wb.build() File "C:\Users\Frame\AppData\Local\Temp\1\pip-build-env-h1_o3poz\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 82, in build self._build(zip_file) File "C:\Users\Frame\AppData\Local\Temp\1\pip-build-env-h1_o3poz\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 101, in _build self._run_build_command(setup) File "C:\Users\Frame\AppData\Local\Temp\1\pip-build-env-h1_o3poz\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 129, in _run_build_command subprocess.check_call( File "C:\python\lib\subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['C:\python\python.exe', 'setup.py', 'build', '-b', 'build']' returned non-zero exit status 1.

ERROR: Failed building wheel for pendulum Running setup.py clean for pendulum ERROR: Command errored out with exit status 1: command: 'C:\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Frame\AppData\Local\Temp\1\pip-install-nkecq6bf\pendulum\setup.py'"'"'; file='"'"'C:\Users\Frame\AppData\Local\Temp\1\pip-install-nkecq6bf\pendulum\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' clean --all cwd: C:\Users\Frame\AppData\Local\Temp\1\pip-install-nkecq6bf\pendulum Complete output (3 lines): Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'setuptools'

ERROR: Failed cleaning build dir for pendulum Failed to build pendulum ERROR: Could not build wheels for pendulum which use PEP 517 and cannot be installed directly

richieadler commented 4 years ago

Can confirm that I get the same error @enercalc is getting.

Pendulum 2.0.3 installs correctly.

ajayd2k commented 4 years ago

Windows 10 :

I installed the PIP version 18.1 with the below command C:>pip install pip==18.1

Then Install the pendulum with the command: C:>pip install pendulum

No errors now

weskerfoot commented 4 years ago

Poetry is required to build pendulum. If you are on a system for which wheels (prebuilt packages) are not provided then it needs to be built from the source distribution. This can also happen if you tell pip not to use wheels. If you can and do use the wheels then poetry should not be required.

To add to that, the reason it's an issue on Alpine is because Alpine doesn't have prebuilt wheels available (because it's using musl libc, so it needs to get recompiled for that), so you have to build them from source every time you install it.

alertedsnake commented 4 years ago

To add to that, the reason it's an issue on Alpine is because Alpine doesn't have prebuilt wheels available (because it's using musl libc, so it needs to get recompiled for that), so you have to build them from source every time you install it.

We build wheels for Alpine and serve them via devpi so we don't have to have build tools in containers and such. And we still have problems building a wheel for Pendulum :)

ThanhTuNguyen commented 4 years ago

Someone should fix this bug, it's been a couple months. i can not downgrade my pip, it will effect to other libraries. Right now i just mess up to my docker file in order to install poetry and pendulum directly into container. Its a bizarre solution :(

joshourisman commented 4 years ago

For pipenv users, this got my Pipfile with a pendulum dependency installing on Alpine:

FROM python:3.8-alpine

RUN apk update \
    && apk add --no-cache build-base postgresql-dev openssl-dev libffi-dev \
    && pip3 install -U pipenv poetry

WORKDIR /app
ENV WORKON_HOME /app/.venvs
COPY Pipfile Pipfile.lock ./
RUN pipenv install --deploy --site-packages

The important parts are installing poetry with the system pip, and then adding the --site-packages flag when invoking pipenv install.

frostming commented 4 years ago

There are multiple reasons behind this:

  1. Alpine can't match any of the wheels released on pypi
  2. Building pendulum from source dist requires setuptools, but it is not specified in pyproject.toml's [build-systems] requires
  3. Starting from pip 19, it creates a clean isolated environment to install PEP 517 powered libraries.

So the corresponding resolution will be:

  1. If possible, use slim images instead of alpine
  2. Downgrade pip to 18.1
  3. Otherwise, use the following commands to install:
    $ pip install poetry && pip install --no-build-isolation pendulum
  4. Waiting for @sdispater to release a new version of pendulum with fixed pyproject.toml
williamjacksn commented 4 years ago

I got tired of this so I built my own Python package index with wheels for Alpine Linux.

https://github.com/alpine-wheels/index

RazerM commented 4 years ago

I really like pendulum, it's baffling that this hasn't been resolved for so long. I understand that the author wrote poetry but it's not a glowing endorsement that people haven't been able to install pendulum for three months because of it.

richieadler commented 4 years ago

I really like pendulum, it's baffling that this hasn't been resolved for so long.

I was able to solve it in Windows 7, Python 3.8 32 bits following @frostming advice, above.

sdispater commented 4 years ago

This should be fixed in the latest 2.1.2 release.

ThanhTuNguyen commented 4 years ago

It work like normal. Just tested .Thanks

ritumishra9 commented 4 years ago

i am getting the same error while installing mysqlclient

DEPRECATION: Could not build wheels for mysqlclient which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above.

wheel issue is- Building wheel for mysql (setup.py) ... done Created wheel for mysql: filename=mysql-0.0.2-py3-none-any.whl size=1252 sha256=ca801d4e9888754369abcdfb5791654e3a43361475a58726257b7954c7c4d735 Stored in directory: c:\users\admin\appdata\local\pip\cache\wheels\3e\4a\d0\506edab38d1bdf574b02c24805fcf7348a327297fcc285431d Building wheel for client (setup.py) ... done Created wheel for client: filename=client-0.0.1-py3-none-any.whl size=1441 sha256=cf97824f8b63db528014243e69082705c78c4397ca5891bfb2b7217a107e943c Stored in directory: c:\users\admin\appdata\local\pip\cache\wheels\1e\d6\d3\2084ee3b4ac9adaab2bf853307b140575c5fe9160821ab8e07 Building wheel for mysqlclient (setup.py) ... error ERROR: Command errored out with exit status 1:

altendky commented 4 years ago

@ritumishra9, I would suggest reporting this to mysqlclient. Though the references to mysql 0.0.1 and client 0.0.2 seem odd.

spacemanspiff2007 commented 2 years ago

I really like pendulum, it's baffling that this hasn't been resolved for so long. I understand that the author wrote poetry but it's not a glowing endorsement that people haven't been able to install pendulum for three months because of it.

I'm still supporting people (with more or less success) that are getting this exact same issue at the end of 2021. 👎

altendky commented 2 years ago

It usually works best to create a new ticket with complete details of your case and a link to the existing ticket that you think is related. It's hard to help when the issue appears to be solved and no new information is provided.

To be clear, I'm not particularly involved with this project. Just offering some guidance on a path forward that's more likely to result in fixing your issues.

spacemanspiff2007 commented 2 years ago

It usually works best to create a new ticket with complete details of your case

It's difficult because I use pendulum as a dependency for an application and the users try to get support from me and often don't provide all the required information. That would be much appreciated since I am far from an expert! I just try to get them to do things that I found in the issues here. So far it seems that pendulum 2.1.0 will install on most the machines without issues.

Ideally we would consolidate these infos e.g. pendulum requires poetry or otherwise it won't install properly with pip.

altendky commented 2 years ago

The new issue bug report template provides a starting point. Generally speaking you want the OS including version and architecture, Python version, Pendulum version, full terminal session (prompt, command, and output), and maybe also other cases where the same thing does work to help isolate what differences might show the issue. If the command you are running has a verbose option the full output as above could also be provided with the extra verbosity.

ethanmsl commented 11 months ago
  at ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/installation/chef.py:164 in _prepare
      160│
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│
      163│             if error is not None:
    → 164│                 raise error from None
      165│
      166│             return path
      167│
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with pendulum (2.1.2) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "pendulum (==2.1.2)"'.

I'm also getting errors on attempting to install Pendulum, with nominal "pendulum (2.1.2) not supporting PEP 517 builds".

macOS 13.6.2, M1_chip

edgarrmondragon commented 11 months ago

@ethanmsl Pendulum 3.0.0b1 has wheels for M1 macs and Python 3.12, but builds of Pendulum 2.* on Python 3.12+ seem like they'll be forever broken.