Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build borg on arm64 (armbian 22.04LTS) #8208

Closed
m33m33 opened this issue May 10, 2024 · 20 comments
Closed

Can't build borg on arm64 (armbian 22.04LTS) #8208

m33m33 opened this issue May 10, 2024 · 20 comments
Assignees
Labels
Milestone

Comments

@m33m33
Copy link

m33m33 commented May 10, 2024

Have you checked borgbackup docs, FAQ, and open GitHub issues?

As best as I could

Is this a BUG / ISSUE report or a QUESTION?

ISSUE: can't build from sources (either pip or git, this issue is about building from sources using git)

System information. For client/server mode post info for both machines.

Your borg version (borg -V).

Looking forward to build the current version as per git clone

Operating system (distribution) and version.

Armbian, cat /etc/lsb-release :

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

Hardware / network configuration, and filesystems used.

LePotato (arm64 SBC, mainline kernel support)

Describe the problem you're observing.

Following instructions from https://borgbackup.readthedocs.io/en/stable/installation.html#git-installation with GIT method.
Everything looks good from here:

# get borg from github
git clone https://github.com/borgbackup/borg.git

Cloning into 'borg'...                                                                   
remote: Enumerating objects: 56539, done.
remote: Counting objects: 100% (1747/1747), done.                                                                                                                                 
remote: Compressing objects: 100% (730/730), done.                                                                                                                                remote: Total 56539 (delta 1018), reused 1592 (delta 891), pack-reused 54792                                                                                                      Receiving objects: 100% (56539/56539), 32.14 MiB | 3.56 MiB/s, done.
Resolving deltas: 100% (38240/38240), done.                                                                                                                                       Updating files: 100% (401/401), done.                                                                                                                                             

# create a virtual environment
virtualenv --python=$(which python3) borg-env
source borg-env/bin/activate   # always before using!

created virtual environment CPython3.10.12.final.0-64 in 7290ms                          
  creator CPython3Posix(dest=/.../src/borg-env, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/.../.local/share/virtualenv)
    added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1                  
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
(borg-env) user@host> 

# install borg + dependencies into virtualenv
cd borg
pip install -r requirements.d/development.txt
/.../src/borg                                                                        
Requirement already satisfied: setuptools!=60.6.0,!=60.7.0,>=45 in /.../src/borg-env/lib/python3.10/site-packages (from -r requirements.d/development.txt (line 1)) (59.6.0)
Collecting setuptools_scm                                                                                                                                                         
  Using cached setuptools_scm-8.1.0-py3-none-any.whl (43 kB)                                                                                                                      
Requirement already satisfied: pip in /.../src/borg-env/lib/python3.10/site-packages (from -r requirements.d/development.txt (line 3)) (22.0.2)
Requirement already satisfied: wheel in /.../src/borg-env/lib/python3.10/site-packages (from -r requirements.d/development.txt (line 4)) (0.37.1)                             
Collecting virtualenv                                                                    
  Using cached virtualenv-20.26.1-py3-none-any.whl (3.9 MB)
Collecting build                                                                         
  Using cached build-1.2.1-py3-none-any.whl (21 kB)                                                                                                                               
Collecting pkgconfig                                                                     
  Using cached pkgconfig-1.5.5-py3-none-any.whl (6.7 kB)    
Collecting tox                                                                                                                                                                    
  Using cached tox-4.15.0-py3-none-any.whl (155 kB)                                                                                                                               
Collecting pytest                                                                        
  Using cached pytest-8.2.0-py3-none-any.whl (339 kB)              
Collecting pytest-xdist                                                                  
  Using cached pytest_xdist-3.6.1-py3-none-any.whl (46 kB)
Collecting pytest-cov                                                                    
  Using cached pytest_cov-5.0.0-py3-none-any.whl (21 kB)                                                                                                                          
Collecting pytest-benchmark 
  Using cached pytest_benchmark-4.0.0-py3-none-any.whl (43 kB)         
**Collecting Cython               
  Using cached Cython-3.0.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.5 MB)**
Collecting pre-commit        
  Using cached pre_commit-3.7.0-py2.py3-none-any.whl (204 kB)                            
Collecting packaging>=20                                                                 
  Using cached packaging-24.0-py3-none-any.whl (53 kB)                                   
Collecting tomli>=1                      
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)                                                                                                                               
Collecting platformdirs<5,>=3.9.1                                                                                                                                                   Using cached platformdirs-4.2.1-py3-none-any.whl (17 kB)                                                                                                                        Collecting filelock<4,>=3.12.2                                                           
  Using cached filelock-3.14.0-py3-none-any.whl (12 kB)                                                                                                                           Collecting distlib<1,>=0.3.7                                                                                                                                                        Using cached distlib-0.3.8-py2.py3-none-any.whl (468 kB)                                                                                                                        
Collecting pyproject_hooks          
  Using cached packaging-24.0-py3-none-any.whl (53 kB)                                                                                                                      [0/80]
Collecting tomli>=1                      
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)                                      
Collecting platformdirs<5,>=3.9.1                                                                                                                                                 
  Using cached platformdirs-4.2.1-py3-none-any.whl (17 kB)                                                                                                                        
Collecting filelock<4,>=3.12.2                                                           
  Using cached filelock-3.14.0-py3-none-any.whl (12 kB)                                                                                                                           
Collecting distlib<1,>=0.3.7                                                             
  Using cached distlib-0.3.8-py2.py3-none-any.whl (468 kB)              
Collecting pyproject_hooks                                                               
  Using cached pyproject_hooks-1.1.0-py3-none-any.whl (9.2 kB)                                                                                                                    
Collecting chardet>=5.2                                                                                                                                                           
  Using cached chardet-5.2.0-py3-none-any.whl (199 kB)                                                                                                                            
Collecting cachetools>=5.3.2                                                                                                                                                      
  Using cached cachetools-5.3.3-py3-none-any.whl (9.3 kB)                                                                                                                         
Collecting pluggy>=1.3                                                                   
  Using cached pluggy-1.5.0-py3-none-any.whl (20 kB)       
Collecting colorama>=0.4.6                                                               
  Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)                                                                                                                        
Collecting pyproject-api>=1.6.1                                                          
  Using cached pyproject_api-1.6.1-py3-none-any.whl (12 kB) 
Collecting exceptiongroup>=1.0.0rc8                                                                                                                                               
  Using cached exceptiongroup-1.2.1-py3-none-any.whl (16 kB)                                                                                                                      
Collecting iniconfig                                                                     
  Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)           
Collecting execnet>=2.1                                                                  
  Using cached execnet-2.1.1-py3-none-any.whl (40 kB)     
Collecting coverage[toml]>=5.2.1                                                         
  Using cached coverage-7.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (232 kB)                                                                               
Collecting py-cpuinfo       
  Using cached py_cpuinfo-9.0.0-py3-none-any.whl (22 kB)               
Collecting cfgv>=2.0.0          
  Using cached cfgv-3.4.0-py2.py3-none-any.whl (7.2 kB)                                                                                                                           
Collecting nodeenv>=0.11.1   
  Using cached nodeenv-1.8.0-py2.py3-none-any.whl (22 kB)                                
Collecting identify>=1.0.0                                                               
  Using cached identify-2.5.36-py2.py3-none-any.whl (98 kB)                              
Collecting pyyaml>=5.1                   
  Using cached PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (677 kB)                                                                                 
Installing collected packages: py-cpuinfo, distlib, tomli, pyyaml, pyproject_hooks, pluggy, platformdirs, pkgconfig, packaging, nodeenv, iniconfig, identify, filelock, execnet, exceptiongroup, Cython, coverage, colorama, chardet, cfgv, cachetools, virtualenv, setuptools_scm, pytest, pyproject-api, build, tox, pytest-xdist, pytest-cov, pytest-benchmark, pre-commit                                                                                
Successfully installed Cython-3.0.10 build-1.2.1 cachetools-5.3.3 cfgv-3.4.0 chardet-5.2.0 colorama-0.4.6 coverage-7.5.1 distlib-0.3.8 exceptiongroup-1.2.1 execnet-2.1.1 filelock-3.14.0 identify-2.5.36 iniconfig-2.0.0 nodeenv-1.8.0 packaging-24.0 pkgconfig-1.5.5 platformdirs-4.2.1 pluggy-1.5.0 pre-commit-3.7.0 py-cpuinfo-9.0.0 pyproject-api-1.6.1 pyproject_hooks-1.1.0 pytest-8.2.0 pytest-benchmark-4.0.0 pytest-cov-5.0.0 pytest-xdist-3.6.1 pyyaml-6.0.1 setuptools_scm-8.1.0 tomli-2.0.1 tox-4.15.0 virtualenv-20.26.1      

Up to there:

pip install -e .   
Obtaining file:///.../src/borg
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "/.../src/borg-env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/.../src/borg-env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/.../src/borg-env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 144, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 83, in <module>
      ImportError: The GIT version of Borg needs Cython. Install Cython or use a released version.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

As far as I can tell, cython is there as a regular package, plus in the pip virtual env...

dpkg --list |grep cython
ii  cython3                          0.29.28-1ubuntu3                        arm64        C-Extensions for Python 3

I have a similar issue using the "pip" build method from the docs. It shouldn't be related specificaly to v1.2.8.

I'm pretty sure this is distribution specific, filing an issue just in case someone could help

@ThomasWaldmann
Copy link
Member

If you want to build borg 1.2.x (which is recommended as it is the stable release currently), you either need:

git checkout 1.2-maint  # to switch the repo workdir to 1.2.x branch

or

git checkout 1.2.8  # to build exactly what was released as 1.2.8

After that:

# make sure to have the venv activated here and cd to the workdir, then:
pip install -r requirements.d/development.txt
pip install -e .

If you don't do that, you are likely having master branch checked out, which is unsuitable for production usage.

Note: if you have the virtual env activated, you are using the Cython version installed into there (3.0.10 as per your log), not you system cython 0.29. But usually that's good.

@ThomasWaldmann
Copy link
Member

About the log you posted:

That seems to be a Cython issue, somehow borg does not detect Cython is installed (could be because Cython is not working / is not importable).

@m33m33
Copy link
Author

m33m33 commented May 11, 2024

I restarted from scratch, and used "git checkout 1.2.8" in borg source directory to get the v1.2.8 release source files.

Just to be sure what cython version is used I removed the cython package from the OS repos (so no more armbian/ubuntu native cython package).

Then successfully activated python venv and required packages:

pip list|grep -y cython
Cython           3.0.10

And yet same error. It comes from the setup.py line 83

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented May 11, 2024

The root cause might be this line failing in setup.py:

from Cython.Build import cythonize

Can you invoke a python interpreter with your virtual env active and try that?

If that fails, it is not a borg problem, but a Cython problem.

@m33m33
Copy link
Author

m33m33 commented May 11, 2024

cython import works in the venv:

python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cython.Build import cythonize
>>> 

I can use cython to process a file too:

cython src/borg/platform/windows.pyx 
src/borg-env/lib/python3.10/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: src/borg/src/borg/platform/windows.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
ls -alh src/borg/platform/windows.c
src/borg/platform/windows.c

Setting this environment variable gets me a step further:

export READTHEDOCS=TRUE
pip install -e . 
Obtaining file:///.../src/borg
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: packaging in /.../src/borg-env/lib/python3.10/site-packages (from borgbackup==1.2.8) (24.0)
Collecting msgpack!=1.0.1,<=1.0.8,>=0.5.6
  Using cached msgpack-1.0.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (376 kB)
Building wheels for collected packages: borgbackup
  Building editable for borgbackup (pyproject.toml) ... done
  Created wheel for borgbackup: filename=borgbackup-1.2.8-0.editable-py3-none-any.whl size=6968 sha256=64802bdb2db89581c12c740517d0018b76430687a3933d9a2108f7dff48087bf
  Stored in directory: /tmp/pip-ephem-wheel-cache-z4t78sg7/wheels/6a/b6/00/fe8808f488d9b884be00479398e8d932d9ac29c3f1a59681e0
Successfully built borgbackup
Installing collected packages: msgpack, borgbackup
Successfully installed borgbackup-1.2.8 msgpack-1.0.8

pip list |grep borg
borgbackup                    1.2.8       /.../src/borg

../borg-env/bin/borg --version
Traceback (most recent call last):
  File "/.../src/borg/src/borg/archiver.py", line 37, in <module>
    from . import helpers
  File "/.../src/borg/src/borg/helpers/__init__.py", line 10, in <module>
    from .checks import *  # NOQA
  File "/.../src/borg/src/borg/helpers/checks.py", line 4, in <module>
    from .errors import Error
  File "/.../src/borg/src/borg/helpers/errors.py", line 3, in <module>
    import borg.crypto.low_level
ModuleNotFoundError: No module named 'borg.crypto.low_level'

@ThomasWaldmann
Copy link
Member

And yet same error. It comes from the setup.py line 83

If you use the 1.2.8 checkout, better use the 1.2.8 tag to link to source files, like:

https://github.com/borgbackup/borg/blob/1.2.8/setup.py

The effect you have is weird. It seems that you can successfully import cythonize but if it still complains about needing cython, that would mean that setup.py can't do that import, because that error msg comes from the else-branch of if cythonize.

@m33m33
Copy link
Author

m33m33 commented May 11, 2024

Using https://github.com/borgbackup/borg/blob/1.2.8/setup.py same issue.
I can confirm: in setup.py the cythonize import fail (I added debug output around the try/except from Cython.Build import cythonize), it enters the except ImportError section

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented May 11, 2024

Can you try whether up/downgrading setuptools/pip/wheel helps (inside the venv)?

@m33m33
Copy link
Author

m33m33 commented May 11, 2024

Ok here is the upgrade path I followed in the venv :
pip 22 -> pip 24 : same issue
setuptools 59.6.0 -> 69.5.1 : same
wheel 0.37.1 -> 0.43.0 : same

Upgraded all packages from requirements.d/development.txt to latest available version: same

@m33m33
Copy link
Author

m33m33 commented May 11, 2024

An hello world cythonized test actually works in borg's venv: https://gist.github.com/m33m33/4e45788ef563d08594ba27cd918dcaf7

@m33m33
Copy link
Author

m33m33 commented May 11, 2024

Back to borg code base.
Fresh v1.2.8 git clone, inside the venv, following https://borgbackup.readthedocs.io/en/stable/installation.html#using-git up to pip install -r requirements.d/development.txt

At this point I can run this successfully python setup.py build_ext --inplace :

(borg-env)$ python setup.py build_ext --inplace
Detected OpenSSL [via pkg-config]
Detected and preferring liblz4 [via pkg-config]
Detected and preferring libzstd [via pkg-config]
Detected and preferring libxxhash [via pkg-config]
Compiling src/borg/platform/posix.pyx because it changed.
Compiling src/borg/platform/linux.pyx because it changed.
Compiling src/borg/platform/syncfilerange.pyx because it changed.
Compiling src/borg/platform/freebsd.pyx because it changed.
Compiling src/borg/platform/darwin.pyx because it changed.
Compiling src/borg/platform/windows.pyx because it changed.
[1/6] Cythonizing src/borg/platform/darwin.pyx
[4/6] Cythonizing src/borg/platform/posix.pyx
[5/6] Cythonizing src/borg/platform/syncfilerange.pyx
[2/6] Cythonizing src/borg/platform/freebsd.pyx
[6/6] Cythonizing src/borg/platform/windows.pyx
[3/6] Cythonizing src/borg/platform/linux.pyx
Compiling src/borg/crypto/low_level.pyx because it changed.
Compiling src/borg/compress.pyx because it changed.
Compiling src/borg/hashindex.pyx because it changed.
Compiling src/borg/item.pyx because it changed.
Compiling src/borg/chunker.pyx because it changed.
Compiling src/borg/algorithms/checksums.pyx because it changed.
[3/6] Cythonizing src/borg/compress.pyx
[2/6] Cythonizing src/borg/chunker.pyx
[6/6] Cythonizing src/borg/item.pyx
[1/6] Cythonizing src/borg/algorithms/checksums.pyx
[5/6] Cythonizing src/borg/hashindex.pyx
[4/6] Cythonizing src/borg/crypto/low_level.pyx
running build_ext
building 'borg.crypto.low_level' extension
creating build
creating build/temp.linux-aarch64-3.10
creating build/temp.linux-aarch64-3.10/src
creating build/temp.linux-aarch64-3.10/src/borg
creating build/temp.linux-aarch64-3.10/src/borg/crypto
aarch64-linux-gnu-gcc -Wno-unused-result -Wsign-compare
(...)
ctor-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/.../src/v1/borg-env/include -I/usr/include/python3.10 -c src/borg/platform/linux.c -o build/temp.linux-aarch64-3.10/src/borg/platform/linux.o -Wall -Wextra -Wpointer-arith
aarch64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-aarch64-3.10/src/borg/platform/linux.o -lacl -o build/lib.linux-aarch64-3.10/borg/platform/linux.cpython-310-aarch64-linux-gnu.so
building 'borg.platform.syncfilerange' extension
aarch64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/...src/v1/borg-env/include -I/usr/include/python3.10 -c src/borg/platform/syncfilerange.c -o build/temp.linux-aarch64-3.10/src/borg/platform/syncfilerange.o -Wall -Wextra -Wpointer-arith
aarch64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-aarch64-3.10/src/borg/platform/syncfilerange.o -o build/lib.linux-aarch64-3.10/borg/platform/syncfilerange.cpython-310-aarch64-linux-gnu.so
copying build/lib.linux-aarch64-3.10/borg/crypto/low_level.cpython-310-aarch64-linux-gnu.so -> src/borg/crypto
copying build/lib.linux-aarch64-3.10/borg/compress.cpython-310-aarch64-linux-gnu.so -> src/borg
copying build/lib.linux-aarch64-3.10/borg/hashindex.cpython-310-aarch64-linux-gnu.so -> src/borg
copying build/lib.linux-aarch64-3.10/borg/item.cpython-310-aarch64-linux-gnu.so -> src/borg
copying build/lib.linux-aarch64-3.10/borg/chunker.cpython-310-aarch64-linux-gnu.so -> src/borg
copying build/lib.linux-aarch64-3.10/borg/algorithms/checksums.cpython-310-aarch64-linux-gnu.so -> src/borg/algorithms
copying build/lib.linux-aarch64-3.10/borg/platform/posix.cpython-310-aarch64-linux-gnu.so -> src/borg/platform
copying build/lib.linux-aarch64-3.10/borg/platform/linux.cpython-310-aarch64-linux-gnu.so -> src/borg/platform
copying build/lib.linux-aarch64-3.10/borg/platform/syncfilerange.cpython-310-aarch64-linux-gnu.so -> src/borg/platform
(borg-env)$ echo $?
0
(borg-env)$ 

To me it means that cythonization actually works, but not when running pip install -e .

@m33m33
Copy link
Author

m33m33 commented May 12, 2024

Additional test scenario:

  • totaly remove OS level pip, virtualenv, to a bare python3.10 setup
  • use latest pip3 24 and all packages (virtualenv etc) from pip's depot
    -> Same issue :(

@m33m33
Copy link
Author

m33m33 commented May 12, 2024

During all these tests cases I noticed ImportError: /tmp/pip-build-env-sljdtawn/overlay/lib/python3.10/site-packages/Cython/Utils.cpython-310-aarch64-linux-gnu.so: failed to map segment from shared object

Actually this particular error is tied to the noexec mount option for /tmp.

Here /tmp is a tiny tmpfs, because 1. it's an arm64 SBC and 2. you know you don't want malware binaries exec on /tmp anyway.

python3 setup.py build_ext --inplace works because it simply produce .o files whereas pip install -e . actually uses them and fail.

So let's remount /tmp without noexec
mount -o remount,exec /tmp

pip3 install -e .
Obtaining file:///.../src/borg
  (...)
Successfully installed borgbackup-1.2.9.dev0+g958c5a26.d20240512 msgpack-1.0.8

../borg-env/bin/borg --version
borg 1.2.9.dev0+g958c5a26.d20240512

May I suggest adding a test for /tmp exec capability ? I will give it a try against v1.4 branch as to my understanding it's the next release candidate branche...

@ThomasWaldmann
Copy link
Member

Good catch! Is there a traceback for this ImportError?

Also: can this "failed to map" error msg be seen if you remove the try/except in borg's setup.py?

@ThomasWaldmann ThomasWaldmann added this to the 1.2.9 milestone May 12, 2024
@m33m33
Copy link
Author

m33m33 commented May 12, 2024

Traceback (most recent call last):
        File "/.../src/borg-env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/.../src/borg-env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/.../src/borg-env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 144, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-ktfu9762/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 83, in <module>
      ImportError: The GIT version of Borg needs Cython. Install Cython or use a released version.

If you blindly import Cython without try/catch you get the same error. I think keeping the try/catch is a good idea but adding a warning in the except section is needed, because if you enter this section the rest will most likely fail at some point, right ?

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented May 12, 2024

I am working on an improvement, PR will come soon, would be good if you can try it out.

Can you try #8210?

It is for 1.4-maint branch, but guess the patch might also apply to 1.2-maint.

The goal is to get a clear error msg and not to hide the original error, making it easier to find the root cause of issues other than just "cython is not installed".

ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
…ckup#8208

Looks like borg's setup.py has hidden the real cause of a cythonize ImportError.

There are basically 2 cases:
- either there is no Cython installed, then the import fails because the module can not be found, or
- there is some issue within Cython and the import fails due to that.

It's important not to hide the real cause, especially if we run into case 2.

case 1 is kind of expected and frequent, case 2 is rare.
@ThomasWaldmann
Copy link
Member

Add "bug" label because borg's setup.py has hidden the original exception message, making it hard to find the root cause of this problem.

@ThomasWaldmann ThomasWaldmann self-assigned this May 12, 2024
@m33m33
Copy link
Author

m33m33 commented May 12, 2024

Here is the pip install -e . output with #8210 applied. The error is more verbose now, but no hint about /tmp +exec ?

src/test/testthomas/borg
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "/misc/usb/borg/src/test/testthomas/borg-env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/misc/usb/borg/src/test/testthomas/borg-env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/misc/usb/borg/src/test/testthomas/borg-env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-dh3q9evk/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-dh3q9evk/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-dh3q9evk/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-dh3q9evk/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 85, in <module>
      ImportError: The GIT version of Borg needs a working Cython. Install or fix Cython or use a released borg version. Importing cythonize failed with: ImportError: /tmp/pip-build-env-dh3q9evk/overlay/lib/python3.10/site-packages/Cython/Utils.cpython-310-aarch64-linux-gnu.so: failed to map segment from shared object
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
…ckup#8208

Looks like borg's setup.py has hidden the real cause of a cythonize ImportError.

There are basically 2 cases:
- either there is no Cython installed, then the import fails because the module can not be found, or
- there is some issue within Cython and the import fails due to that.

It's important not to hide the real cause, especially if we run into case 2.

case 1 is kind of expected and frequent, case 2 is rare.
@ThomasWaldmann
Copy link
Member

OK, I'll add a hint about +exec.

ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
That "failed to map segment from shared object" error msg is not
very helpful. Add a hint that the filesystem needs to be +exec
(== not noexec mounted, like it might be the case for /tmp on
some systems).
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
That "failed to map segment from shared object" error msg is not
very helpful. Add a hint that the filesystem needs to be +exec
(== not noexec mounted, like it might be the case for /tmp on
some systems).
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
…ckup#8208

Looks like borg's setup.py has hidden the real cause of a cythonize ImportError.

There are basically 2 cases:
- either there is no Cython installed, then the import fails because the module can not be found, or
- there is some issue within Cython and the import fails due to that.

It's important not to hide the real cause, especially if we run into case 2.

case 1 is kind of expected and frequent, case 2 is rare.
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
That "failed to map segment from shared object" error msg is not
very helpful. Add a hint that the filesystem needs to be +exec
(== not noexec mounted, like it might be the case for /tmp on
some systems).
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
…ckup#8208

Looks like borg's setup.py has hidden the real cause of a cythonize ImportError.

There are basically 2 cases:
- either there is no Cython installed, then the import fails because the module can not be found, or
- there is some issue within Cython and the import fails due to that.

It's important not to hide the real cause, especially if we run into case 2.

case 1 is kind of expected and frequent, case 2 is rare.
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
That "failed to map segment from shared object" error msg is not
very helpful. Add a hint that the filesystem needs to be +exec
(== not noexec mounted, like it might be the case for /tmp on
some systems).
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
…ckup#8208

Looks like borg's setup.py has hidden the real cause of a cythonize ImportError.

There are basically 2 cases:
- either there is no Cython installed, then the import fails because the module can not be found, or
- there is some issue within Cython and the import fails due to that.

It's important not to hide the real cause, especially if we run into case 2.

case 1 is kind of expected and frequent, case 2 is rare.
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
That "failed to map segment from shared object" error msg is not
very helpful. Add a hint that the filesystem needs to be +exec
(== not noexec mounted, like it might be the case for /tmp on
some systems).
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
…ckup#8208

Looks like borg's setup.py has hidden the real cause of a cythonize ImportError.

There are basically 2 cases:
- either there is no Cython installed, then the import fails because the module can not be found, or
- there is some issue within Cython and the import fails due to that.

It's important not to hide the real cause, especially if we run into case 2.

case 1 is kind of expected and frequent, case 2 is rare.
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 12, 2024
That "failed to map segment from shared object" error msg is not
very helpful. Add a hint that the filesystem needs to be +exec
(== not noexec mounted, like it might be the case for /tmp on
some systems).
ThomasWaldmann added a commit that referenced this issue May 12, 2024
…or-reporting-master

setup.py: fix import error reporting for cythonize import, see #8208 (master)
ThomasWaldmann added a commit that referenced this issue May 12, 2024
…or-reporting-1.2

setup.py: fix import error reporting for cythonize import, see #8208
ThomasWaldmann added a commit that referenced this issue May 12, 2024
…or-reporting-1.4

setup.py: fix import error reporting for cythonize import, see #8208
@ThomasWaldmann
Copy link
Member

OK, as far as borg is concerned, I'll close this - it now gives a helpful error message.

The root cause of this is the noexec fs and that the pip build used that fs, so it is outside of borg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants