I've been reading a lot these days, and I'm not sure about the specific use of it. I need ask it, because cannot find someone who explain it to me. Now I'm lost..
The main problem is I need install my app (python + glade) in "/usr/share/name_app" and a ".desktop" file in "/usr/share/applications" in Ubuntu.
The solution that I've find is creating a ".deb" file because the installation is perfect. In ubuntu I can launch it with Unity clicking on the launcher, the ".desktop".
(Probably I'll upload it to "Ubuntu Software Center").
For windows I could use "py2exe" or a similar, and another one for Mac.
But, like the code is in GitHub, it should have a "setup" or a "makefile" to install it.
After reading and reading (and reading), I think that "setup.py" is only for install a module and then import it with python.
However if I have to install and app, how can I distribute it making a "setup.py" or a "makefile"? Which is better for install an app? Which is the diference? What I have to use?
Thanks:)
setup.py is used to deploy Python applications and modules with virtualenv http://www.virtualenv.org/en/latest/index.html setup.py is mostly useful for the application developers - you can run
python setup.py develop
within virtualenv to set-up your development workspace with Python dependencies.
For each platform distribution (Windows, OSX, Linux) use the distribution tools as you are currently using.
You can also use setuptools tools to roll out packages from setup.py for the platform architecture. Eg. creating .deb from setup.py
http://pypi.python.org/pypi/stdeb/
More info about setup.py
http://packages.python.org/distribute/setuptools.html
To grasp general concepts you could read stdlib docs: An Introduction to Distutils.
The first several links for keywords: "python packaging" are to: Python Packaging User Guide that should show what setup.py is and how to use it.
Related
Can someone point me at a good introduction to creating a Windows MSI installer for a Python package? The function that I need is:
Raise the Windows auth level
Install as normal using pip...
Now run additional script to move some files where a standard user cannot put them
Reverse this on uninstall.
It looks like a bdist_msi is the simplest way to achieve this but the internet seems somewhat lacking on a good example showing what Windows tooling I need to add to enable python setup.py bdist_msi to do its stuff.
Thanks!
Using from setuptools.command.install import install, I can easily run a custom post-install script if I run python setup.py install. This is fairly trivial to do.
Currently, the script does nothing but print some text but I want it to deal with system changes that need to happen when a new package is installed -- for example, back up the database that the package is using.
I want to generate the a Python wheel for my package and then copy that and install it on a a set of deployment machines. However, my custom install script is no longer run on the deployment machine.
What am I doing wrong? Is that even possible?
Do not mix package installation and system deployment
Installation of Python packages (using any sort of packaging tools or formats) shall be focused on making that package usable from Python code.
Deployment, what might include database modifications etc. is definitely out of scope and shall be handled by other tools like fab, salt-stack etc.
The fact, that something seems fairly trivial does not mean, one shall do it.
The risk is, you will make your package installation difficult to reuse, as it will be spoiled by others things, which are not related to pure package installation.
The option to hook into installation process and modify environment is by some people even considered flaw in design, causing big mess in Python packaging situation - see Armin Roacher in Python Packaging: Hate, Hate, Hate Everywhere, chapter "PTH: The failed Design that enabled it all"
PEP 427 which specifies the wheel package format does not leave any provisions for custom pre or post installation scripts.
Therefore running a custom script is not possible during wheel package installation.
You'll have to add the custom script to a place in your package where you expect the developer to execute first.
I'm in desperate need of a cross platform framework as I have vast numbers of .NET products that I'm trying to port to Linux. I have started to work with Python/pyQt and the standard library and all was going well until I try to import non-standard libraries. I'm hearing about pip and easy_install and I'm completely confused about this.
My products need to ship with everything required to execute them, so in the .NET world I simply package my DLLs (or licensed DLLs) with my product.
As a test bed I'm trying to import this library called requests: https://github.com/kennethreitz/requests
I've got an __init__.py file and the library source in my program directory but it isn't working. Please tell me that there is a simple way to include libraries without needing any kind of extra package installer.
I would suggest you start by familiarizing yourself with python packages (see the distutils docs. Pip is simply a manager that install packages directly from the internet repository, so that you don't need to manually go and download them. So for, example, as stated under "Installing" on the requests homepage, you simply run pip install requests in a terminal, without manually downloading anything.
Packaging your product is a different story, and the way you do it depends on the target system. On windows, the easiest might be to create an installer using NSIS which will install all dependencies. You might also want to use cx-freeze to pull all the dependencies (including the python interpreter) into a single package.
On linux, many of the dependencies will already be including in most distributions. so you should just list them as requirements when creating your package (e.g. deb for ubuntu). Other dependencies might not be included in the distro's repo, but you can still list them as requirements in setup.py.
I can't really comment on Mac, since I've never used python on one, but I think that it would be similar to the linux approach.
I am trying to begin a new python GUI application and I have decided to use wxPython as GUI because I want a multi-platform one.
The problem is that I want to use virtualenv ( with virtualenvwrapper ) to isolate the environment and be able to reproduce it in other machines where I will work, but i cannot install wxPython.
I have it installed in my ubuntu machine via apt-get but that is not enough
I have searched the web for a solution and i have found ...
This page http://batok.github.com/virtualenvwxp/ where it is explained a way to hack the virtualenv environment to use the local installation of wxPython. Not the best solution, but it would be a good workaround. The problem is that it is explained for Mac, and I couldnt make it work in my ubuntu.
Also found this page Installing wxPython in virtualenv under Linux where someone ask something similar. I have tried to build wxPython that way with no success.
Any help would be appreciated.
In the end, I have choose wxPython beacuse it is multiplatform and i can use it without license problems, but as i have not started yet i can change my mind if there is another easier to install framework.
Thanks In advance
20110925: Sorry for the delay and thanks for the answers.
I just have tried to install wxpython using buildout and the links given here, but i still have the same problem. It seems as if I need libgtk2.0-dev package to be able to compile wxpython...
So there is any way to install this package locally to the buildout environment?
Thanks again.
At the end I could not resolve this problem.
I want to create a reproducible python environment with all the requirements inside using buildout and/or virtualenv so I could work in any linux system with just virtualenv, python and a C++ compiler installed.
It seems that the only way to do this is to use buildout cmmi recipes to download and build wxpython and ALL its dependencies. This is a really painful way, and I have no time now.
I have decided to use a workaround: I am going to work on my ubuntu laptop most of the time, so I have installed wxpython from the repositories and use a wx.pth file to make it available to the virtual environment.
This is not a good solution, but seems the best till now ... so if someone knows any better solution please let me know.
When my python project is more mature, I will turn again to this problem and I will probably try the hard way ...
Thanks for all your answers and comments.
The solution I ended up using was to install python to my main system:
Then make a symbolic link from the wx in my system python to my virtual environment:
ln -s /usr/lib/python2.7/dist-packages/wxversion.py <virtual_env_path>/lib/python2.7/site-packages/wxversion.py
Where is the path in my case to a virtual environment named "fibersim" for example is:
/home/adam/anaconda/envs/fibersim
Then import wx worked
Got this from: http://qopml.org/wp-content/uploads/2013/01/README.txt
Buildout allows your to install different parts whose recipe code determines how that part is built. There are cmmi recipes for building stuff with Configure/Make/Make-Install (CMMI). You can use this to build wxPython locally to the buildout and then create a python interpreter that has that build of wxPython and your own eggs in it's path.
See this blog post and this answer for details.
Keep in mind that zc.recipe.egg will also install any setuptools/distribute console_scripts in the buildout's bin directory as well. See also mr.developer for automatically checking out multiple packages from VCS and working on them in the same buildout.
I want to distribute some python code, with a few external dependencies, to machines with only core python installed (and users that unfamiliar with easy_install etc.).
I was wondering if perhaps virtualenv can be used for this purpose? I should be able to write some bash scripts that trigger the virtualenv (with the suitable packages) and then run my code.. but this seems somewhat messy, and I'm wondering if I'm re-inventing the wheel?
Are there any simple solutions to distributing python code with dependencies, that ideally doesn't require sudo on client machines?
Buildout - http://pypi.python.org/pypi/zc.buildout
As sample look at my clean project: http://hg.jackleo.info/hyde-0.5.3-buildout-enviroment/src its only 2 files that do the magic, more over Makefile is optional but then you'll need bootstrap.py (Make file downloads it, but it runs only on Linux). buildout.cfg is the main file where you write dependency's and configuration how project is laid down.
To get bootstrap.py just download from http://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap/bootstrap.py
Then run python bootstap.py and bin/buildout. I do not recommend to install buildout locally although it is possible, just use the one bootstrap downloads.
I must admit that buildout is not the easiest solution but its really powerful. So learning is worth time.
UPDATE 2014-05-30
Since It was recently up-voted and used as an answer (probably), I wan to notify of few changes.
First of - buildout is now downloaded from github https://raw.githubusercontent.com/buildout/buildout/master/bootstrap/bootstrap.py
That hyde project would probably fail due to buildout 2 breaking changes.
Here you can find better samples http://www.buildout.org/en/latest/docs/index.html also I want to suggest to look at "collection of links related to Buildout" part, it might contain info for your project.
Secondly I am personally more in favor of setup.py script that can be installed using python. More about the egg structure can be found here http://peak.telecommunity.com/DevCenter/PythonEggs and if that looks too scary - look up google (query for python egg). It's actually more simple in my opinion than buildout (definitely easier to debug) as well as it is probably more useful since it can be distributed more easily and installed anywhere with a help of virtualenv or globally where with buildout you have to provide all of the building scripts with the source all of the time.
You can use a tool like PyInstaller for this purpose. Your application will appear as a single executable on all platforms, and include dependencies. The user doesn't even need Python installed!
See as an example my logview package, which has dependencies on PyQt4 and ZeroMQ and includes distributions for Linux, Mac OSX and Windows all created using PyInstaller.
You don't want to distribute your virtualenv, if that's what you're asking. But you can use pip to create a requirements file - typically called requirements.txt - and tell your users to create a virtualenv then run pip install -r requirements.txt, which will install all the dependencies for them.
See the pip docs for a description of the requirements file format, and the Pinax project for an example of a project that does this very well.