New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_scandir extension doesn't compile on Solaris 11 #29
Comments
Interesting. Well, scandir won't gain us much on Solaris in that case. Do you know of a compiler macro to test whether the |
glibc defines _DIRENT_HAVE_D_TYPE, but there are other platforms that have d_type that don't define this (BSD/OS X). Qt5 uses: (I suppose you could also check for one of the other defs like DT_UNKNOWN being defined.) |
Hmm, I'm not sure the best combination of macros. Yeah, I think checking for |
I checked Solaris 11.1, DT_UNKNOWN is not defined. (I will keep the VM available for further testing.) Do the python devs have anything to say about these kinds of checks being in the codebase? |
I've heavily changed _scandir.c to update it to the version of C code used in Python 3.5. Feel free to check if this is still an issue, otherwise I'll close. |
Hi, I believe the issue is that Solaris does not support d_type in dirent. See this for an example of how to shim it. http://blueslugs.com/2010/06/13/adirent-ch-adding-d_type-to-struct-dirent-on-opensolaris/ Wouldn't scandir still be useful due to it being a generator (if I understand it properly) for those trying to read a huge amount of files in a single directory? |
Got it, thanks. In CPython that macro is set in the Per the comment above, what about defining
|
Yep, that will fix it. Was just looking at that bit of code and came here to ask about it. |
Also, assuming that is the exact code change you make, it compiled and the tests were successful on SunOS 5.10 Generic_150400-14 sun4v sparc sun4v:
|
Thanks. It compiling now is good, but unfortunately it's not actually being used yet. I have too tight a test on
to include your SunOS system (either include |
Ohh, Okie doke. I have to leave soon but I can get back on this later to try and help. Lots of errors.
and:
|
Okay, thanks. However, what I would have expected is to see TestScandirC in the test output. The fact that it's not means scandir.py can't import the C module. I expect that if you run Python and try In any case, I'm not sure whether it's worth spending too much time on Solaris/SunOS, as there's going to be no performance improvement for scandir without d_type. So maybe it's okay to just let it use scandir_generic? |
Sorry I was in a hurry and didn't do the test right with _scandir. _scandir loads. Here is the test, all scandir_python fails on the readdir_r call.
|
Also with regards to performance gains... there is one big advantage to using scandir on Solaris and that is.. if you are trying to read a directory with millions of files in it. os.listdir will read the entire directory while scandir iterates and only calls getdents as needed. This is my very unfortunate situation. I did a truss on this and confirmed it using _scandir vs listdir. I only saw a single stat call which I assume was making sure it was a directory or something that we were scanning. Looked pretty efficient to me. I know that if I had to recurse into directories, I would incur a stat call on every file... but that's no different than where I am already at today, so it is a draw on this part. Do you agree? Or am I missing something else important? I'm just going to use _scandir for my purposes, but I'm happy to help get the scandir_python working if you want. |
Yeah, that's a good point. I'm glad |
…Solaris). Don't try to use scandir_python on systems without d_type (Solaris). #29
Thanks, @mverrilli. I've just commited 612a61c which should fix this and allow _scandir.c to compile and scandir to use that and work on Solaris. |
gcc -m64 -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 -c _scandir.c -o build/temp.solaris-2.11-i86pc.64bit-2.7/_scandir.o
_scandir.c: In function '_fi_next':
_scandir.c:484:60: error: 'struct dirent' has no member named 'd_type'
_scandir.c:486:60: error: 'struct dirent' has no member named 'd_type'
_scandir.c:488:1: warning: control reaches end of non-void function
error: command 'gcc' failed with exit status 1
See http://stackoverflow.com/questions/2197918/cross-platform-way-of-testing-whether-a-file-is-a-directory
The text was updated successfully, but these errors were encountered: