This repository contains builds of M2Crypto for Windows based on these instructions.
If you have built your own, send a Pull Request to integrate them here so we can help others too! 🙂 🚀
Steps >=7 can be simplified running the
builder.ps1script
- Install the latest
Build Tools for Visual Studio 2019. See https://visualstudio.microsoft.com/downloads/ under "All Downloads" -> "Tools for Visual Studio 2019". This direct link was active as of this writing: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16 - In the installer, select "C++ Build Tools", install, and reboot if necessary.
- Install the latest full (not
Light)OpenSSLfor your architecture (Win64/Win32). Current version as of this writing is1.1.1d. Make note of the directory to which you installOpenSSL. https://slproweb.com/products/Win32OpenSSL.html - In
PowerShell, install theChocolateypackage manager. I used this command from their website:Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) - Install
swigwithChocolatey(inPowerShell).choco install -r -y swig - Install the
pywin32dependency. Runpip install pywin32. If you have problems, try first runningpip install wheel. To getpipto target a specific Python installation, try launching it usingpy -[version] -m pip install [module]. Note: you may need to use an elevated (administrator)PowerShellto install Python modules. - Get the latest
m2cryptocode. If you havegitinstalled, rungit clone https://gitlab.com/m2crypto/m2crypto. Otherwise, download and extract the code from GitLab: https://gitlab.com/m2crypto/m2crypto/-/archive/master/m2crypto-master.zip - Use
cdto change into the directorym2cryptowas cloned/extracted to. - Assuming
pythonlaunches your desired Python interpreter version, runpython setup.py build --openssl="C:\Program Files\OpenSSL-Win64" --bundledlls, replacingC:\Program Files\OpenSSL-Win64with the directory to which you installedOpenSSL. (On some systems you can use thepylauncher to specify a Python version to use, runpy -hfor more information.) - Generate the installable files.
python.exe setup.py bdist_wheel bdist_wininst bdist_msi. - Install the module.
cdinto thedistdirectory and runpip install M2Crypto-0.35.2-cp38-cp38-win_amd64.whl, replacing the filename with the generated.whlfile. If you have problems, try first runningpip install wheel. To getpipto target a specific Python installation, try launching it usingpy -[version] -m pip install [module]. Alternatively, you can run the generated.exeor.msiinstaller. Note: you may need to use an elevated (administrator)PowerShellto install Python modules.