Re: tool located in site_scons\site_tools\toolname causes ImportError
"Arndt Pauschardt" <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <trinity-7ef74b95-ea94-45d4-9a77-d4940b0eab90-1549269694114@3c-app-webde-bs51> |
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" <[email protected]> An: "SCons users mailing list" <[email protected]> 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 <[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 _______________________________________________ Scons-users mailing list [email protected] https://pairlist4.pair.net/mailman/listinfo/scons-users