first cut at fortran support for distutils

Travis Oliphant and I have hacked together Fortran support for distutils in the course of putting together scipy (www.scipy.org). I won't pretend its pretty, but it does seem to do the job on Linux and W2000/W98 using the mingw32 version of gcc/g77. We're also working on Sun and Irix. Basically, the static_clib has been modified to build static libraries of the fortran code that are then linked with the extension module interface (written in C). We'd like to work toward this becoming a standard part of distutils. Are others interested in this? Also, opinions on how to best pursue its inclusion are welcomed. If your interested, please grab the source version of scipy from the site and take a look at fortran_support.py, build_flib.py, build_clib_new.py, and setup.py. thanks, eric

The concern I have is that Fortran is not in the same boat here that C is. C compilations can get their command-line arguments by default at least by using the settings that Python was compiled with, and that was determined by a configuration process. For Fortran, there is no such crutch so any new compiler will have to be added to distutils by hand. And Fortran users are much more likely IMHO to want to fool around with the flags. The approach I took in Pyfort was to assume that the USER could make the static library. That reduces the question to (a) getting the right run-time modules linked and (b) writing a wrapper so the functions can be called from Fortran. But (a) actually depends on the compiler flags used, and of course (b) has to be done some way or the other, either by hand or with a tool. Pyfort therefore uses distutils to do the link and by default includes the basic libraries into the libdir and dirlist lists, and the user can then add to that via the Pyfort command line. So I didn't need any changes to distutils itself, I just used it from my Python. -----Original Message----- From: distutils-sig-admin@python.org [mailto:distutils-sig-admin@python.org] On Behalf Of eric jones Sent: Monday, August 20, 2001 5:48 PM To: distutils-sig@python.org Cc: oliphant.travis@ieee.org Subject: [Distutils] first cut at fortran support for distutils Travis Oliphant and I have hacked together Fortran support for distutils in the course of putting together scipy (www.scipy.org). I won't pretend its pretty, but it does seem to do the job on Linux and W2000/W98 using the mingw32 version of gcc/g77. We're also working on Sun and Irix. Basically, the static_clib has been modified to build static libraries of the fortran code that are then linked with the extension module interface (written in C). We'd like to work toward this becoming a standard part of distutils. Are others interested in this? Also, opinions on how to best pursue its inclusion are welcomed. If your interested, please grab the source version of scipy from the site and take a look at fortran_support.py, build_flib.py, build_clib_new.py, and setup.py. thanks, eric _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig

Hi, I completely agree with Paul's concerns below but I don't think that nothing should be done in this matter. Playing with compiler flags is rare (you can find optimal flag configuration once, later may be change it a bit) relative to the actual compilation of Fortran programs that are developed in connection with Python (here talking based on my experience). So, it would be very useful if Fortran codes could be compiled within setup.py. And more importantly, one could crab, say from Internet, a Python package containing Fortran codes and build it from scratch (rather than messing with Makefiles that are platform dependent even on unices). Here assuming that support for Fortran compilers is set up properly locally - this is not a problem on unices, don't know about windows. So, I think that that the work of Eric and Travis is relevant and very useful. Regards, Pearu On Thu, 30 Aug 2001, Paul F. Dubois wrote:

The concern I have is that Fortran is not in the same boat here that C is. C compilations can get their command-line arguments by default at least by using the settings that Python was compiled with, and that was determined by a configuration process. For Fortran, there is no such crutch so any new compiler will have to be added to distutils by hand. And Fortran users are much more likely IMHO to want to fool around with the flags. The approach I took in Pyfort was to assume that the USER could make the static library. That reduces the question to (a) getting the right run-time modules linked and (b) writing a wrapper so the functions can be called from Fortran. But (a) actually depends on the compiler flags used, and of course (b) has to be done some way or the other, either by hand or with a tool. Pyfort therefore uses distutils to do the link and by default includes the basic libraries into the libdir and dirlist lists, and the user can then add to that via the Pyfort command line. So I didn't need any changes to distutils itself, I just used it from my Python. -----Original Message----- From: distutils-sig-admin@python.org [mailto:distutils-sig-admin@python.org] On Behalf Of eric jones Sent: Monday, August 20, 2001 5:48 PM To: distutils-sig@python.org Cc: oliphant.travis@ieee.org Subject: [Distutils] first cut at fortran support for distutils Travis Oliphant and I have hacked together Fortran support for distutils in the course of putting together scipy (www.scipy.org). I won't pretend its pretty, but it does seem to do the job on Linux and W2000/W98 using the mingw32 version of gcc/g77. We're also working on Sun and Irix. Basically, the static_clib has been modified to build static libraries of the fortran code that are then linked with the extension module interface (written in C). We'd like to work toward this becoming a standard part of distutils. Are others interested in this? Also, opinions on how to best pursue its inclusion are welcomed. If your interested, please grab the source version of scipy from the site and take a look at fortran_support.py, build_flib.py, build_clib_new.py, and setup.py. thanks, eric _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig

Hi, I completely agree with Paul's concerns below but I don't think that nothing should be done in this matter. Playing with compiler flags is rare (you can find optimal flag configuration once, later may be change it a bit) relative to the actual compilation of Fortran programs that are developed in connection with Python (here talking based on my experience). So, it would be very useful if Fortran codes could be compiled within setup.py. And more importantly, one could crab, say from Internet, a Python package containing Fortran codes and build it from scratch (rather than messing with Makefiles that are platform dependent even on unices). Here assuming that support for Fortran compilers is set up properly locally - this is not a problem on unices, don't know about windows. So, I think that that the work of Eric and Travis is relevant and very useful. Regards, Pearu On Thu, 30 Aug 2001, Paul F. Dubois wrote:
participants (3)
-
eric jones
-
Paul F. Dubois
-
Pearu Peterson