支持vs2005 的msvccompiler.py

本文档详细介绍了 distutils.msvccompiler 模块中 MSVCCompiler 类的实现细节,该类为 Microsoft Visual Studio 提供了一个 C 编译器的具体实现。文中深入探讨了如何通过注册表获取编译器路径配置、如何设置编译选项以及如何进行编译、链接等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

支持vs2005 的msvccompiler.py
"""distutils.msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio.
"""

# Written by Perry Stoll
#
 hacked by Robin Becker and Thomas Heller to do a better job of
#
   finding DevStudio (through the registry)

# This module should be kept compatible with Python 2.1.

__revision__ = "$Id: msvccompiler.py 50979 2006-07-30 13:27:31Z martin.v.loewis $"

import sys, os, string
from distutils.errors import 
     DistutilsExecError, DistutilsPlatformError, 
     CompileError, LibError, LinkError
from distutils.ccompiler import 
     CCompiler, gen_preprocess_options, gen_lib_options
from distutils import log

_can_read_reg 
= 0
try:
    
import _winreg

    _can_read_reg 
= 1
    hkey_mod 
= _winreg

    RegOpenKeyEx 
= _winreg.OpenKeyEx
    RegEnumKey 
= _winreg.EnumKey
    RegEnumValue 
= _winreg.EnumValue
    RegError 
= _winreg.error

except ImportError:
    
try:
        
import win32api
        
import win32con
        _can_read_reg 
= 1
        hkey_mod 
= win32con

        RegOpenKeyEx 
= win32api.RegOpenKeyEx
        RegEnumKey 
= win32api.RegEnumKey
        RegEnumValue 
= win32api.RegEnumValue
        RegError 
= win32api.error

    
except ImportError:
        log.info(
"Warning: Can't read registry to find the "
                 
"necessary compiler setting "
                 
"Make sure that Python modules _winreg, "
                 
"win32api or win32con are installed.")
        
pass

if _can_read_reg:
    HKEYS 
= (hkey_mod.HKEY_USERS,
             hkey_mod.HKEY_CURRENT_USER,
             hkey_mod.HKEY_LOCAL_MACHINE,
             hkey_mod.HKEY_CLASSES_ROOT)

def read_keys(base, key):
    
"""Return list of registry keys."""

    
try:
        handle 
= RegOpenKeyEx(base, key)
    
except RegError:
        
return None
    L 
= []
    i 
= 0
    
while 1:
        
try:
            k 
= RegEnumKey(handle, i)
        
except RegError:
            
break
        L.append(k)
        i 
= i + 1
    
return L

def read_values(base, key):
    
"""Return dict of registry keys and values.

    All names are converted to lowercase.
    
"""
    
try:
        handle 
= RegOpenKeyEx(base, key)
    
except RegError:
        
return None
    d 
= {}
    i 
= 0
    
while 1:
        
try:
            name, value, type 
= RegEnumValue(handle, i)
        
except RegError:
            
break
        name 
= name.lower()
        d[convert_mbcs(name)] 
= convert_mbcs(value)
        i 
= i + 1
    
return d

def convert_mbcs(s):
    enc 
= getattr(s, "encode", None)
    
if enc is not None:
        
try:
            s 
= enc("mbcs")
        
except UnicodeError:
            
pass
    
return s

class MacroExpander:

    
def __init__(self, version):
        self.macros 
= {}
        self.load_macros(version)

    
def set_macro(self, macro, path, key):
        
for base in HKEYS:
            d 
= read_values(base, path)
            
if d:
                self.macros[
"$(%s)" % macro] = d[key]
                
break

    
def load_macros(self, version):
        vsbase 
= r"SoftwareMicrosoftVisualStudio%0.1f" % version
        self.set_macro(
"VCInstallDir", vsbase + r"SetupVC""productdir")
        self.set_macro(
"VSInstallDir", vsbase + r"SetupVS""productdir")
        net 
= r"SoftwareMicrosoft.NETFramework"
        self.set_macro(
"FrameworkDir", net, "installroot")
        
try:
            
if version > 7.0:
                
try:
                    self.set_macro(
"FrameworkSDKDir", net, "sdkinstallrootv1.1")
               
except KeyError:
                    self.set_macro(
"FrameworkSDKDir", net, "sdkinstallrootv2.0")
            
else:
                self.set_macro(
"FrameworkSDKDir", net, "sdkinstallroot")
        
except KeyError, exc: #
            raise DistutilsPlatformError, 
                  (
"""Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
""")

        p 
= r"SoftwareMicrosoftNET Framework SetupProduct"
        
for base in HKEYS:
            
try:
                h 
= RegOpenKeyEx(base, p)
            
except RegError:
                
continue
            key 
= RegEnumKey(h, 0)
            d 
= read_values(base, r"%s%s" % (p, key))
            self.macros[
"$(FrameworkVersion)"= d["version"]

    
def sub(self, s):
        
for k, v in self.macros.items():
            s 
= string.replace(s, k, v)
        
return s

def get_build_version():
    
"""Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    
"""

    prefix 
= "MSC v."
    i 
= string.find(sys.version, prefix)
    
if i == -1:
        
return 6
    i 
= i + len(prefix)
    s, rest 
= sys.version[i:].split(" "1)
    majorVersion 
= int(s[:-2]) - 6
    minorVersion 
= int(s[2:3]) / 10.0
    
# I don't think paths are affected by minor version in version 6
    if majorVersion == 6:
        minorVersion 
= 0
    
if majorVersion >= 6:
        
return majorVersion + minorVersion
    
# else we don't know what version of the compiler this is
    return None

def get_build_architecture():
    
"""Return the processor architecture.

    Possible results are "Intel", "Itanium", or "AMD64".
    
"""

    prefix 
= " bit ("
    i 
= string.find(sys.version, prefix)
    
if i == -1:
        
return "Intel"
    j 
= string.find(sys.version, ")", i)
    
return sys.version[i+len(prefix):j]



class MSVCCompiler (CCompiler) :
    
"""Concrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.
"""

    compiler_type 
= 'msvc'

    
# Just set this so CCompiler's constructor doesn't barf.  We currently
    # don't use the 'set_executables()' bureaucracy provided by CCompiler,
    # as it really isn't necessary for this sort of single-compiler class.
    # Would be nice to have a consistent interface with UnixCCompiler,
    # though, so it's worth thinking about.
    executables = {}

    
# Private class data (need to distinguish C from C++ source for compiler)
    _c_extensions = ['.c']
    _cpp_extensions 
= ['.cc''.cpp''.cxx']
    _rc_extensions 
= ['.rc']
    _mc_extensions 
= ['.mc']

    
# Needed for the filename generation methods provided by the
    # base class, CCompiler.
    src_extensions = (_c_extensions + _cpp_extensions +
                      _rc_extensions 
+ _mc_extensions)
    res_extension 
= '.res'
    obj_extension 
= '.obj'
    static_lib_extension 
= '.lib'
    shared_lib_extension 
= '.dll'
    static_lib_format 
= shared_lib_format = '%s%s'
    exe_extension 
= '.exe'

    
def __init__ (self, verbose=0, dry_run=0, force=0):
        CCompiler.
__init__ (self, verbose, dry_run, force)
        self.
__version = get_build_version()
        self.
__arch = get_build_architecture()
        
if self.__arch == "Intel":
            
# x86
            if self.__version >= 7:
                self.
__root = r"SoftwareMicrosoftVisualStudio"
                self.
__macros = MacroExpander(self.__version)
            
else:
                self.
__root = r"SoftwareMicrosoftDevstudio"
            self.
__product = "Visual Studio version %s" % self.__version
        
else:
            
# Win64. Assume this was built with the platform SDK
            self.__product = "Microsoft SDK compiler %s" % (self.__version + 6)

        self.initialized 
= False

    
def initialize(self):
        self.
__paths = []
        
if os.environ.has_key("DISTUTILS_USE_SDK"and os.environ.has_key("MSSdk"and self.find_exe("cl.exe"):
            
# Assume that the SDK set up everything alright; don't try to be
            # smarter
            self.cc = "cl.exe"
            self.linker 
= "link.exe"
            self.lib 
= "lib.exe"
            self.rc 
= "rc.exe"
            self.mc 
= "mc.exe"
        
else:
            self.
__paths = self.get_msvc_paths("path")

            
if len (self.__paths== 0:
                
raise DistutilsPlatformError, 
                      (
"Python was built with %s, "
                       
"and extensions need to be built with the same "
                       
"version of the compiler, but it isn't installed." % self.__product)

            self.cc 
= self.find_exe("cl.exe")
            self.linker 
= self.find_exe("link.exe")
            self.lib 
= self.find_exe("lib.exe")
            self.rc 
= self.find_exe("rc.exe")   # resource compiler
            self.mc = self.find_exe("mc.exe")   # message compiler
            self.set_path_env_var('lib')
            self.set_path_env_var(
'include')

        
# extend the MSVC path with the current path
        try:
            
for p in string.split(os.environ['path'], ';'):
                self.
__paths.append(p)
        
except KeyError:
            
pass
        os.environ[
'path'= string.join(self.__paths';')

        self.preprocess_options 
= None
        
if self.__arch == "Intel":
            self.compile_options 
= [ '/nologo''/Ox''/MD''/W3''/GX' ,
                                     
'/DNDEBUG']
            self.compile_options_debug 
= ['/nologo''/Od''/MDd''/W3''/GX',
                                          
'/Z7''/D_DEBUG']
        
else:
            
# Win64
            self.compile_options = [ '/nologo''/Ox''/MD''/W3''/GS-' ,
                                     
'/DNDEBUG']
            self.compile_options_debug 
= ['/nologo''/Od''/MDd''/W3''/GS-',
                                          
'/Z7''/D_DEBUG']

        self.ldflags_shared 
= ['/DLL''/nologo''/INCREMENTAL:NO']
        
if self.__version >= 7:
            self.ldflags_shared_debug 
= [
                
'/DLL''/nologo''/INCREMENTAL:no''/DEBUG'
                ]
        
else:
            self.ldflags_shared_debug 
= [
                
'/DLL''/nologo''/INCREMENTAL:no''/pdb:None''/DEBUG'
                ]
        self.ldflags_static 
= [ '/nologo']

        self.initialized 
= True

    
# -- Worker methods ------------------------------------------------

    
def object_filenames (self,
                          source_filenames,
                          strip_dir
=0,
                          output_dir
=''):
        
# Copied from ccompiler.py, extended to return .res as 'object'-file
        # for .rc input file
        if output_dir is None: output_dir = ''
        obj_names 
= []
        
for src_name in source_filenames:
            (base, ext) 
= os.path.splitext (src_name)
            base 
= os.path.splitdrive(base)[1# Chop off the drive
            base = base[os.path.isabs(base):]  # If abs, chop off leading /
            if ext not in self.src_extensions:
                
# Better to raise an exception instead of silently continuing
                # and later complain about sources and targets having
                # different lengths
                raise CompileError ("Don't know how to compile %s" % src_name)
            
if strip_dir:
                base 
= os.path.basename (base)
            
if ext in self._rc_extensions:
                obj_names.append (os.path.join (output_dir,
                                                base 
+ self.res_extension))
            
elif ext in self._mc_extensions:
                obj_names.append (os.path.join (output_dir,
                                                base 
+ self.res_extension))
            
else:
                obj_names.append (os.path.join (output_dir,
                                                base 
+ self.obj_extension))
        
return obj_names

    
# object_filenames ()


    
def compile(self, sources,
                output_dir
=None, macros=None, include_dirs=None, debug=0,
                extra_preargs
=None, extra_postargs=None, depends=None):

        
if not self.initialized: self.initialize()
        macros, objects, extra_postargs, pp_opts, build 
= 
                self._setup_compile(output_dir, macros, include_dirs, sources,
                                    depends, extra_postargs)

        compile_opts 
= extra_preargs or []
        compile_opts.append (
'/c')
        
if debug:
            compile_opts.extend(self.compile_options_debug)
        
else:
            compile_opts.extend(self.compile_options)

        
for obj in objects:
            
try:
                src, ext 
= build[obj]
            
except KeyError:
                
continue
            
if debug:
                
# pass the full pathname to MSVC in debug mode,
                # this allows the debugger to find the source file
                # without asking the user to browse for it
                src = os.path.abspath(src)

            
if ext in self._c_extensions:
                input_opt 
= "/Tc" + src
            
elif ext in self._cpp_extensions:
                input_opt 
= "/Tp" + src
            
elif ext in self._rc_extensions:
                
# compile .RC to .RES file
                input_opt = src
                output_opt 
= "/fo" + obj
                
try:
                    self.spawn ([self.rc] 
+ pp_opts +
                                [output_opt] 
+ [input_opt])
                
except DistutilsExecError, msg:
                    
raise CompileError, msg
                
continue
            
elif ext in self._mc_extensions:

                
# Compile .MC to .RC file to .RES file.
                #   * '-h dir' specifies the directory for the
                #     generated include file
                #   * '-r dir' specifies the target directory of the
                #     generated RC file and the binary message resource
                #     it includes
                #
                # For now (since there are no options to change this),
                # we use the source-directory for the include file and
                # the build directory for the RC file and message
                # resources. This works at least for win32all.

                h_dir 
= os.path.dirname (src)
                rc_dir 
= os.path.dirname (obj)
                
try:
                    
# first compile .MC to .RC and .H file
                    self.spawn ([self.mc] +
                                [
'-h', h_dir, '-r', rc_dir] + [src])
                    base, _ 
= os.path.splitext (os.path.basename (src))
                    rc_file 
= os.path.join (rc_dir, base + '.rc')
                    
# then compile .RC to .RES file
                    self.spawn ([self.rc] +
                                [
"/fo" + obj] + [rc_file])

                
except DistutilsExecError, msg:
                    
raise CompileError, msg
                
continue
            
else:
                
# how to handle this file?
                raise CompileError (
                    
"Don't know how to compile %s to %s" % 
                    (src, obj))

            output_opt 
= "/Fo" + obj
            
try:
                self.spawn ([self.cc] 
+ compile_opts + pp_opts +
                            [input_opt, output_opt] 
+
                            extra_postargs)
            
except DistutilsExecError, msg:
                
raise CompileError, msg

        
return objects

    
# compile ()


    
def create_static_lib (self,
                           objects,
                           output_libname,
                           output_dir
=None,
                           debug
=0,
                           target_lang
=None):

        
if not self.initialized: self.initialize()
        (objects, output_dir) 
= self._fix_object_args (objects, output_dir)
        output_filename 
= 
            self.library_filename (output_libname, output_dir
=output_dir)

        
if self._need_link (objects, output_filename):
            lib_args 
= objects + ['/OUT:' + output_filename]
            
if debug:
                
pass                    # XXX what goes here?
            try:
                self.spawn ([self.lib] 
+ lib_args)
            
except DistutilsExecError, msg:
                
raise LibError, msg

        
else:
            log.debug(
"skipping %s (up-to-date)", output_filename)

    
# create_static_lib ()

    
def link (self,
              target_desc,
              objects,
              output_filename,
              output_dir
=None,
              libraries
=None,
              library_dirs
=None,
              runtime_library_dirs
=None,
              export_symbols
=None,
              debug
=0,
              extra_preargs
=None,
              extra_postargs
=None,
              build_temp
=None,
              target_lang
=None):

        
if not self.initialized: self.initialize()
        (objects, output_dir) 
= self._fix_object_args (objects, output_dir)
        (libraries, library_dirs, runtime_library_dirs) 
= 
            self._fix_lib_args (libraries, library_dirs, runtime_library_dirs)

        
if runtime_library_dirs:
            self.warn (
"I don't know what to do with 'runtime_library_dirs': "
                       
+ str (runtime_library_dirs))

        lib_opts 
= gen_lib_options (self,
                                    library_dirs, runtime_library_dirs,
                                    libraries)
        
if output_dir is not None:
            output_filename 
= os.path.join (output_dir, output_filename)

        
if self._need_link (objects, output_filename):

            
if target_desc == CCompiler.EXECUTABLE:
                
if debug:
                    ldflags 
= self.ldflags_shared_debug[1:]
                
else:
                    ldflags 
= self.ldflags_shared[1:]
            
else:
                
if debug:
                    ldflags 
= self.ldflags_shared_debug
                
else:
                    ldflags 
= self.ldflags_shared

            export_opts 
= []
            
for sym in (export_symbols or []):
                export_opts.append(
"/EXPORT:" + sym)

            ld_args 
= (ldflags + lib_opts + export_opts +
                       objects 
+ ['/OUT:' + output_filename])

            
# The MSVC linker generates .lib and .exp files, which cannot be
            # suppressed by any linker switches. The .lib files may even be
            # needed! Make sure they are generated in the temporary build
            # directory. Since they have different names for debug and release
            # builds, they can go into the same directory.
            if export_symbols is not None:
                (dll_name, dll_ext) 
= os.path.splitext(
                    os.path.basename(output_filename))
                implib_file 
= os.path.join(
                    os.path.dirname(objects[0]),
                    self.library_filename(dll_name))
                ld_args.append (
'/IMPLIB:' + implib_file)

            
if extra_preargs:
                ld_args[:0] 
= extra_preargs
            
if extra_postargs:
                ld_args.extend(extra_postargs)

            self.mkpath (os.path.dirname (output_filename))
            
try:
                self.spawn ([self.linker] 
+ ld_args)
            
except DistutilsExecError, msg:
                
raise LinkError, msg

        
else:
            log.debug(
"skipping %s (up-to-date)", output_filename)

    
# link ()


    
# -- Miscellaneous methods -----------------------------------------
    # These are all used by the 'gen_lib_options() function, in
    # ccompiler.py.

    
def library_dir_option (self, dir):
        
return "/LIBPATH:" + dir

    
def runtime_library_dir_option (self, dir):
        
raise DistutilsPlatformError, 
              
"don't know how to set runtime library search path for MSVC++"

    
def library_option (self, lib):
        
return self.library_filename (lib)


    
def find_library_file (self, dirs, lib, debug=0):
        
# Prefer a debugging library if found (and requested), but deal
        # with it if we don't have one.
        if debug:
            try_names 
= [lib + "_d", lib]
        
else:
            try_names 
= [lib]
        
for dir in dirs:
            
for name in try_names:
                libfile 
= os.path.join(dir, self.library_filename (name))
                
if os.path.exists(libfile):
                    
return libfile
        
else:
            
# Oops, didn't find it in *any* of 'dirs'
            return None

    
# find_library_file ()

    
# Helper methods for using the MSVC registry settings

    
def find_exe(self, exe):
        
"""Return path to an MSVC executable program.

        Tries to find the program in several places: first, one of the
        MSVC program search paths from the registry; next, the directories
        in the PATH environment variable.  If any of those work, return an
        absolute path that is known to exist.  If none of them work, just
        return the original program name, 'exe'.
        
"""

        
for p in self.__paths:
            fn 
= os.path.join(os.path.abspath(p), exe)
            
if os.path.isfile(fn):
                
return fn

        
# didn't find it; try existing path
        for p in string.split(os.environ['Path'],';'):
            fn 
= os.path.join(os.path.abspath(p),exe)
            
if os.path.isfile(fn):
                
return fn

        
return exe

    
def get_msvc_paths(self, path, platform='x86'):
        
"""Get a list of devstudio directories (include, lib or path).

        Return a list of strings.  The list will be empty if unable to
        access the registry or appropriate registry keys not found.
        
"""

        
#if not _can_read_reg:
        #    return []
            
        
if self.__version >= 8:
           
# With .NET 8.0, the environment variables are not stored in the
           # registry anymore.  They are stored in a platform specific file
           # under C:Program FilesMicrosoft Visual Studio 8VCcpackages
           # Instead of parsing these files (which I don't know how to do),
           # we simply rely on the fact that the python script is being
           # called from a "Visual Studio 2005 Command Prompt".  In these
           # consoles, the environment variables are properly defined.
   
           real_path 
= path
           
if path == "library":
                real_path 
= "lib";
           
return string.split(os.environ[real_path], ";")
  
        path 
= path + " dirs"
        
if self.__version >= 7:
            key 
= (r"%s%0.1fVCVC_OBJECTS_PLATFORM_INFOWin32Directories"
                   
% (self.__root, self.__version))
        
else:
            key 
= (r"%s.0Build SystemComponentsPlatforms"
                   r
"Win32 (%s)Directories" % (self.__root, platform))

        
for base in HKEYS:
            d 
= read_values(base, key)
            
if d:
                
if self.__version >= 7:
                    
return string.split(self.__macros.sub(d[path]), ";")
                
else:
                    
return string.split(d[path], ";")
        
# MSVC 6 seems to create the registry entries we need only when
        # the GUI is run.
        if self.__version == 6:
            
for base in HKEYS:
                
if read_values(base, r"%s.0" % self.__rootis not None:
                    self.warn(
"It seems you have Visual Studio 6 installed, "
                        
"but the expected registry settings are not present. "
                        
"You must at least run the Visual Studio GUI once "
                        
"so that these entries are created.")
                    
break
        
return []

    
def set_path_env_var(self, name):
        
"""Set environment variable 'name' to an MSVC path type value.

        This is equivalent to a SET command prior to execution of spawned
        commands.
        
"""

        
if name == "lib":
            p 
= self.get_msvc_paths("library")
        
else:
            p 
= self.get_msvc_paths(name)
        
if p:
            os.environ[name] 
= string.join(p, ';')
我直接输入pip install lap可以运行,但是输入pip install lap ==0.4.0报错,错误信息为 Building wheel for lap (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [17 lines of output] C:\Users\Asus\AppData\Local\Temp\pip-install-of5dgx80\lap_60e3f99852764226a7a9ac99c7c3e734\setup.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import parse_version Partial import of lap during the build process. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\Asus\AppData\Local\Temp\pip-install-of5dgx80\lap_60e3f99852764226a7a9ac99c7c3e734\setup.py", line 236, in <module> setup_package() File "C:\Users\Asus\AppData\Local\Temp\pip-install-of5dgx80\lap_60e3f99852764226a7a9ac99c7c3e734\setup.py", line 223, in setup_package from numpy.distutils.core import setup File "D:\Anaconda\envs\paddle\lib\site-packages\numpy\distutils\core.py", line 24, in <module> from numpy.distutils.command import config, config_compiler, \ File "D:\Anaconda\envs\paddle\lib\site-packages\numpy\distutils\command\config.py", line 19, in <module> from numpy.distutils.mingw32ccompiler import generate_manifest File "D:\Anaconda\envs\paddle\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 29, in <module> from distutils.msvccompiler import get_build_version as get_build_msvc_version ModuleNotFoundError: No module named 'distutils.msvccompiler' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for lap Running setup.py clean for lap Failed to build lap ERROR: Failed to build installable wheels for some pyproject.toml based projects (la
04-02
(paddleseg) C:\Users\16607\Desktop\PaddleSeg-release-2.10>pip install numpy==1.19.5 -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting numpy==1.19.5 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/51/60/3f0fe5b7675a461d96b9d6729beecd3532565743278a9c3fe6dd09697fa7/numpy-1.19.5.zip (7.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 598.1 kB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [275 lines of output] setup.py:67: RuntimeWarning: NumPy 1.19.5 may not yet support Python 3.10. warnings.warn( Running from numpy source directory. setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates run_build = parse_setuppy_commands() Processing numpy/random\_bounded_integers.pxd.in Processing numpy/random\bit_generator.pyx Processing numpy/random\mtrand.pyx Processing numpy/random\_bounded_integers.pyx.in Processing numpy/random\_common.pyx Processing numpy/random\_generator.pyx Processing numpy/random\_mt19937.pyx Processing numpy/random\_pcg64.pyx Processing numpy/random\_philox.pyx Processing numpy/random\_sfc64.pyx Cythonizing sources blas_opt_info: blas_mkl_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries mkl_rt not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE blis_info: libraries blis not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE openblas_info: libraries openblas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']' customize GnuFCompiler Could not locate executable g77 Could not locate executable f77 customize IntelVisualFCompiler Could not locate executable ifort Could not locate executable ifl customize AbsoftFCompiler Could not locate executable f90 customize CompaqVisualFCompiler Could not locate executable DF customize IntelItaniumVisualFCompiler Could not locate executable efl customize Gnu95FCompiler Could not locate executable gfortran Could not locate executable f95 customize G95FCompiler Could not locate executable g95 customize IntelEM64VisualFCompiler customize IntelEM64TFCompiler Could not locate executable efort Could not locate executable efc customize PGroupFlangCompiler Could not locate executable flang don't know how to compile Fortran code on platform 'nt' NOT AVAILABLE atlas_3_10_blas_threads_info: Setting PTATLAS=ATLAS libraries tatlas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE atlas_3_10_blas_info: libraries satlas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE atlas_blas_threads_info: Setting PTATLAS=ATLAS libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE atlas_blas_info: libraries f77blas,cblas,atlas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE accelerate_info: NOT AVAILABLE C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\system_info.py:1914: UserWarning: Optimized (vendor) Blas libraries are not found. Falls back to netlib Blas library which has worse performance. A better performance should be easily gained by switching Blas library. if self._calc_info(blas): blas_info: libraries blas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\system_info.py:1914: UserWarning: Blas (http://www.netlib.org/blas/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [blas]) or by setting the BLAS environment variable. if self._calc_info(blas): blas_src_info: NOT AVAILABLE C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\system_info.py:1914: UserWarning: Blas (http://www.netlib.org/blas/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [blas_src]) or by setting the BLAS_SRC environment variable. if self._calc_info(blas): NOT AVAILABLE non-existing path in 'numpy\\distutils': 'site.cfg' lapack_opt_info: lapack_mkl_info: libraries mkl_rt not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE openblas_lapack_info: libraries openblas not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE openblas_clapack_info: libraries openblas,lapack not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE flame_info: libraries flame not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE atlas_3_10_threads_info: Setting PTATLAS=ATLAS libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries tatlas,tatlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries lapack_atlas not found in C:\ libraries tatlas,tatlas not found in C:\ libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries tatlas,tatlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries lapack_atlas not found in D:\Anaconda3\Library\lib libraries tatlas,tatlas not found in D:\Anaconda3\Library\lib <class 'numpy.distutils.system_info.atlas_3_10_threads_info'> NOT AVAILABLE atlas_3_10_info: libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries satlas,satlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries lapack_atlas not found in C:\ libraries satlas,satlas not found in C:\ libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries satlas,satlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries lapack_atlas not found in D:\Anaconda3\Library\lib libraries satlas,satlas not found in D:\Anaconda3\Library\lib <class 'numpy.distutils.system_info.atlas_3_10_info'> NOT AVAILABLE atlas_threads_info: Setting PTATLAS=ATLAS libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries ptf77blas,ptcblas,atlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries lapack_atlas not found in C:\ libraries ptf77blas,ptcblas,atlas not found in C:\ libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries ptf77blas,ptcblas,atlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries lapack_atlas not found in D:\Anaconda3\Library\lib libraries ptf77blas,ptcblas,atlas not found in D:\Anaconda3\Library\lib <class 'numpy.distutils.system_info.atlas_threads_info'> NOT AVAILABLE atlas_info: libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries f77blas,cblas,atlas not found in C:\Users\16607\.conda\envs\paddleseg\lib libraries lapack_atlas not found in C:\ libraries f77blas,cblas,atlas not found in C:\ libraries lapack_atlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries f77blas,cblas,atlas not found in C:\Users\16607\.conda\envs\paddleseg\libs libraries lapack_atlas not found in D:\Anaconda3\Library\lib libraries f77blas,cblas,atlas not found in D:\Anaconda3\Library\lib <class 'numpy.distutils.system_info.atlas_info'> NOT AVAILABLE lapack_info: libraries lapack not found in ['C:\\Users\\16607\\.conda\\envs\\paddleseg\\lib', 'C:\\', 'C:\\Users\\16607\\.conda\\envs\\paddleseg\\libs', 'D:\\Anaconda3\\Library\\lib'] NOT AVAILABLE C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\system_info.py:1748: UserWarning: Lapack (http://www.netlib.org/lapack/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [lapack]) or by setting the LAPACK environment variable. return getattr(self, '_calc_info_{}'.format(name))() lapack_src_info: NOT AVAILABLE C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\system_info.py:1748: UserWarning: Lapack (http://www.netlib.org/lapack/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [lapack_src]) or by setting the LAPACK_SRC environment variable. return getattr(self, '_calc_info_{}'.format(name))() NOT AVAILABLE numpy_linalg_lapack_lite: FOUND: language = c define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')] C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\dist.py:275: UserWarning: Unknown distribution option: 'define_macros' warnings.warn(msg) running dist_info running build_src build_src building py_modules sources creating build creating build\src.win-amd64-3.10 creating build\src.win-amd64-3.10\numpy creating build\src.win-amd64-3.10\numpy\distutils building library "npymath" sources Traceback (most recent call last): File "C:\Users\16607\.conda\envs\paddleseg\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module> main() File "C:\Users\16607\.conda\envs\paddleseg\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main json_out["return_val"] = hook(**hook_input["kwargs"]) File "C:\Users\16607\.conda\envs\paddleseg\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 175, in prepare_metadata_for_build_wheel return hook(metadata_directory, config_settings) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\build_meta.py", line 157, in prepare_metadata_for_build_wheel self.run_setup() File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\build_meta.py", line 248, in run_setup super(_BuildMetaLegacyBackend, File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup exec(compile(code, __file__, 'exec'), locals()) File "setup.py", line 508, in <module> setup_package() File "setup.py", line 500, in setup_package setup(**metadata) File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\core.py", line 169, in setup return old_setup(**new_attr) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\__init__.py", line 165, in setup return distutils.core.setup(**attrs) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup dist.run_commands() File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands self.run_command(cmd) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command cmd_obj.run() File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\command\dist_info.py", line 31, in run egg_info.run() File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\egg_info.py", line 24, in run self.run_command("build_src") File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command cmd_obj.run() File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\build_src.py", line 144, in run self.build_sources() File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\build_src.py", line 155, in build_sources self.build_library_sources(*libname_info) File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\build_src.py", line 288, in build_library_sources sources = self.generate_sources(sources, (lib_name, build_info)) File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\build_src.py", line 378, in generate_sources source = func(extension, build_dir) File "numpy\core\setup.py", line 658, in get_mathlib_info st = config_cmd.try_link('int main(void) { return 0;}') File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 243, in try_link self._link(body, headers, include_dirs, File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\config.py", line 162, in _link return self._wrap_method(old_config._link, lang, File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\config.py", line 96, in _wrap_method ret = mth(*((self,)+args)) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 137, in _link (src, obj) = self._compile(body, headers, include_dirs, lang) File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\config.py", line 105, in _compile src, obj = self._wrap_method(old_config._compile, lang, File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\command\config.py", line 96, in _wrap_method ret = mth(*((self,)+args)) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 132, in _compile self.compiler.compile([src], include_dirs=include_dirs) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 401, in compile self.spawn(args) File "C:\Users\16607\AppData\Local\Temp\pip-build-env-jsbqs_bs\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 505, in spawn return super().spawn(cmd, env=env) File "C:\Users\16607\AppData\Local\Temp\pip-install-2awzlfe6\numpy_1cc900f1cb7d4c8ba60fd8fe5999e5d1\numpy\distutils\ccompiler.py", line 90, in <lambda> m = lambda self, *args, **kw: func(self, *args, **kw) TypeError: CCompiler_spawn() got an unexpected keyword argument 'env' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.什么问题
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值