I am trying to install python-shout module in windows 10 but it fails. In the ubuntu works well.
Edit (06/10/2022): Here is what i have tried to build python-shout in native windows
- Only download libshout module files from here: Note that i download all the 14 dependencies + this package: winpthreads
- I renamed the 15 zst files to have names like 1.zst, 2.zst,…, 15.zst
- I decompress the zst files using this command:
tar --use-compress-program=unzstd -xvf 1.zst
- From the output files and directories i copied the opt/x86_64-w64-mingw32/* folders and files in mingw64 folder.
- After that i uninstall msys2 platform.
- I open a cmd and i run the file mingw64/bin/shout.exe The files run correctly.
- I download and extract the python-shout module from here
- I modified the setup.py of the extracted folder in step 7 to be like
# distutils build script # To install shout-python, run 'python setup.py install' from setuptools import setup, Extension import os import sys import setuptools ver = '0.2.7' with open("README.md", "r") as fh: long_description = fh.read() cflags = "-IC:/Users/cpapp/OneDrive/Υπολογιστής/mingw64/include" libs = "-LC:/Users/cpapp/OneDrive/Υπολογιστής/mingw64/lib -lshout" # there must be an easier way to set up these flags! iflags = [x[2:] for x in cflags.split() if x[0:2] == '-I'] extra_cflags = [x for x in cflags.split() if x[0:2] != '-I'] libdirs = [x[2:] for x in libs.split() if x[0:2] == '-L'] libsonly = [x[2:] for x in libs.split() if x[0:2] == '-l'] # include_dirs=[] # libraries=[] # runtime_library_dirs=[] # extra_objects, extra_compile_args, extra_link_args shout = Extension('shout', sources = ['shout.c'], include_dirs = iflags, extra_compile_args = extra_cflags, library_dirs = libdirs, libraries = libsonly) # data_files = [] setup (name = 'python-shout', version = ver, description = 'Bindings for libshout 2', long_description=long_description, long_description_content_type="text/markdown", url = 'http://icecast.org/download.php', author = 'Brendan Cully', author_email = 'brendan@xiph.org', ext_modules = [shout], packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "Programming Language :: Python :: 2", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: OS Independent", ], )
Important note: Check the path values of cflags and libs variables.
- I run
python setup.py build
with this output:
running build running build_ext building 'shout' extension "C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629binHostX86x86cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:/Users/cpapp/OneDrive/Υπολογιστής/mingw64/include -IC:pythoninclude -IC:pythonInclude "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629include" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629ATLMFCinclude" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.19041.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\cppwinrt" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629include" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629ATLMFCinclude" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.19041.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\cppwinrt" /Tcshout.c /Fobuildtemp.win32-cpython-310Releaseshout.obj shout.c "C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629binHostX86x86link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:/Users/cpapp/OneDrive/Υπολογιστής/mingw64/lib /LIBPATH:C:pythonlibs /LIBPATH:C:python /LIBPATH:C:pythonPCbuildwin32 "/LIBPATH:C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629ATLMFClibx86" "/LIBPATH:C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629libx86" "/LIBPATH:C:Program Files (x86)Windows Kits10lib10.0.19041.0ucrtx86" "/LIBPATH:C:Program Files (x86)Windows Kits10\lib10.0.19041.0\umx86" "/LIBPATH:C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629ATLMFClibx86" "/LIBPATH:C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629libx86" "/LIBPATH:C:Program Files (x86)Windows Kits10lib10.0.19041.0ucrtx86" "/LIBPATH:C:Program Files (x86)Windows Kits10\lib10.0.19041.0\umx86" shout.lib /EXPORT:PyInit_shout buildtemp.win32-cpython-310Releaseshout.obj /OUT:buildlib.win32-cpython-310shout.cp310-win_amd64.pyd /IMPLIB:buildtemp.win32-cpython-310Releaseshout.cp310-win_amd64.lib LINK : fatal error LNK1181: cannot open input file 'shout.lib' error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX86\x86\link.exe' failed with exit code 1181
The error is that shout.lib file can’t be found, but there is no shout.lib file only libshout-3.dll. I tried to convert libshout-3.dll to shout.lib using dumpbin. The python module installation works well but when i am trying to import the module not well formatted dll error oquered.
Any help would be usefull!!
Advertisement
Answer
I have succesfully install python-shout module with MingGW and MSYS 2.
Instructions:
Download msys2 from https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20210228.exe
Run the installer (instructions: https://www.msys2.org/)
Update packages using
pacman -Syu
andpacman -Su
Install basic programs for msys2
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Install python
pacman -S mingw-w64-x86_64-python
Install libshout
pacman -S mingw-w64-x86_64-libshout
Download and extract python-shout from: https://github.com/yomguy/python-shout
Edit setup.py to be like this:
from setuptools import setup, Extension import os import sys import setuptools ver = '0.2.7' with open("README.md", "r") as fh: long_description = fh.read() cflags = "-IC:/msys64/mingw64/include" libs = "-LC:/msys64/mingw64/lib -lshout" # there must be an easier way to set up these flags! iflags = [x[2:] for x in cflags.split() if x[0:2] == '-I'] extra_cflags = [x for x in cflags.split() if x[0:2] != '-I'] libdirs = [x[2:] for x in libs.split() if x[0:2] == '-L'] libsonly = [x[2:] for x in libs.split() if x[0:2] == '-l'] # include_dirs=[] # libraries=[] # runtime_library_dirs=[] # extra_objects, extra_compile_args, extra_link_args shout = Extension('shout', sources = ['shout.c'], include_dirs = iflags, extra_compile_args = extra_cflags, library_dirs = libdirs, libraries = libsonly) # data_files = [] setup (name = 'python-shout', version = ver, description = 'Bindings for libshout 2', long_description=long_description, long_description_content_type="text/markdown", url = 'http://icecast.org/download.php', author = 'Brendan Cully', author_email = 'brendan@xiph.org', ext_modules = [shout], packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "Programming Language :: Python :: 2", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: OS Independent", ], )
Install setuptools
pacman -S python-setuptools
Install python-shout running: 10.a
cd c/Users/Χρήστος/Desktop/python-shout-master
Note that you must put your Windows username instead of mine (Χρήστος) and 10.bpython setup.py install
and that’s it. Python-shout module has successfully installed in your Windows machine. To test it just run:
python >>import shout >>s = shout.Shout() >>print("Using libshout version %s" % shout.version())
After that you can install pyinstaller from source in MSYS2 console (https://github.com/pyinstaller/pyinstaller) download and extract, then run python setup.py install
and finally run pyinstaller –onefile icecast_program.py
and then you will have an exe that can be run in every Windows system.