matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Unable to upgrade to 1.68.0 #14001

Closed jahway603 closed 2 years ago

jahway603 commented 2 years ago

Description

When attempting to upgrade my Synapse from 1.67.0 to 1.68.0, it fails on "Building wheel for matrix-synapse (pyproject.toml)".

Per the upgrade notes, I'm not using SQLite and I have rustc installed. I checked the rustc version, which was 1.55.0, and have used rustup to upgrade to rustc 1.64.0, which fits the minimum requirement of rustc 1.58.1, but still have the same error before I upgraded rustc.

Steps to reproduce

Homeserver

omitted, it's an ARM64

Synapse Version

{"server_version":"1.67.0","python_version":"3.9.2"}

Installation Method

pip (from PyPI)

Platform

"bare metal" on DietPi (Debian for ARM architecture, aarch64) using python pip for install/upgrade

Relevant log output

$ sudo -u synapse pip3 install -U matrix-synapse
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: matrix-synapse in /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages (1.67.0)
Collecting matrix-synapse
  Using cached matrix-synapse-1.68.0.tar.gz (2.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (3.0.1)
Requirement already satisfied: pyasn1>=0.1.9 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (0.4.8)
Requirement already satisfied: sortedcontainers>=1.4.4 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (2.4.0)
Requirement already satisfied: phonenumbers>=8.2.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (8.12.33)
Requirement already satisfied: packaging>=16.1 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (21.0)
Requirement already satisfied: pyOpenSSL>=16.0.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (21.0.0)
Requirement already satisfied: Pillow>=5.4.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (8.3.2)
Requirement already satisfied: bcrypt>=3.1.7 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (3.2.0)
Requirement already satisfied: pyasn1-modules>=0.0.7 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (0.2.8)
Requirement already satisfied: pymacaroons>=0.13.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (0.13.0)
Requirement already satisfied: netaddr>=0.7.18 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (0.8.0)
Requirement already satisfied: msgpack>=0.5.2 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (1.0.2)
Requirement already satisfied: cryptography>=3.4.7 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (35.0.0)
Requirement already satisfied: attrs!=21.1.0,>=19.2.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (21.2.0)
Requirement already satisfied: frozendict!=2.1.2,>=1 in /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages (from matrix-synapse) (2.3.4)
Requirement already satisfied: jsonschema>=3.0.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (3.2.0)
Requirement already satisfied: ijson>=3.1.4 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (3.1.4)
Requirement already satisfied: prometheus-client>=0.4.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (0.11.0)
Requirement already satisfied: signedjson<2.0.0,>=1.1.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (1.1.1)
Requirement already satisfied: service-identity>=18.1.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (21.1.0)
Requirement already satisfied: bleach>=1.4.3 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (4.1.0)
Requirement already satisfied: pydantic>=1.7.4 in /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages (from matrix-synapse) (1.10.1)
Collecting matrix-common<2.0.0,>=1.3.0
  Using cached matrix_common-1.3.0-py3-none-any.whl (11 kB)
Collecting setuptools_rust>=1.3
  Using cached setuptools_rust-1.5.2-py3-none-any.whl (23 kB)
Requirement already satisfied: unpaddedbase64>=2.1.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (2.1.0)
Requirement already satisfied: Twisted[tls]>=18.9.0 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (21.7.0)
Requirement already satisfied: treq>=15.1 in /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages (from matrix-synapse) (22.2.0)
Requirement already satisfied: PyYAML>=3.11 in /usr/local/lib/python3.9/dist-packages (from matrix-synapse) (5.4.1)
Requirement already satisfied: canonicaljson<2.0.0,>=1.5.0 in /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages (from matrix-synapse) (1.6.2)
Requirement already satisfied: typing-extensions>=3.10.0.1 in /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages (from matrix-synapse) (4.3.0)
Requirement already satisfied: cffi>=1.1 in /usr/local/lib/python3.9/dist-packages (from bcrypt>=3.1.7->matrix-synapse) (1.14.6)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.9/dist-packages (from bcrypt>=3.1.7->matrix-synapse) (1.16.0)
Requirement already satisfied: webencodings in /usr/local/lib/python3.9/dist-packages (from bleach>=1.4.3->matrix-synapse) (0.5.1)
Requirement already satisfied: simplejson>=3.14.0 in /usr/local/lib/python3.9/dist-packages (from canonicaljson<2.0.0,>=1.5.0->matrix-synapse) (3.17.5)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.9/dist-packages (from Jinja2>=3.0->matrix-synapse) (2.0.1)
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/dist-packages (from jsonschema>=3.0.0->matrix-synapse) (58.0.4)
Requirement already satisfied: pyrsistent>=0.14.0 in /usr/local/lib/python3.9/dist-packages (from jsonschema>=3.0.0->matrix-synapse) (0.18.0)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.9/dist-packages (from packaging>=16.1->matrix-synapse) (2.4.7)
Requirement already satisfied: PyNaCl<2.0,>=1.1.2 in /usr/local/lib/python3.9/dist-packages (from pymacaroons>=0.13.0->matrix-synapse) (1.4.0)
Collecting semantic-version<3,>=2.8.2
  Using cached semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)
Collecting setuptools
  Using cached setuptools-65.4.1-py3-none-any.whl (1.2 MB)
Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.9/dist-packages (from signedjson<2.0.0,>=1.1.0->matrix-synapse) (4.8.1)
Requirement already satisfied: incremental in /usr/local/lib/python3.9/dist-packages (from treq>=15.1->matrix-synapse) (21.3.0)
Requirement already satisfied: requests>=2.1.0 in /usr/local/lib/python3.9/dist-packages (from treq>=15.1->matrix-synapse) (2.26.0)
Requirement already satisfied: hyperlink>=21.0.0 in /usr/local/lib/python3.9/dist-packages (from treq>=15.1->matrix-synapse) (21.0.0)
Requirement already satisfied: Automat>=0.8.0 in /usr/local/lib/python3.9/dist-packages (from Twisted[tls]>=18.9.0->matrix-synapse) (20.2.0)
Requirement already satisfied: constantly>=15.1 in /usr/local/lib/python3.9/dist-packages (from Twisted[tls]>=18.9.0->matrix-synapse) (15.1.0)
Requirement already satisfied: zope.interface>=4.4.2 in /usr/local/lib/python3.9/dist-packages (from Twisted[tls]>=18.9.0->matrix-synapse) (5.4.0)
Requirement already satisfied: idna>=2.4 in /usr/local/lib/python3.9/dist-packages (from Twisted[tls]>=18.9.0->matrix-synapse) (3.2)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/dist-packages (from cffi>=1.1->bcrypt>=3.1.7->matrix-synapse) (2.20)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/dist-packages (from requests>=2.1.0->treq>=15.1->matrix-synapse) (2021.5.30)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.9/dist-packages (from requests>=2.1.0->treq>=15.1->matrix-synapse) (2.0.6)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/dist-packages (from requests>=2.1.0->treq>=15.1->matrix-synapse) (1.26.7)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.9/dist-packages (from importlib-metadata->signedjson<2.0.0,>=1.1.0->matrix-synapse) (3.6.0)
Building wheels for collected packages: matrix-synapse
  Building wheel for matrix-synapse (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/local/lib/python3.9/dist-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpgpd_o7pa
       cwd: /tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa
  Complete output (31 lines):
  A setup.py file already exists. Using it.
  Traceback (most recent call last):
    File "/tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa/setup.py", line 242, in <module>
      from build_rust import *
    File "/tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa/build_rust.py", line 6, in <module>
      from setuptools_rust import Binding, RustExtension
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/setuptools_rust/__init__.py", line 1, in <module>
      from .build import build_rust
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/setuptools_rust/build.py", line 23, in <module>
      from setuptools.command.build import build as CommandBuild  # type: ignore[import]
  ModuleNotFoundError: No module named 'setuptools.command.build'
  Traceback (most recent call last):
    File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
      main()
    File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/poetry/core/masonry/api.py", line 67, in build_wheel
      return WheelBuilder.make_in(poetry, Path(wheel_directory))
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 79, in make_in
      wb.build(target_dir=directory)
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 113, in build
      self._build(zip_file)
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 167, in _build
      self._run_build_command(setup)
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 205, in _run_build_command
      subprocess.check_call(
    File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/usr/bin/python3', '/tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa/setup.py', 'build', '-b', '/tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa/build']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for matrix-synapse
Failed to build matrix-synapse
ERROR: Could not build wheels for matrix-synapse, which is required to install pyproject.toml-based projects

Anything else that would be useful to know?

I've been running this server for a while now and have not encountered any errors like this when upgrading Synapse releases.

clokep commented 2 years ago

@jahway603 Ensure that you're using poetry > 1.2.0, which is also a requirement of Synapse v1.68.0.

DMRobertson commented 2 years ago

I think the relevant part of the logs here is:

  Traceback (most recent call last):
    File "/tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa/setup.py", line 242, in <module>
      from build_rust import *
    File "/tmp/pip-install-zd_d2f6d/matrix-synapse_a58a0827ff0048ab8f3222aba7debffa/build_rust.py", line 6, in <module>
      from setuptools_rust import Binding, RustExtension
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/setuptools_rust/__init__.py", line 1, in <module>
      from .build import build_rust
    File "/tmp/pip-build-env-3nmbxrav/overlay/lib/python3.9/site-packages/setuptools_rust/build.py", line 23, in <module>
      from setuptools.command.build import build as CommandBuild  # type: ignore[import]
  ModuleNotFoundError: No module named 'setuptools.command.build'

Might be possible to avoid this pain if we provided aarch64 wheels too (#13938)

jahway603 commented 2 years ago

@jahway603 Ensure that you're using poetry > 1.2.0, which is also a requirement of Synapse v1.68.0.

I did install poetry from the Debian package manager, but it still crashed when building the wheels, so no change.

MTRNord commented 2 years ago

I seem to hit the same error on WSL2 Ubuntu 22.04 with python 3.10.6 and setuptools 65.4.1 as well as poetry 1.2.2

MTRNord commented 2 years ago

Turns out for some reason I have setuptools installed in 2 places :/ probably the one is from the package manager and is from late 2021 while the newer is from pip. The older one being not compatible

MTRNord commented 2 years ago

Uninstalling the python3-setuptools package and using https://bootstrap.pypa.io/get-pip.py to install pip manually fixes this for me. However that doesnt seem to be a great solution :/

DMRobertson commented 2 years ago

Uninstalling the python3-setuptools package and using https://bootstrap.pypa.io/get-pip.py to install pip manually fixes this for me. However that doesnt seem to be a great solution :/

If you are trying to just deploy Synapse, make a new virtualenv, activate it, and pip install matrix-synapse[all].

If you're developing on Synapse, use poetry as described here (which will create a virtualenv for you).

DMRobertson commented 2 years ago

@jahway603 I would guess that the version of setuptools being used to install Synapse is too old. What does sudo -u synapse pip3 show setuptools say?

Edit: again, if you're doing a from-source or from-pypi installation I would strongly recommend isolating it in a virtualenv.

jahway603 commented 2 years ago

@DMRobertson This is the result:

$ sudo -u synapse pip3 show setuptools
Name: setuptools
Version: 65.4.1
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: distutils-sig@python.org
License: 
Location: /mnt/dietpi_userdata/synapse/.local/lib/python3.9/site-packages
Requires: 
Required-by: jsonschema, zope.interface
jahway603 commented 2 years ago

Unsure if this is relevant, but just tried upgrading to the latest 1.69.0 right now and this failed too.

DMRobertson commented 2 years ago

It's very odd that you get the error

ModuleNotFoundError: No module named 'setuptools.command.build'

because this was introduced in setuptools 62.4.0 (https://github.com/pypa/setuptools/commit/b517cfae6b11c15834aa7aaf439bc45894a238f4), but your system seems to have setuptools 65.x.

I would guess that (as MTRNord says) there are multiple versions of setuptools and python is picking the "wrong" one. (I hate Python packaging.)

What version of setuptools is installed with the System python? (apt show python3-setuptools maybe? Guessing---not a Debian user.)

jahway603 commented 2 years ago

Closing this issue as this server was just successfully upgraded to Matrix Synapse version 1.70.1. Thank you all for your help in resolving this and all the great work you do on Matrix Synapse.

DMRobertson commented 2 years ago

this server was just successfully upgraded to Matrix Synapse version 1.70.1.

Does this mean that you/your distro is using the aarch64 wheels?