Skip to content

f2py: pyf file mentioned in sources of an Extension is not added to source distribution #19441

Closed

Description

@gmloose

In my project, I have an extension generated from Fortran source code. The generated pyf file needed to be tweaked a bit, and must therefore be treated as a source file as well.

Problem is that, although the pyf file is mentioned as a source file in the Extension, it is not packaged in the source distribution. As, a result, when you try to install from the source tar-ball, the build will fail.

Reproducing code example:

The error cannot be reproduced with a single python file. I created a small demo project that reproduces the error. See https://github.com/gmloose/f2py_hello.
The README.md file describes the steps you have to take in order to reproduce the error.

Error message:

If you follow the steps in the README.md file, you will see the following error message:

build_src
building extension "hello._hello" sources
  target build/src.linux-x86_64-3.6/hello/_hellomodule.c does not exist:
   Assuming _hellomodule.c was generated with "build_src --inplace" command.
error: 'hello/_hellomodule.c' missing

ERROR Backend subproccess exited when trying to invoke get_requires_for_build_wheel

NumPy/Python version information:

python3 -c  'import sys, numpy; print("Numpy version:{}\nPython version:{}".format(numpy.__version__, sys.version))' 
Numpy version:1.19.5
Python version:3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0]

Note that this is the latest numpy version that supports Python 3.6. It was automatically installed in the virtual environment when I installed my demo project.

Activity

  1. pearu commented on Jul 9, 2021

    @pearu
    Contributor

    As a workaround, try including the pyf file in MANIFEST.in file.

  2. gmloose commented on Jul 9, 2021

    @gmloose
    ContributorAuthor

    This solves the issue of having the pyf file in the binary distribution. But it is still a workaround. I think the real issue is in the way Numpy's Extension handles pyf files mentioned as sources, which IMHO is a bug. It shouldn't be necessary to manually add the pyf file to either MANIFEST.in or as package_data argument to setup().

  3. pearu commented on Jul 9, 2021

    @pearu
    Contributor

    Yes, it is a bug: the pyf files should always be considered source files.

  4. gmloose commented on Jan 21, 2022

    @gmloose
    ContributorAuthor

    Any idea when this will be fixed?

  5. HaoZeke commented on Nov 20, 2023

    @HaoZeke
    Member

    Closing as distutils isn't supported anymore. Please use meson-python with the meson backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions