Re: tool located in site_scons\site_tools\toolname causes ImportError
Bill Deegan <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <CAEyG4CHBaH7b3HqfGNzS+eH2BoKq9em5arbKYsNsSUvhiA=wKw@mail.gmail.com> |
Let me see if I can reproduce it here. Also curious if it affects py3.5, py3.6 and non-windows platforms. Looks like you have a workaround so you're not stuck (for the moment). -Bill SCons Project Co-manager. On Fri, Feb 1, 2019 at 4:21 AM Arndt Pauschardt <[email protected]> wrote: > Hi, * > this is my 1st mail to this list, so pls let me know any 'code-of-conduct' > violations ... :-) > > 1. I have installed WinPython 3.7.10 on a Win7 64bit machine and > pip-installed scons into this: > > E:\rfs_projects\test>python -VV > Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit > (AMD64)] > E:\rfs_projects\test>scons --version > SCons by Steven Knight et al.: > script: v3.0.4.3a41ed6b288cee8d085373ad7fa02894e1903864, > 2019-01-20 22:51:36, by bdeegan on kufra > engine: v3.0.4.3a41ed6b288cee8d085373ad7fa02894e1903864, > 2019-01-20 22:51:36, by bdeegan on kufra > engine path: > ['e:\\wpy-3710\\python-3.7.1.amd64\\lib\\site-packages\\scons\\SCons'] > Copyright (c) 2001 - 2019 The SCons Foundation > > > 2. I'm running the following SConstruct > > env = Environment() > env.Tool('astyle') > > 2.1 in site_scons\site_tools\astyle I have an __init__.py and an astyle.py: > __init__.py: > from astyle import generate > from astyle import exists > > astyle.py : > import os > from SCons.Script import * > def generate(env, **kw): > astyle_path = os.path.join(kw.get('TOOL_DIR', ''), 'AStyle') > env.PrependENVPath('PATH', astyle_path) > ASTYLECOM='astyle --verbose ' > env['ASTYLE_OPTS'] = kw.get('OPTS') > import SCons.Builder > # cmd line options, taken from the docu for your convenience > # --ascii output is ascii chars (and not localized or > whatever), output is English > astyle_bld = SCons.Builder.Builder(action=['@echo formatting $SOURCE', > ASTYLECOM+ > '--options=$ASTYLE_OPTS ' > '--ascii ' > '$SOURCE > $TARGET' > ], > suffix='.astyle' > ) > env.Append(BUILDERS={'astyle_C': astyle_bld}) > return > def exists(env): > return 0 > > > 3. Running this (e.g. scons -h) causes an ImportError: > E:\rfs_projects\test>scons -h > scons: Reading SConscript files ... > ImportError: cannot import name 'generate' from 'astyle' > (E:\rfs_projects\test\site_scons\site_tools\astyle\__init__.py): > File "E:\rfs_projects\test\SConstruct", line 2: > env = Environment(tools = ['astyle']) > File > "e:\wpy-3710\python-3.7.1.amd64\lib\site-packages\scons\SCons\Environment.py", > line 982: > apply_tools(self, tools, toolpath) > File > "e:\wpy-3710\python-3.7.1.amd64\lib\site-packages\scons\SCons\Environment.py", > line 107: > env.Tool(tool) > File > "e:\wpy-3710\python-3.7.1.amd64\lib\site-packages\scons\SCons\Environment.py", > line 1788: > tool = SCons.Tool.Tool(tool, toolpath, **kw) > File > "e:\wpy-3710\python-3.7.1.amd64\lib\site-packages\scons\SCons\Tool\__init__.py", > line 117: > module = self._tool_module() > File > "e:\wpy-3710\python-3.7.1.amd64\lib\site-packages\scons\SCons\Tool\__init__.py", > line 232: > module = spec.loader.load_module(spec.name) > File "<frozen importlib._bootstrap_external>", line 407: > File "<frozen importlib._bootstrap_external>", line 907: > File "<frozen importlib._bootstrap_external>", line 732: > File "<frozen importlib._bootstrap>", line 265: > File "<frozen importlib._bootstrap>", line 696: > File "<frozen importlib._bootstrap>", line 677: > File "<frozen importlib._bootstrap_external>", line 728: > File "<frozen importlib._bootstrap>", line 219: > File "E:\rfs_projects\test\site_scons\site_tools\astyle\__init__.py", > line 1: > from astyle import generate > > > 4. Running the exact same SConstruct (and site_scons\..) from a > WinPy2.7.13 (with pip'ed scons 3.0.4) does not cause a problem. > 5. Renaming site_scons\site_tools\astyle to astyle_1 (to take it out) and > moving astyle.py into site_scons\ fixes the issue for the WinPython 3.7. > > I'm not sure what I'm doing wrong, I have been trying to google-read on > this "ImportError", but I did not find anything which seems to explain this. > > Thx for any help on this > Arndt > > > _______________________________________________ > Scons-users mailing list > [email protected] > https://pairlist4.pair.net/mailman/listinfo/scons-users > _______________________________________________ Scons-users mailing list [email protected] https://pairlist4.pair.net/mailman/listinfo/scons-users