Cross compiling Python doesn't preserve permissions when doing make install

Hi,

I am trying to cross compile python on windows for a Linux based system, when I do a make DESTDIR install the binaries get installed in custom directory on windows, however the permissions are not preserved. how can I preserve permissions, such that me doing an untar on Linux should have correct permissions and I can run the binary immediately without changing permissions after untar.

Windows does not have permissions that are compatible with unix permissions.

I do not think you can fix this if you use windows to do the build.
Can you build using a linux system in a linux VM instead?

2 Likes

My restrictions are to build with windows itself. Then according to above I need to manually set execute permissions for the binaries and access permissions for dlls. Right?

That sounds you are forced to use windows by company policy, not very wise.

So yes you will need a script to set file ownership and permissions.
FYI I assume you mean .so when you said dlls.

2 Likes

yep, I meant .so, thanks Barry.

A Linux shared-object file is a dynamic link library, so it’s not wrong to call them DLLs.

1 Like

What you can do is add permissions automatically to the tar file on windows using the python stdlib module tarfile. I have never done this myself, but it should be possible.

Thank you @MegaIng, can you elaborate on what you mean by adding permissions to tar file automatically. From where will you get the reference permissions (one’s like that in Linux)? I assume we need this beforehand right, or are they encoded in tarfile module? If no, then we would be doing the same thing a bash script to change permissions does except we are doing in python.

You can presumably predict these based on file names, otherwise you couldn’t write the bash script either.

The benefit of my suggestion is that you can do it as part of the build step on windows, producing a final tar that just needs to be untared instead of also having to run a script to fix permissions afterwards. If this is not a benefit for you, then this suggestion wont help.

2 Likes

Thank you for the suggestion @MegaIng, I was just clearing my doubts. The proposed approach will be usefull for me.