I'm trying to get Python packages built on my Windows machine using GCC instead of the MS C++ build tools, the former being much smaller (although still 1.5GB).
I have setup mingw-w64
using MSYS2
, and it's in the path, so:
C:\Users\username>where g++
c:\MyPrograms\msys64\mingw64\bin\g++.exe
C:\Users\username>g++ --version
g++ (Rev3, Built by MSYS2 project) 10.1.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
So far, so good.
I setup the distutils.cfg
as follows, as described here:
[build]
compiler=mingw32
[build_ext]
compiler=mingw32
But then installing a package such as astropy
yields the following error:
ValueError: Unknown MS Compiler version 1916
I saw somewhere a suggestion to fill distutils.cfg
like this:
[build]
compiler=g++
[build_ext]
compiler=g++
which then raises:
error: don't know how to compile C/C++ code on platform 'nt' with 'g++' compiler
Any idea?
Edit: Full trace
running build_ext
running pre_hook from astropy.modeling.setup_package for build_ext command
running pre_hook from astropy._erfa.setup_package for build_ext command
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\username\AppData\Local\Temp\pip-install-id1zp2pt\astropy\setup.py", line 35, in <module>
setup(setup_requires=setup_requires)
File "c:\users\username\appdata\local\temp\pip-install-id1zp2pt\astropy\astropy_helpers\astropy_helpers\setup_helpers.py", line 102, in setup
setuptools_setup(**package_info)
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\setuptools\__init__.py", line 161, in setup
return distutils.core.setup(**attrs)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\install.py", line 61, in run
return orig.install.run(self)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\username\appdata\local\temp\pip-install-id1zp2pt\astropy\astropy_helpers\astropy_helpers\setup_helpers.py", line 298, in run
orig_run(self)
File "c:\users\username\appdata\local\temp\pip-install-id1zp2pt\astropy\astropy_helpers\astropy_helpers\commands\build_ext.py", line 142, in run
super().run()
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
_build_ext.run(self)
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\command\build_ext.py", line 306, in run
self.compiler = new_compiler(compiler=self.compiler,
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\ccompiler.py", line 1032, in new_compiler
return klass(None, dry_run, force)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 282, in __init__
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 157, in __init__
self.dll_libraries = get_msvcr()
File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 86, in get_msvcr
raise ValueError("Unknown MS Compiler version %s " % msc_ver)
ValueError: Unknown MS Compiler version 1916
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\username\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\username\\AppData\\Local\\Temp\\pip-install-id1zp2pt\\astropy\\setup.py'"'"'; __file__='"'"'C:\\Users\\username\\AppData\\Local\\Temp\\pip-install-id1zp2pt\\astropy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\username\AppData\Local\Temp\pip-record-zwu6d9vh\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\username\appdata\local\programs\python\python38\Include\astropy' Check the logs for full command output.