I'm having some trouble with distributing my python programs. for linux it's easy enough, just tell people which packages they need and provide the source. for windows however it's a different story altogether. I can get my program compiled with py2exe. the problem there however is that it always seems to miss one dll file or the other.
my question therefore is, is there some easy way to package a python script for multiple platforms? right now I keep having to go on a wild goosechase after dll files I don't have. and this isn't even mentioning the 32bit vs. 64bit problem which leaves a lot to desire.
any and all pointers are welcome. the ideal solution would be some sort of script that would create two zipfiles. one being linux/source and one for windows64bit/windows32bit. I really don't care all that much about mac support, but it would be welcome.
If you support linux, you probably support mac in the same way.
I typically use py2exe to distribute to windows, but there are alternatives, such as cxfreeze, and others. I haven't bothered to care much about 64/32 bit and just deliver a 32 bit solution.
Here are a list of packagers:
http://www.freehackers.org/Packaging_a_python_program
Related
I read somewhere you could run python without an OS. How would I do this? Would I need to compile it? Can I run it raw? And if I did need to compile it, what tool would I use and what format would I compile it to?
As far as I know there's not really any way to do this easily but I could be wrong. There are "portable" versions of python but these are operating system dependent. I think what you're referencing is some guys at PyCon managed to run python from the GRUB Bootloader. Your best bet would be installing some minimalist Linux distribution, with essentially only Python and some core packages required to run. The problem is that there's a lot of types of hardware out there, all with their own drivers and assembly language. Python can work as a low level language when you need it to but it seems like configuration would be a nightmare. I haven't looked into it super thoroughly but it seems difficult and impractical. Having an OS above python gives you access to the package managers IDEs and compilier options that make python worth using.
yea that's one of the options, pretty much all the "light" distros will be similar, if you want more to try out try here. Not sure why you're worried about speed though, if you're having speed issues it's far more likely to be the IDE you're using or your code bogging down the computer, not any sort of compiler issues.
I have a program I've written in Python 2.7 on Windows, and I've been using py2exe with total success to make it into an exe (and associated files). However, a reasonable number of people who I want to use it are on Linux/OSX, and while some have been able to make the Windows version work with Wine, others have not been so successful. I've looked thoroughly into py2installer, py2app, freeze and others, but if I understand correctly (I am new to Python and very new to compiling) you need to run them on the system you want to compile them for, i.e. you can only compile for Linux on Linux and OSX on OSX. I don't want to distribute just the raw files because I want the source code to be obfuscated as it is inside a .exe, amd obviously not everyone has Python.
So, my question is: is there any way to compile for OSX or Linux, in Python, while on a Windows machine? And if not, what do you think the best alternative solution might be?
Code obfuscation is really not 'pythonic'. Even when packed into an .exe file, it's basically just the python interpreter and you source code (well, the .pyc files) zipped into one file. It is not as much as cross-compiling as it is about using a python package which does the thing you want (e.g, pack you code in a specific way) on linux.
Freeze will do this for you.
Most linux dists come with python built-in.
Get your linux box running! It's fun, useful, and you can always say 'On My Machine It Works!'. You can compile your code there / test your exe on Wine.
If for some reason you still can't get it to run, post a question!
Get Virtualbox, install Ubuntu in it, and build it "natively" in for Linux. These things work really well, and cross compilation is just asking for trouble. You're going to eventually need Linux to answer the support questions you'll get from these customers anyway! :(
I've looked at some projects like py2exe and a couple other ones. But I want really small under 1mb would be cool but under 300kb would be ideal. Are there any project to possibly extern python into a C compiler or even convert python to C?
Maybe there is just a really small python interpreter that I could add only the required libraries to? ( I tried one, it didn't really seem to be "python")
I've looked at a lot of options but I haven't tried them out properly... What can you recommend?
I am willing to put the effort into a more complex process if the payoff(small size) is worth it, but I need to narrow down the list.
The Shedskin solution in Is it feasible to compile Python to machine code? is what you look for however it is not compile an arbitrary python code. And it is not compile to C but to C++.
I mean the closest you will get with python is py2exe and UPX Create the exe but don't bundle anything to it instead make a library then use upx and do the best compression. It has little overhead and can trim another few mb off your final product. Its not the best way but its one of them.
The other option would be to write a snub launcher in C or C++ to fire up a python interpreter and run your source code. While this would be much smaller it would probably be far more complicated to make, if you are looking to follow this method then this link will help you with that.
I have no experience in making a program into an software. I want to mimic a software out there because the software is simple and yet not free. I want to use python as the language chosen. So what is the process/steps to make an software using python? The software should be okay in Windows.
I only have experience in making a standalone program. I think we need to make the program install to the computer. But I have no idea how to do it.
Not sure I got what you are asking for either, but among the most typical ways to create installations or executables there are:
Distutils (part of the standard library)
PyInstaller (cross-platform)
Py2Exe (windows only)
HTH!
I'm not quite certain I understand what you're asking, but I'm guessing you want a way to create an installable and uninstallable windows program from a python program. If so, a combination of py2exe and NSIS is one way to go.
Edit: You're probably better off using one of mac's suggestions. The above way is likely unnecessarily complicated.
I have started on a personal python application that runs on the desktop. I am using wxPython as a GUI toolkit. Should there be a demand for this type of application, I would possibly like to commercialize it.
I have no knowledge of deploying "real-life" Python applications, though I have used py2exe in the past with varied success. How would I obfuscate the code? Can I somehow deploy only the bytecode?
An ideal solution would not jeopardize my intellectual property (source code), would not require a direct installation of Python (though I'm sure it will need to have some embedded interpreter), and would be cross-platform (Windows, Mac, and Linux). Does anyone know of any tools or resources in this area?
Thanks.
You can distribute the compiled Python bytecode (.pyc files) instead of the source. You can't prevent decompilation in Python (or any other language, really). You could use an obfuscator like pyobfuscate to make it more annoying for competitors to decipher your decompiled source.
As Alex Martelli says in this thread, if you want to keep your code a secret, you shouldn't run it on other people's machines.
IIRC, the last time I used cx_Freeze it created a DLL for Windows that removed the necessity for a native Python installation. This is at least worth checking out.
Wow, there are a lot of questions in there:
It is possible to run the bytecode (.pyc) file directly from the Python interpreter, but I haven't seen any bytecode obfuscation tools available.
I'm not aware of any "all in one" deployment solution, but:
For Windows you could use NSIS(http://nsis.sourceforge.net/Main_Page). The problem here is that while OSX/*nix comes with python, Windows doesn't. If you're not willing to build a binary with py2exe, I'm not sure what the licensing issues would be surrounding distribution of the Python runtime environment (not to mention the technical ones).
You could package up the OS X distribution using the "bundle" format, and *NIX has it's own conventions for installing software-- typically a "make install" script.
Hope that was helpful.
Maybe IronPython can provide something for you? I bet those .exe/.dll-files can be pretty locked down. Not sure how such features work on mono, thus no idea how this works on Linux/OS X...
I have been using py2exe with good success on Windows. The code needs to be modified a bit so that the code analysis picks up all modules needed, but apart from that, it works.
As for Linux, there are several important distribution formats:
DEB (Debian, Ubuntu and other derivatives)
RPM (RedHat, Fedora, openSuSE)
DEBs aren't particularly difficult to make, especially when you're already using distutils/setuptools. Some hints are given in the policy document, examples for packaging Python applications can be found in the repository.
I don't have any experience with RPM, but I'm sure there are enough examples to be found.
Try to use scraZ obfuscator (http://scraZ.me).
This is obfuscator for bytecode, not for source code.
Free version have good, but not perfect obfuscation methods.
PRO version have very very strong protection for bytecode.
(after bytecode obfuscation a decompilation is impossible)