0

更新

这是cantera的链接:在此处输入链接描述 ,我确实安装了scons;

 apt-cache policy scons*
  scons:
 Installed: 4.0.1+dfsg-2
 Candidate: 4.0.1+dfsg-2
 Version table:
 *** 4.0.1+dfsg-2 900
    900 http://deb.debian.org/debian testing/main amd64 Packages
    100 /var/lib/dpkg/status
     3.0.1-2 500
    500 http://http.us.debian.org/debian stable/main amd64 Packages

直接链接到源:

在此处输入链接描述

这是调用安装脚本的示例;

scons build prefix='/home/X/SW/Cantera/installed/' --config=force


我一直在尝试升级/安装 Cantera (cantera.org),它依赖于 Scons(使用脚本,'SConstruct')。我注意到在脚本中有一行from buildutils import *. 我尝试使用 , 安装它python3 -m pip install --user buildutils,但我收到了这个大错误:

2016|0|X@X ~/SW/Cantera/cantera $ Wed  7 04 2021, 13:24:08 
 python3 -m pip install --user buildutils
Collecting buildutils
  Using cached buildutils-0.3.tar.gz (47 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-owjzbfid
         cwd: /tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/setup.py", line 5, in <module>
        from ez_setup import use_setuptools
      File "/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/ez_setup.py", line 91
        except pkg_resources.VersionConflict, e:
                                            ^
    SyntaxError: invalid syntax
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/b2/84/797607896d265c2bf00cdaff35c901713f738dfc4efe8ee23bdedb42c789/buildutils-0.3.tar.gz#sha256=8f9921cf145a1879986b4028db0af4f028f65fe6eae29936490174037ba7dfc5 (from https://pypi.org/simple/buildutils/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached buildutils-0.1.2.tar.gz (42 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-28mf5gk7
         cwd: /tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/setup.py", line 5, in <module>
        from ez_setup import use_setuptools
      File "/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/ez_setup.py", line 160
        print "Setuptools successfully installed or upgraded."
              ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Setuptools successfully installed or upgraded.")?
    ----------------------------------------
WARNING: Discarding  https://files.pythonhosted.org/packages/d7/62/b25a56b638d9e1cfc08eba7fd0aa5876f3e2c86f30ca4c5b8c3cda2af524/buildutils-0.1.2.tar.gz#sha256=ad9d597e6836535010880128e5614145f84939c7e26a64c186a7eb37454fa8db (from https://pypi.org/simple/buildutils/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement buildutils
ERROR: No matching distribution found for buildutils

我看到“版本冲突”和括号问题......我还注意到最新版本是 2007 年...... https://pypi.org/project/buildutils/有更新的替代品吗?

我想过尝试从源代码手动安装它(egg 文件显然是为 python2 构建的),但无法成功执行ez_setup.pysetup.py没有错误。我跟着一页,但在我不确定发生了什么之前从未这样做过。

我在互联网上看到很多关于找不到模块的请求,但大多数答案都围绕着错误命名(Can't install PyZMP for Python -- Dependencies),或者没有安装。

buildutils我从 Debian存储库中搜索有关的东西,但没有找到相关的东西。

这源于我KeyValue从 scons 脚本中得到的一个错误,这里显示了相关部分:

...
...
--------------------- end config.log ---------------------
INFO: Using NumPy version 1.19.5.
INFO: Using Cython version 0.29.21.
INFO: Building the full Python package for Python 3.9
KeyError: 'HAS_CLANG':
  File "/home/X/SW/Cantera/cantera/SConstruct", line 1543:
    if env['OS'] == 'Solaris' or env['HAS_CLANG']:
  File "/home/X/.local/lib/python3.9/site-packages/SCons/Environment.py", line 388:
    return self._dict[key]

所以脚本的 1543 周围的行SConstruct是;

...
196 env = Environment(tools=toolchain+['textfile', 'subst', 'recursiveInstall', 'wix', 'gch'],
197                   ENV={'PATH': os.environ['PATH']},
198                   toolchain=toolchain,
199                   **extraEnvArgs)
200
201 env['OS'] = platform.system()
202 env['OS_BITS'] = int(platform.architecture()[0][:2])
...
825 conf = Configure(env, custom_tests={'CheckStatement': CheckStatement})
...
1032 env['HAS_CLANG'] = conf.CheckDeclaration('__clang__', '', 'C++')
...
1526
1527 configh = {}
1528
1529 configh['CANTERA_VERSION'] = quoted(env['cantera_version'])
1530 configh['CANTERA_SHORT_VERSION'] = quoted(env['cantera_short_version'])
1531
1532 # Conditional defines
1533 def cdefine(definevar, configvar, comp=True, value=1):
1534     if env.get(configvar) == comp:
1535         configh[definevar] = value
1536     else:
1537         configh[definevar] = None
1538
1539 # Need to test all of these to see what platform.system() returns
1540 configh['SOLARIS'] = 1 if env['OS'] == 'Solaris' else None
1541 configh['DARWIN'] = 1 if env['OS'] == 'Darwin' else None
1542
1543 if env['OS'] == 'Solaris' or env['HAS_CLANG']:
1544     configh['NEEDS_GENERIC_TEMPL_STATIC_DECL'] = 1
1545
1546 configh['CT_SUNDIALS_VERSION'] = env['sundials_version'].replace('.','')
1547
1548 if env.get('has_sundials_lapack') and env['use_lapack']:
1549     configh['CT_SUNDIALS_USE_LAPACK'] = 1
1550 else:
1551     configh['CT_SUNDIALS_USE_LAPACK'] = 0
1552
1553 cdefine('LAPACK_FTN_STRING_LEN_AT_END', 'lapack_ftn_string_len_at_end')

这看起来很像一本字典,即此处的快速入门部分:在此处输入链接描述,def Environment但我在目录 ( ) 的脚本中找不到(也可能是此配置),grep -nRHI "def Environment" *因此我认为它可能是此模块的一部分buildutils。这解释了为什么我尝试安装它以及随后的错误。我意识到我可以尝试只注释掉第 1543 行并取消缩进第 1544 行,因为我确实有铿锵声,但我不确定我是否有“正确”的铿锵声......

编辑

我确实有buildutil,并且正在搜索 PyPl,也许这是替代品.... mercurial 存储库链接buildutils似乎不起作用,但也许我可以awk在整个项目中替换名称...我也在https 上看到: //pypi.org/project/buildutil/它可能只对python3.6有好处...

编辑 2

我现在想知道它是否不仅仅是重命名...,因为这两个名称都列在https://github.com/tedicreations/buildutil ...所以也许只是awk将名称从更改为的buildutils脚本buildutil...

编辑 3 根据 的建议2to3,我尝试了显示这些更改;

 2to3 -f all -w SConstruct
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored SConstruct
--- SConstruct  (original)
+++ SConstruct  (refactored)
@@ -37,7 +37,7 @@
     'scons doxygen' - Build the Doxygen documentation
 """
 
-from __future__ import print_function
+
 from buildutils import *
 
 if not COMMAND_LINE_TARGETS:
@@ -216,7 +216,7 @@
 
 # Fix an issue with Unicode sneaking into the environment on Windows
 if os.name == 'nt':
-    for key,val in env['ENV'].items():
+    for key,val in list(env['ENV'].items()):
         env['ENV'][key] = str(val)
 
 if 'FRAMEWORKS' not in env:
@@ -327,7 +327,7 @@
 defaults.python_prefix = '$prefix' if env['OS'] != 'Windows' else ''
 
 # Transform lists into strings to keep cantera.conf clean
-for key,value in defaults.__dict__.items():
+for key,value in list(defaults.__dict__.items()):
     if isinstance(value, (list, tuple)):
         setattr(defaults, key, ' '.join(value))
 
@@ -660,7 +660,7 @@
 
 # Expand ~/ and environment variables used in cantera.conf (variables used on
 # the command line will be expanded by the shell)
-for option in opts.keys():
+for option in list(opts.keys()):
     original = env[option]
     if isinstance(original, str):
         modified = os.path.expandvars(os.path.expanduser(env[option]))
RefactoringTool: Files that were modified:
RefactoringTool: SConstruct

但是在 ascons clean和 a之后scons test-clean,错误仍然存​​在(可能是字典问题......);

 scons build prefix='/home/X/SW/Cantera/installed/'  --config=force
scons: Reading SConscript files ...
INFO: SCons is using the following Python interpreter: /usr/bin/python3
Configuration variables read from 'cantera.conf' and command line:
    prefix = '/home/X/SW/Cantera/installed/'

Checking for C++ header file cmath... yes
Checking for C++ header file fmt/ostream.h... yes
INFO: Using system installation of fmt library.
INFO: Found fmt version 7.1.3
Checking for C++ header file yaml-cpp/yaml.h... yes
INFO: Using system installation of yaml-cpp library.
Checking for C++ header file gtest/gtest.h... no
Checking for C++ header file gmock/gmock.h... no
INFO: Using Googletest from Git submodule
Checking for C++ header file Eigen/Dense... no
INFO: Using private installation of Eigen.
INFO: Found Eigen version 3.3.7
Checking whether __GLIBCXX__ is declared... yes
Checking whether __clang__ is declared... no
Checking for C++ header file omp.h... yes
INFO: Found Boost version 1.74
Checking whether boost::core::demangle is declared... yes
Checking for CVodeCreate(CV_BDF, CV_NEWTON) in C++ library sundials_cvodes... no
Checking for CVodeCreate(CV_BDF) in C++ library sundials_cvodes... yes
Checking for double x; log(x) in C library None... no
INFO: Using system installation of Sundials version 4.1.0.
Checking whether SUNDIALS_BLAS_LAPACK is declared... yes
sh: 1: .sconf_temp/conftest_9d002cee8d847914673abd8559024f70_0_3ae94ee097a5c84b400a349871c73680: not found
WARNING: Unable to use 'gfortran' to compile the Fortran interface. See config.log for details.
INFO: Skipping compilation of the Fortran 90 interface.
INFO: Using NumPy version 1.19.5.
INFO: Using Cython version 0.29.21.
INFO: Building the full Python package for Python 3.9
KeyError: 'HAS_CLANG':
  File "/home/X/SW/Cantera/cantera/SConstruct", line 1542:
    if env['OS'] == 'Solaris' or env['HAS_CLANG']:
  File "/home/X/.local/lib/python3.9/site-packages/SCons/Environment.py", line 388:
    return self._dict[key]

我注意到,如果这确实是一个适当的更改,则2to3可能无法将模块从转换为buildutils的规则...buildutil

和...

这是来自modernize模块,因为它没有摆脱buildutils(我没有),尝试运行它似乎毫无意义......我做了......仍然是同样的错误。

 python3 -m modernize -w SConstruct 
 Loading the following fixers:
    fissix.fixes.fix_apply  (apply)
    fissix.fixes.fix_except  (except)
    fissix.fixes.fix_exec  (exec)
    fissix.fixes.fix_execfile  (execfile)
    fissix.fixes.fix_exitfunc  (exitfunc)
    fissix.fixes.fix_funcattrs  (funcattrs)
    fissix.fixes.fix_has_key  (has_key)
    fissix.fixes.fix_idioms  (idioms)
    fissix.fixes.fix_long  (long)
    fissix.fixes.fix_methodattrs  (methodattrs)
    fissix.fixes.fix_ne  (ne)
    fissix.fixes.fix_numliterals  (numliterals)
    fissix.fixes.fix_operator  (operator)
    fissix.fixes.fix_paren  (paren)
    fissix.fixes.fix_reduce  (reduce)
    fissix.fixes.fix_renames  (renames)
    fissix.fixes.fix_repr  (repr)
    fissix.fixes.fix_set_literal  (set_literal)
    fissix.fixes.fix_standarderror  (standarderror)
    fissix.fixes.fix_sys_exc  (sys_exc)
    fissix.fixes.fix_throw  (throw)
    fissix.fixes.fix_tuple_params  (tuple_params)
    fissix.fixes.fix_types  (types)
    fissix.fixes.fix_ws_comma  (ws_comma)
    fissix.fixes.fix_xreadlines  (xreadlines)
    libmodernize.fixes.fix_basestring  (basestring)
    libmodernize.fixes.fix_dict_six  (dict_six)
    libmodernize.fixes.fix_file  (file)
    libmodernize.fixes.fix_filter  (filter)
    libmodernize.fixes.fix_import  (import)
    libmodernize.fixes.fix_imports_six  (imports_six)
    libmodernize.fixes.fix_input_six  (input_six)
    libmodernize.fixes.fix_int_long_tuple  (int_long_tuple)
    libmodernize.fixes.fix_itertools_imports_six  (itertools_imports_six)
    libmodernize.fixes.fix_itertools_six  (itertools_six)
    libmodernize.fixes.fix_map  (map)
    libmodernize.fixes.fix_metaclass  (metaclass)
    libmodernize.fixes.fix_next  (next)
    libmodernize.fixes.fix_print  (print)
    libmodernize.fixes.fix_raise  (raise)
    libmodernize.fixes.fix_raise_six  (raise_six)
    libmodernize.fixes.fix_unichr  (unichr)
    libmodernize.fixes.fix_unicode_type  (unicode_type)
    libmodernize.fixes.fix_urllib_six  (urllib_six)
    libmodernize.fixes.fix_xrange_six  (xrange_six)
    libmodernize.fixes.fix_zip  (zip)
 Applying the following explicit transformations:
    (None)

RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored SConstruct
--- SConstruct  (original)
+++ SConstruct  (refactored)
@@ -38,6 +38,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 from buildutils import *
 
 if not COMMAND_LINE_TARGETS:
RefactoringTool: Files that were modified:
RefactoringTool: SConstruct
4

1 回答 1

0

一些旧包可以用2to3 工具修复,在旧源文件夹上运行它,然后尝试使用 python3 进行设置。另一种方法是安装python2。

于 2021-04-07T21:32:04.643 回答