xpra icon
Bug tracker and wiki

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#373 closed task (fixed)

gmp and mpfr build for win32 - needed for pycrypto fastmath

Reported by: Antoine Martin Owned by: Smo
Priority: minor Milestone: 0.11
Component: client Version:
Keywords: win32 Cc:

Description (last modified by Antoine Martin)

Can be dealt with as part of #300

Attachments (1)

session-info-showfastmath.png (1.9 KB) - added by Antoine Martin 6 years ago.
session info dialog showing availability of pycrypto's fastmath

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by Antoine Martin

Milestone: 1.00.11
Status: newassigned

comment:2 Changed 7 years ago by Antoine Martin

Description: modified (diff)

Changed 6 years ago by Antoine Martin

session info dialog showing availability of pycrypto's fastmath

comment:3 Changed 6 years ago by Antoine Martin

Owner: changed from Antoine Martin to Smo
Status: assignednew

This solution works for me: Building PyCrypto with fastmath (gmp or mpir) via pip on Windows (remove existing version before installing - and remember to use "export VAR=value" syntax in the mingw32 shell!)

You can verify it is installed with:

C:\Python27\Python.exe -c "from Crypto.PublicKey import _fastmath;print(_fastmath);"

And as of r4511, it is also shown on session info as "(fastmath available)":
/raw-attachment/ticket/373/session-info-showfastmath.png

Please confirm and close.

Last edited 6 years ago by Antoine Martin (previous) (diff)

comment:4 Changed 6 years ago by Smo

Resolution: fixed
Status: newclosed

Followed the same solution that worked for you. Compiled and Installed with minor issues.

There was an issue with the test units but doesn't seem to affect anything. Will reopen this ticket if I find a problem.

comment:5 Changed 6 years ago by Antoine Martin

Notes:

  • pycrypto version 2.6.1 was released on the 2014-06-20 and is an important update (security issues)
  • upgrading via easy_install breaks fastmath.. the instruction above have to be used every time (PITA)
  • mpir 2.7.0 beta is available (which means that the actual release is likely to happen before too long - and we probably should use it as it fixes RNG security issues, etc)

comment:6 Changed 6 years ago by Antoine Martin

Was easier to rebuild with an up to date mingw32 environment and the libgmp it can install.

In a mingw shell:

mingw-get.exe update
mingw-get.exe upgrade
mingw-get.exe install mingw32-libgmp

Then in the pycrypto source directory, just:

./configure
/c/Python27/python.exe setup.py build -c mingw32
/c/Python27/python.exe setup.py test
/c/Python27/python.exe setup.py install

Note: this does not seem to work for Python 3.3 and 3.4, where the resulting module causes crashes at runtime

Note: as of version 0.12.x, you can also verify the presence of pycrypto's fastmath with Network_info.exe:

C:\Program Files\Xpra>Network_info.exe
Network interfaces found:
* {0F7E7AF4-D168-429C-86D0-0687BA76F4A5}
* MS TCP Loopback interface

Protocol Capabilities:
* bencode              : True
* bencode.version      : Cython, 0.11
* digest               : hmac, xor
* lz4                  : True
* mmap                 : True
* pycrypto.fastmath    : True
* pycrypto.version     : 2.6.1
* rencode              : True
* rencode.version      : Cython, 1.0.2
* yaml                 : False

PS: you may need to patch some of the mingw header files if you encounter off64_t and off_t errors, see here: mingw bug 2024: 'off64_t' does not name a type

Last edited 6 years ago by Antoine Martin (previous) (diff)

comment:7 Changed 6 years ago by Antoine Martin

For Python 3.x:

  • using gmp 6.0.0:
    • build it with mingw32 (no way to build with msvc?):
      ./configure --disable-static --enable-shared --with-pic --host=pentium-pc-mingw32
      make
      
    • generate the lib file using a visual studio shell (as per gmplib.org : MS Windows DLLs):
      cd gmp-6.0.0
      cd .libs
      lib /def:libgmp-3.dll.def /out:gmp.lib
      
  • copy the gmp.lib to the pycrypto source dir
  • copy the gmp.h to pycrypto's src/inc-msvc dir
  • edit src/inc-msvc/config.h:
    #define HAVE_DECL_MPZ_POWM 1
    #define HAVE_DECL_MPZ_POWM_SEC 1
    #define HAVE_LIBGMP 1
    
  • build + install pycrypto:
    C:\Python34\Python.exe setup.py install
    

(and verify that it found gmp)

Note: for some reason, the fastmath pyd needs to find the libgmp-3.dll.dll (and fails no matter what it seems..)


Nasty workaround:

  • make a static version of gmp instead:
    ./configure --disable-shared --enable-static --with-pic --host=pentium-pc-mingw32
    make
    
  • copy .libs/libgmp.a and libgcc.a to pycrypto's source dir
  • edit pycrypto's setup.py and replace the fastmath extension's libraries= line with:
    extra_objects=['libgmp.a', 'libgcc.a']
    
  • build + install pycrypto:
    C:\Python34\Python.exe setup.py install
    

(and verify that it found gmp)

  • make an xpra build and verify that fastmath is present

  • using mpir:
    • requires msvc gui... which is stuck on the splash screen on my dev vm..
Last edited 6 years ago by Antoine Martin (previous) (diff)
Note: See TracTickets for help on using tickets.