[Scons-users] tool located in site_scons\site_tools\toolname causes ImportError

Eric Fahlgren ericfahlgren at gmail.com
Wed Feb 6 14:03:20 EST 2019


Sorry for the tardy reply.

Neither, we have the tools in the projects directory and they are loaded by
explicit calls to 'env.Tool("BLAH", toolpath=["wherever"])'.

Your question reveals something I should look into cleaning up, so thanks!


On Tue, Feb 5, 2019 at 3:55 AM Arndt Pauschardt <arndt.pauschardt at web.de>
wrote:

> Hi,
> just for confirmation: If you are running on Py3 and use the Tools()
> feature, where are you keeping your tools? In
> site_scons/site_tools/toolnameX/toolnameX.py? Or (as in the workaround), in
> site_scons/toolnameX.py?
> Thx
>
> *Gesendet:* Montag, 04. Februar 2019 um 18:17 Uhr
> *Von:* "Eric Fahlgren" <ericfahlgren at gmail.com>
> *An:* "SCons users mailing list" <scons-users at scons.org>
> *Betreff:* Re: [Scons-users] tool located in
> site_scons\site_tools\toolname causes ImportError
> We've been using Py3 SCons since May 2018.  We have a couple thousand
> lines of tools, plus another couple thousand lines in the SCons* files
> themselves; all were ported over with very minimal changes (but, we'd
> already been using __future__ print and import on everything for years).
>
> The only issue I ran into was using pip to install the early wheel files
> (they were fiddly and required the 'wheel' package be installed first), but
> it appears Bill got that all resolved in 3.0.3 and I am very happy now.
>
>
> On Mon, Feb 4, 2019 at 8:42 AM Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> SCons manual shouldn't say py3 is not supported yet. It's been supported
>> since SCons 3.0.0, although we're finding some issues as users actually
>> start using it.
>> (Where in the manual does it say not supported because that's a bug..)
>>
>>
>> On Mon, Feb 4, 2019 at 3:41 AM Arndt Pauschardt <arndt.pauschardt at web.de>
>> wrote:
>>
>>> Hi, Bill
>>> thanks for looking into this.
>>> a) Yes, we have a work-around. The background of all this is an effort
>>> to retire Python 2.7, scons is the last "tool" in our eco-system which
>>> relies on 2.7, so we would like to migrate to 3.7. So, yes, it works under
>>> 2.7 and we could fix it for 3.7, but I admit that I prefer the
>>> site_scons\site_tools hierarchy approach over "dumping" all tools into
>>> site_scons.
>>> I'm aware of the fact that the SCons manual says that Py3 is not
>>> supported yet, but following this mailing list seems to indicate that using
>>> Py3 is no longer a high risk thing.
>>>
>>> b) I have seen the exact same problem with MSYS2. There, I believed for
>>> a while that it would be caused by an "incomplete" package install:
>>> pacman'ing python 3, then pip'ing scons into an MSYS2 installation has a
>>> problem with the shebang in the "scons" script , it needs to be tweaked.
>>> Then, it seems to work, but fails with the same import error.
>>>
>>> I have not tried Win10, Debian/Raspbian yet - these would be the
>>> platforms I have within reasonable reach.
>>>
>>> Cheers
>>> Arndt
>>>
>>> *Gesendet:* Freitag, 01. Februar 2019 um 15:53 Uhr
>>> *Von:* "Bill Deegan" <bill at baddogconsulting.com>
>>> *An:* "SCons users mailing list" <scons-users at scons.org>
>>> *Betreff:* Re: [Scons-users] tool located in
>>> site_scons\site_tools\toolname causes ImportError
>>> 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 <arndt.pauschardt at web.de>
>>> 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
>>>> Scons-users at scons.org
>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>
>>> _______________________________________________ Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
> _______________________________________________ Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20190206/4b56ad46/attachment.html>


More information about the Scons-users mailing list