[issue37247] swap distutils build_ext and build_py commands to allow proper SWIG extension installation
Jeroen van den Hout added the comment: > Adding a separate build step for SWIG (then the order would be build_swig, > build_py, build_ext) would be safer and IMHO also more logical. I like this suggestion and contemplated it. However SWIG interface files are defined in Extension instances, which are inherently tight to the build_ext command. Breaking this link would require introspection of extensions before deciding on which command to invoke, or a completely separate SWIG Extension class, both of which require a change in usage. > It's not uncommon for projects to extend distutils in various ways and the > proposed change may break those packages. I argue that those packages are already tempering with default behavior of distutils, while the change I am proposing is fixing a flaw in basic functionality and might I say 'implied behavior' of distutils (as the docs say distutils understands SWIG, while it isn't currently even capable of installing correctly when SWIG files are used). The build_ext and build_py commands are truly separate commands, except when SWIG interface files are used: - build_py is responsible for copying pure python files to their correct directories, potentially compiling them to .pyc files. - build_ext is responsible for compiling and linking C/C++ files and copying resultant files to their correct directories. It is only when SWIG files are supplied that a .py file is produced, which quite neatly would be picked up by build_py, given the chance. -- ___ Python tracker <https://bugs.python.org/issue37247> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37247] swap distutils build_ext and build_py commands to allow proper SWIG extension installation
Jeroen van den Hout added the comment: I'm sorry, I read your comment completely wrong, so please disregard my previous comment. I would argue the sequence doesn't really matter that much for non SWIG packages, since those will install correctly no matter if the extensions are built and copied first or not. In the non-SWIG case they are truly independent commands. It is only in the SWIG packages that they become dependent on each other. On top of that I see more and more questions on stack exchange and other forums asking why their SWIG builds fail to install correctly, implying that more and more developers are using this awesome feature and start to rely on it. -- ___ Python tracker <https://bugs.python.org/issue37247> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37247] swap distutils build_ext and build_py commands to allow proper SWIG extension installation
Jeroen van den Hout added the comment: Well, if I look at the source code build_ext explicitly calls for SWIG to handle interface files. Also, in case of commands like 'pip install ', the build sequence is predefined anyways, unless you explicitly define your own sequence in a custom command, in which case you are already tempering with default behavior. That's why I argue that building and copying SWIG generated files correctly should be the default behavior. -- ___ Python tracker <https://bugs.python.org/issue37247> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37247] swap distutils build_ext and build_py commands to allow proper SWIG extension installation
New submission from Jeroen van den Hout : Currently when building an extension which lists a SWIG interface (.i) file as a source file, SWIG creates the files correctly in the build_ext command. Unfortunately this command is run after the build_py command, so the python files (.py) created in the build_ext command are never copied to the installation. To fix this, swap build_ext and build_py commands in the sub_commands attribute of the build command. -- components: Distutils messages: 345330 nosy: Jeroen van den Hout, dstufft, eric.araujo priority: normal severity: normal status: open title: swap distutils build_ext and build_py commands to allow proper SWIG extension installation type: behavior versions: Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue37247> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com