Skip to content

Conversation

@lesteve
Copy link
Contributor

@lesteve lesteve commented Nov 7, 2025

Fix #15123.

Followed #15123 (comment) which recommends to special-case Cython.

  • fixed the code, there are two different code paths
    • .pyx file
    • custom target that generated a .pyx file
  • added a test to make sure that the generated .pyx.c is directly under the .p folder (something like foo.cpython-313-x86_64-linux-gnu.so.p on Linux)
  • added a pyx.c test cases/cython/2 generated sources/libdir/foo.pyx to test one of the code path

I double-checked it seems to work fine with scikit-learn before our work-arounds to use a generator.

@lesteve
Copy link
Contributor Author

lesteve commented Nov 7, 2025

It looks like adding test cases/cython/2 generated sources/libdir/foo.pyx is making another test fail, I need to take a closer look.

output = os.path.join(self.get_target_private_dir(target), f'{src}.{ext}')
# Use basename to avoid too nested targets which can cause a
# problem with MAX_PATH on Windows
basename = src.fname
Copy link
Member

@dcbaker dcbaker Nov 7, 2025

Choose a reason for hiding this comment

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

fname can have path seperators, it's the path relative to the directory that the File object is defined in, so if the src is files('foo/bar/x.pyx'), then fname will reflect that.

@lesteve
Copy link
Contributor Author

lesteve commented Nov 9, 2025

I think the failing test is because Cython should probably espace spaces in paths inside dependency files, see #15227.

I'll try to think of a simpler way to write the test for this PR.

@lesteve
Copy link
Contributor Author

lesteve commented Nov 9, 2025

I tackled #15219 (review) and the case of having src.fname that contains / is handled in the added test.

I ended up creating a separate test in test cases/cython/5 nested folders which is simpler.

@lesteve
Copy link
Contributor Author

lesteve commented Nov 10, 2025

Now all the GHA CIs pass but two Azure Windows CIs fail, I need to take a closer look:

One of the failure seems to be a ninja error ninja: error: failed recompaction: Permission denied build log

ninja explain: output build.ninja older than most recent input ../test cases/cython/5 nested folders/meson.build (7844182826928296 vs 7844182857252785)
[0/1] "C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe" "D:\a\1\s\meson.py" "--internal" "regenerate" "D:\a\1\s\test cases\cython\5 nested folders" "."
ninja: error: failed recompaction: Permission denied

The other one is a meson setup error build log

ERROR: Could not guess language from source file package/metrics/metric.pyx.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Work-around for Cython generated c/cpp files that hit MAX_PATH limitation on Windows?

2 participants