Issue 13317: building with 2to3 generates wrong import paths because build_ext is run after build_py (original) (raw)

Created on 2011-11-01 21:32 by simohe, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
iss_13317.patch curioswati,2015-12-23 05:14 review
Messages (10)
msg146808 - (view) Author: simohe (simohe) Date: 2011-11-01 21:32
We need build_ext before build_py. Otherwise, when 2to3 is called (in build_py), it will not find ext modules, thinking that those modules are global and, consequently, making a mess, now that all module imports are global.
msg146944 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-03 16:33
Hello and thanks for the report. > We need build_ext before build_py. Otherwise, when 2to3 is called (in build_py), > it will not find ext modules, Why is 2to3 interested in extension modules? 2to3 converts Python code, extension modules are written in C or C++. > thinking that those modules are global I don’t understand what you mean. Can you give me a Python or shell script to reproduce the error or a full description of what you did, what you expected and what went wrong?
msg146979 - (view) Author: simohe (simohe) Date: 2011-11-03 20:51
fix_imports rewrites the import statements to local or global. When a python module loads a local extension module, this import statement should be converted to a local import (from . import extensionmodule). But when the extension module is not built yet, fix_imports does not find them (no file named extenstionmodule.[so|sl]). So it suggests a global import (import extensionmodule). The original comment is a slightly modified version of this here: http://selenic.com/hg/file/afc02adf4ded/contrib/setup3k.py#l223 short summary: build.sub_commands in distutils.command.build should list "build_ext" before "build_py". lib2to3.fixes.fix_import will write global instead of local import statements else.
msg148044 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-21 14:35
Ah, thanks for clarifying, I didn’t understand what you meant with local/global but now I see it’s about absolute imports and explicit relative imports. (I don’t remember ever reading that terminology before looking at fix_import.) I’m adding the “easy” keyword because it should not be too hard to write tests for this, with the examples and helpers we already have in the test suite and given that I’m available for help.
msg183926 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-03-11 04:35
For the record this is caused by #17393
msg256133 - (view) Author: Swati Jaiswal (curioswati) * Date: 2015-12-09 02:59
are you working on it @eric?
msg256811 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2015-12-21 21:55
I’m not active in python-dev anymore. The fix was noted in a previous comment: build.sub_commands in distutils.command.build should list "build_ext" before "build_py". lib2to3.fixes.fix_import will write global instead of local import statements else.
msg256899 - (view) Author: Swati Jaiswal (curioswati) * Date: 2015-12-23 05:14
Can someone help with tests? I just need a pointer on how to do it.
msg348637 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-07-29 11:47
This issue is no newcomer friendly, I remove the "easy" keyword.
msg386277 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:10
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils. If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2022-04-11 14:57:23 admin set github: 57526
2021-02-03 18:10:32 steve.dower set status: open -> closednosy: + steve.dowermessages: + resolution: out of datestage: needs patch -> resolved
2019-07-29 11:47:55 vstinner set keywords: - easynosy: + vstinnermessages: +
2015-12-23 05:14:03 curioswati set files: + iss_13317.patchkeywords: + patchmessages: +
2015-12-21 21:55:29 eric.araujo set versions: + Python 3.5, - 3rd party, Python 3.2, Python 3.3nosy: + dstufftmessages: + assignee: eric.araujo -> components: - Distutils2
2015-12-09 02:59:00 curioswati set nosy: + curioswatimessages: +
2013-03-11 04:35:01 eric.araujo set messages: +
2011-11-21 14:35:24 eric.araujo set assignee: tarek -> eric.araujotype: behaviorcomponents: + Distutils2, - 2to3 (2.x to 3.x conversion tool)versions: + 3rd party, Python 3.2, Python 3.3keywords: + easynosy: + alexismessages: + stage: needs patch
2011-11-05 22:42:51 Arfrever set nosy: + Arfrever
2011-11-03 20:51:34 simohe set nosy: + tarekmessages: + assignee: tarekcomponents: + Distutils, - Build
2011-11-03 16:33:50 eric.araujo set nosy: + eric.araujomessages: +
2011-11-01 21:32:12 simohe create