GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #22508

New issue
Copy link
New issue
Copy link
Closed
Closed
ENH: distutils - add add options for "skip:" and "only:" to be passed to f2py#22508
Copy link
Labels
01 - Enhancementcomponent: numpy.f2py

Description

@2sn
2sn
opened on Nov 1, 2022
Issue body actions

Proposed 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.

Reacted by Rohit Goswami

Activity

  1. HaoZeke
    added
    01 - Enhancement
    component: numpy.f2py
    on Nov 1, 2022
  2. HaoZeke commented on Nov 1, 2022

    @HaoZeke
    HaoZeke
    on Nov 1, 2022
    Member
    More actions

    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

  3. 2sn commented on Nov 1, 2022

    @2sn
    2sn
    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.)

  4. HaoZeke commented on Aug 26, 2023

    @HaoZeke
    HaoZeke
    on Aug 26, 2023
    Member
    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.)

    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 ?

  5. 2sn commented on Aug 27, 2023

    @2sn
    2sn
    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
  6. HaoZeke commented on Nov 12, 2023

    @HaoZeke
    HaoZeke
    on Nov 12, 2023
    Member
    More actions

    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 :)

  7. HaoZeke
    closed this as completedon Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    01 - Enhancementcomponent: numpy.f2py

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.