Install python modules without generating binary/compiled files?

Hello All,

Is it possible to install python packages (like numpy, quaternion, etc.) without generating compiled/binary files?

I have a python program I have written that depends on various modules and I would like to move this program to a different machine. However, this new machine does not have internet access and I am not allowed to transfer compiled/binary or executable files onto the machine. The machine has python installed. My plan was to copy over all the necessary modules by copying all the files in the “site-packages” directory of my virtual python environment into the virtual python environment of the new machine. However, many of these files are compiled/binary types that I cannot bring to the new machine. For example, the quaternion module depends on the “numpy_quaternion.cp311-win_amd64.pyd” file and I can’t transfer .pyd files.

Is it possible to install python modules with pip, or some other way, so that the resulting files are all text or python files so I can transfer them to the new machine? Does anyone have any advice for how I might get my python program running on the new machine?

Thanks.

Libraries that you access from Python are not necessarily written in Python. It’s possible to write a library in another language (often C) and then have a small wrapper that allows that library to be used from Python. Or the library could have some parts written in C and some in Python. There isn’t any form of these libraries that is “all text or Python files” (unless you just get the source code and compile it yourself, but from what you say it seems unlikely you’d be able to do that either).

Numpy is one prominent library that works that way. There’s no way you can get a working version of numpy without some kind of compiling taking place, so you won’t be able to do what you describe.[1]


  1. I seem to recall a pure-Python library that was aimed at being an alternative to numpy, but I don’t think it fully replicated numpy’s functionality. ↩︎

That is disappointing to hear. Thanks for the explanation.

What constitutes “text”? Are you able to base-64 (MIME) encode the binary files and transfer them that way? I’m guessing probably not, but if that is an option (eg if the limitation is because you have to copy and paste files using a text clipboard), it wouldn’t be too hard to implement.

Or conversely, what constitutes “executable” and is thus not permitted?

This is a great question. Let me get a more technical description of the exact limitations and get back to you. The files don’t have to literal text files, but I’m pretty sure they can’t be binary files.