0

I am currently interning at a place where they've asked me to make a standalone python program to do something (say X).
Now, that program is to be run by some commands sent by their proprietary software which is written in their proprietary language. Now the reason I'm saying proprietary so many times is because they aren't ready to take me anywhere near their code. I am just supposed to make a Python code that does X based on the input given by their software.

So is there a way I can make an API and wrap it around my code so as to let the software control it? Also I need to make the whole thing standalone (maybe an installer of some kind) so that they don't have to install Python and the accompanying modules (like opencv) just to run my script?

All I could get out of them was "there are dll files that will be calling your app and we want an executable"

6
  • 2
    Why do you need an API? Are command-line arguments not sufficient? Commented Jul 5, 2016 at 9:01
  • en.wikipedia.org/wiki/Inter-process_communication Commented Jul 5, 2016 at 9:03
  • The answer to both of your questions (possible to define an interface, possible to make an executable/installer) is yes, you should go and do more research on both of them. Commented Jul 5, 2016 at 9:08
  • Command line arguments aren't good enough for them, they want an executable file. To clarify, I know that it can be done, but I don't know how to do it when I'm blind about the thing that's using my program. Commented Jul 5, 2016 at 9:19
  • command line arguments can be given to an executable file. Commented Jul 5, 2016 at 9:21

1 Answer 1

0

Any programm can execute any other program (if it has the appropriate rights) so there is no real distinction between "python file" and "python executable" (that is because python is an interpreted language. The python source files and the "final python program" are "identical" (asuming cpython), in contrast to e.g. a C program where the source files and the executable are vastly different).

If you are on windows there is the additional problem that the user must have installed python to execute .py files. There are some ways to mitigate that problem - there are python libraries that "freeze" the python interpreter and your code into a single .exe file (from the comment by Bakuriu see e.g. freeze) . You could bundle the python interpreter with your code. You can just say your users to install python (if the amount of users is low that might be the good way).

"API" is just a fancy way of saying "this is how you communicate with my programm". This might be how you call a library (e.g. what functions a python module exports) or this might be an HTTP API or which command line arguments are passed or which protocoll over an TCP socket is spoken. Without knowing which API you are supposed to implement you cannot fulfill your job.

Without knowing further specifications (what inputdoes the other program give to yours, how does it call your programm?) it's very hard to say anything more helpful.

Sign up to request clarification or add additional context in comments.

5 Comments

Okay, this clears a lot of things. The system they're using is running Windows and a proprietary software. The software is supposed to send some arguments (like name, number etc) to my program and my program is supposed to return either text or image to the software. I'm using opencv library too and that would also have to be bundled along with my Python code. Does pyinstaller (or other such distutils) do that?
How are the arguments sent? Are you supposed to program a library or an executable? How should the text/image be returned (encoding, or maybe a path to a image file?)?
Bundling C libraries with a python application is alwayse a bit of a hassle, this question mentions cxfreeze. I couldn't quickly find information on pyinstaller and opencv but I guess if you dig a bit deeper you should find some information.
I have no control over how the argument are sent to my code, I can just decide what arguments my code receives and tell them about it. The images will be stored locally and path will be returned.
So you decide wether they are passed as commandline arguments or otherwise? In that case you can just decide what is easiest for you, so essentially you can "make up" an API, document it and give the documentation to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.