How to run a Python program on a Windows server without installing Python?

So, I wrote a Python script that does some simple things. It originally started on a Unix server, but because of the crappy network security settings that TPTB refuse to change, we need to run it on a Windows server. However, the administrators of the mentioned Windows server refuse to do anything useful, for example, install Python.

What are my options for running a Python script on Windows without Python?

Consideration 1:

Something like Py2Exe - I found this after a quick google search, and that seems promising. From what I can say, it will generate a bunch of files, but we can just copy this directory to our Windows machine and it will be completely isolated and will not have any external dependencies. Does anyone know how well this works? Obviously, this depends on my Python script, but, fortunately, this script is pretty simple and only uses Python built-in libraries like urllib2 and urlparse.

Consideration 2:

We can assume that at least some version of the .NET Framework is installed on the Windows server, which makes IronPython think. I have never used this before, but I always wanted it. From what I can tell, it compiles Python code into CLS-compatible IL code that can be run natively under .NET runtime. However, this requires additional .NET libraries to be installed on the server? Can I just link these DLLs to my program? Or do I need to rewrite my Python script to call certain .NET Framework classes instead of using things like urllib2 or urlparse?

Thanks!

PS - The ironic part: I practically do not know Python, and I am a .NET expert, but I wrote a script in Python because I was told that it will work on a Unix server. If I knew that we would finish this on a Windows server, I would write it in C # to start in about 1/10 time. Failure.

+4
source share
1 answer

Are you allowed to completely copy executable files to the server? If so, you should be able to install Python without an administrator or use Portable Python , which you can simply copy to a folder without any installation at all.

There is nothing wrong with Py2exe, but that means you have to create a script in a new executable every time you update it. In addition, Py2exe has a slightly longer startup time than the Python interpreter, since it must extract the Python DLL files to a temporary folder each time; this, of course, of course, if you run your script often.

+4
source

Source: https://habr.com/ru/post/1379504/


All Articles