Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@DWesl
Copy link
Contributor

@DWesl DWesl commented Nov 10, 2025

Test for #29762 with fix suggested by #29762 and #24874

f2py failed when the source directory was the build directory, due to a failure to copy the source files to the build directory.  This commit accepts this state as resulting in the source files being present in the build directory.

Suggested in numpy#29762 and numpy#24874
@DWesl
Copy link
Contributor Author

DWesl commented Nov 11, 2025

@2sn, applying your suggested fix in the obvious spots did not make the test pass. Was there anything else you did to make this scenario work?

]
# we filter the only public function mod2
only = ["mod1_func1", ]
options = ["--build-dir", util.get_module_dir()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

util.get_module_dir() returns a fresh temporary directory:

def get_module_dir():
global _module_dir
if _module_dir is None:
_module_dir = tempfile.mkdtemp()
atexit.register(_cleanup)
if _module_dir not in sys.path:
sys.path.insert(0, _module_dir)
return _module_dir

How is that a test for building inside the source directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

util.get_module_dir() also caches that module directory and returns the same one until it's cleared.

util.build_module() uses that function to get a directory to put the source files for a given test in: since util.get_module_dir() caches its result, the option will have f2py use as a build directory the same temporary directory it put the sources in.

I think T2PyTest cleanup will clear the temporary directory.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants