pythonmacospypyquickfixfix-protocol

Quickfix for Python Library installation fails in MacOS


I am trying to install quickfix 1.15.1 (the current latest version available) in MacOS.

OS version is Ventura 15.1. Chip is Apple M2. Python version is 3.9.6. Clang version is 14.0.0.

But the installation gets failed.

The steps I followed is as follows.

  1. Tried to install using pip3 install quickfix. It was not successful.

  2. Downloaded the source package from pypi and tried to install the package using pip3 install . and pip3 install . --no-binary=:all --user --no-cache-dir. It was not successful.

  3. Cloned the C++ quickfix source code from github and tried to install the library using the commands ./boostrap, ./configure --with-python3 and sudo make install. It was not successful too.

The error I get when trying to install the library in all the above three steps is as follows.

Processing /Users/user/Dependencies/quickfix-1.15.1
Preparing metadata (setup.py) ... done
Building wheels for collected packages: quickfix
Building wheel for quickfix (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─\> \[248 lines of output\]
Testing for std::tr1::shared_ptr...
test_std_tr1_shared_ptr.cpp:1:10: fatal error: 'tr1/memory' file not found
\#include \<tr1/memory\>
^\~\~\~\~\~\~\~\~\~\~\~
1 error generated.
...not found
Testing for std::shared_ptr...
...found
Testing for std::unique_ptr...
...found

C++/AtomicCount.h:163:11: error: unrecognized instruction mnemonic
                "lock\n\t"
                ^
      <inline asm>:1:2: note: instantiated into assembly here
              lock
              ^
      In file included from C++/DataDictionary.cpp:26:
      In file included from C++/DataDictionary.h:30:
      In file included from C++/FieldMap.h:30:
      In file included from C++/MessageSorters.h:30:
      In file included from C++/SharedArray.h:26:
      C++/AtomicCount.h:163:18: error: unrecognized instruction mnemonic, did you mean: add, addp, adds, addv, fadd, madd?
                "lock\n\t"
                       ^
      <inline asm>:2:2: note: instantiated into assembly here
              xadd x9, [x8]
              ^

fatal error: too many errors emitted, stopping now [-ferror-limit=]
      2 warnings and 20 errors generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for quickfix
  Running setup.py clean for quickfix
Failed to build quickfix
Installing collected packages: quickfix
  Running setup.py install for quickfix ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for quickfix did not run successfully.

fatal error: too many errors emitted, stopping now [-ferror-limit=]
      2 warnings and 20 errors generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> quickfix

note: This is an issue with the package mentioned above, not pip.

Went through different issue threads and docs, but could not find a solution yet. Found this similar stack overflow post as well. But a solution could not be found there too.


Solution

  • Just installed quickfix-1.15.1 on my ARM-based MacBook with:

    1. Download quickfix-1.15.1.tar.gz from https://pypi.org/project/quickfix
    2. Unpack it and edit C++/AtomicCount.h file by uncomment line 155 and comment out line 170 below:
        static int atomic_exchange_and_add(int * pw, int dv)
        {
          int r = *pw;
          *pw += dv;
          return r;
    
          // int r;
    
          // __asm__ __volatile__
          //   (
          //     "lock\n\t"
          //     "xadd %1, %0":
          //     "+m"(*pw), "=r"(r) : // outputs (%0, %1)
          //     "1"(dv) : // inputs (%2 == %1)
          //     "memory", "cc" // clobbers
          //   );
    
          // return r;
        }
    
    1. Then run pip3 install . while inside quickfix-1.15.1 folder.
    2. You can also locate your wheel file e.g. quickfix-1.15.1-cp310-cp310-macosx_12_0_arm64.whl in your pip cache directory as well.

    Hope this helps.