GeezerVison is showing github.com — ENH: distutils - add add options for "skip:" and "only:" to be passed to f2py · Issue #22508 · numpy/numpy
ENH: distutils - add add options for "skip:" and "only:" to be passed to f2py #22508DescriptionProposed new feature or change:
Would it be possible to add feature for skip: and and only: to be passed to the f2py call in numpy.distutils.Extension?
The documentation says
f2py [<options>] <fortran files> [[[only:]||[skip:]] \
<fortran functions> ] \
[: <fortran files> ...]
Passing on these extra lists would be very useful. It seems currently not possible or at least not documented.
If a workaround could be suggested and documented, that would also be very much appreciated. ActivityHaoZeke commented on Nov 1, 2022 This might be something to consider as part of the CLI rewrite #21923 (@NamamiShanker) since the current CLI is buggy (inconsistent) while handling only #20520 2sn commented on Nov 1, 2022 ContributorAuthor More actions @HaoZeke The background is that I want to use full Fortran capability, e.g., function pointers, etc., but that does not seem possible when f2py tries to wrap it all.
For other projects that I only use locally without distribution yet - and for that reason - I make a separate library (.a), and an interface module just for f2py that calls these library functions. But I do not know a way how to do that with the distutils. If you can suggest a way to do that, it would solve many issues. (And I would be happy to share details of the approach for use by others.) HaoZeke commented on Aug 26, 2023
@HaoZeke The background is that I want to use full Fortran capability, e.g., function pointers, etc., but that does not seem possible when f2py tries to wrap it all.
For other projects that I only use locally without distribution yet - and for that reason - I make a separate library (.a), and an interface module just for f2py that calls these library functions. But I do not know a way how to do that with the distutils. If you can suggest a way to do that, it would solve many issues. (And I would be happy to share details of the approach for use by others.)
This should actually be happening automatically, when using skip: and only: the wrappers should not contain the rest of the codebase. Could you also try with #24532 ? 2sn commented on Aug 27, 2023 ContributorAuthor More actions It did not work in the past, I think we got around it be including fixed wrappers in the project instead of generating them; it has since been rewritten for use with Meson by a software engineer (@conradtchan from ADACS) to make it ready for the next python release, I have not had time to study the resulting code base in detail. It is in the starfit package on PyPI/github in case you like to have a look. Reacted by Rohit Goswami Reacted by Rohit Goswami Reacted by Rohit Goswami HaoZeke commented on Nov 12, 2023 I tested the code in starfit, and version:2.0.0.dev0+git20231111.9340fca does seem correctly regenerate the required solver.pyf:
❯ f2py -m _solver -h solver.pyf --f2cmap .f2py_f2cmap solver.f90 only: fitness_ fitness_m_ get_complete_matrix_ get_complete_inverse_ : --overwrite-signature
diff --git i/src/starfit/fitness/solver.pyf w/src/starfit/fitness/solver.pyf
index ad67e06..4b0224b 100644
--- i/src/starfit/fitness/solver.pyf
+++ w/src/starfit/fitness/solver.pyf
@@ -1,7 +1,7 @@
! -*- f90 -*-
! Note: the context of this file is case sensitive.
-python module _solver ! in
+python module _solver ! in
interface ! in :_solver
subroutine fitness_(f,c,obs,err,det,cov,abu,nel,ncov,nstar,nsol,ls,icdf,flags) ! in :_solver:solver.f90
use fitting, only: fitness
@@ -12,7 +12,7 @@ python module _solver ! in
real(kind=real64) dimension(nel),intent(in),depend(nel) :: err
real(kind=real64) dimension(nel),intent(in),depend(nel) :: det
real(kind=real64) dimension(nel,ncov),intent(in),depend(nel) :: cov
- real(kind=real64) dimension(nsol,nstar,nel),intent(in),depend(nel,nstar,nsol) :: abu
+ real(kind=real64) dimension(nsol,nstar,nel),intent(in),depend(nsol,nel,nstar) :: abu
integer(kind=int64), optional,intent(in),check(shape(obs, 0) == nel),depend(obs) :: nel=shape(obs, 0)
integer(kind=int64), optional,intent(in),check(shape(cov, 1) == ncov),depend(cov) :: ncov=shape(cov, 1)
integer(kind=int64), optional,intent(in),check(shape(c, 1) == nstar),depend(c) :: nstar=shape(c, 1)
@@ -24,13 +24,13 @@ python module _solver ! in
subroutine fitness_m_(f,c,obs,err,det,cov,abu,nel,ncov,nstar,nsol,ls,icdf,flags) ! in :_solver:solver.f90
use fitting, only: fitness_m
use typedef, only: real64,int64
- real(kind=real64) dimension(nsol,nel,nel),intent(out),depend(nel,nsol) :: f
+ real(kind=real64) dimension(nsol,nel,nel),intent(out),depend(nsol,nel) :: f
real(kind=real64) dimension(nsol,nstar),intent(in,out) :: c
real(kind=real64) dimension(nel),intent(in) :: obs
real(kind=real64) dimension(nel),intent(in),depend(nel) :: err
real(kind=real64) dimension(nel),intent(in),depend(nel) :: det
real(kind=real64) dimension(nel,ncov),intent(in),depend(nel) :: cov
- real(kind=real64) dimension(nsol,nstar,nel),intent(in),depend(nel,nstar,nsol) :: abu
+ real(kind=real64) dimension(nsol,nstar,nel),intent(in),depend(nsol,nel,nstar) :: abu
integer(kind=int64), optional,intent(in),check(shape(obs, 0) == nel),depend(obs) :: nel=shape(obs, 0)
integer(kind=int64), optional,intent(in),check(shape(cov, 1) == ncov),depend(cov) :: ncov=shape(cov, 1)
integer(kind=int64), optional,intent(in),check(shape(c, 1) == nstar),depend(c) :: nstar=shape(c, 1)
@@ -52,7 +52,7 @@ python module _solver ! in
integer(kind=int64) intent(in) :: icdf
end subroutine get_complete_matrix_
subroutine get_complete_inverse_(m1,obs,err,det,cov,nel,ncov,icdf) ! in :_solver:solver.f90
- use star_data, only: set_star_data,get_complete_matrix
+ use star_data, only: set_star_data,get_complete_inverse
use typedef, only: real64,int64
real(kind=real64) dimension(nel,nel),intent(out),depend(nel) :: m1
real(kind=real64) dimension(nel),intent(in) :: obs
@@ -63,9 +63,9 @@ python module _solver ! in
integer(kind=int64), optional,intent(in),check(shape(cov, 1) == ncov),depend(cov) :: ncov=shape(cov, 1)
integer(kind=int64) intent(in) :: icdf
end subroutine get_complete_inverse_
- end interface
+ end interface
end python module _solver
-! This file was auto-generated with f2py (version:1.23.5).
+! This file was auto-generated with f2py (version:2.0.0.dev0+git20231111.9340fca).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e
So I'm going to close this for now.. but please free to reopen if there's something I missed :)
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|