setuptools and additional scripts handling
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. I'm starting to use setuptools for my projects and I have a few questions. In my web applications, usually I have some scripts that needs to be installed as cron scripts. I would like to install them using setuptools, since it is important that the correct python interpreter is used (I use virtualenv), and setuptools does this automatically.. Is it possible to declare a custom directory where some of the scripts needs to be installed? Thanks Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkt6nGQACgkQscQJ24LbaUT8QACgg2tkF6vJWWTiBoFnWtr6tb1X C7sAnjzu/l/ytRMD44STkTiiVJ/uIxmy =hSnP -----END PGP SIGNATURE-----
At 02:23 PM 2/16/2010 +0100, Manlio Perillo wrote:
Is it possible to declare a custom directory where some of the scripts needs to be installed?
No. However, you can always create a script whose job is to symlink your other scripts to the appropriate cron directory, and ask your users to run it after installation.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 P.J. Eby ha scritto:
At 02:23 PM 2/16/2010 +0100, Manlio Perillo wrote:
Is it possible to declare a custom directory where some of the scripts needs to be installed?
No. However, you can always create a script whose job is to symlink your other scripts to the appropriate cron directory, and ask your users to run it after installation.
Can't this be done inside setup.py? Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkt6u8wACgkQscQJ24LbaUSVjwCfT3zpQmSG+RoTPqrdOMhnRl31 Y2oAnAlJW48TJ+pPRCAz3s4WdeMtKOx+ =/UQx -----END PGP SIGNATURE-----
At 04:37 PM 2/16/2010 +0100, Manlio Perillo wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
P.J. Eby ha scritto:
At 02:23 PM 2/16/2010 +0100, Manlio Perillo wrote:
Is it possible to declare a custom directory where some of the scripts needs to be installed?
No. However, you can always create a script whose job is to symlink your other scripts to the appropriate cron directory, and ask your users to run it after installation.
Can't this be done inside setup.py?
You could make a setup command, or customize the "install" command, but neither of these things would affect easy_install or pip. If you allow the scripts to be installed to standard locations, then they will contain the correct interpreter, and will only need to be symlinked to the cron.hourly or cron.daily or whatever else it is you're wanting to do. (Heck, if what you've got is a singleton application of some sort, you could potentially just have it check at startup that the cron scripts are symlinked, and let the user know about the problem.)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 P.J. Eby ha scritto:
At 04:37 PM 2/16/2010 +0100, Manlio Perillo wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
P.J. Eby ha scritto:
At 02:23 PM 2/16/2010 +0100, Manlio Perillo wrote:
Is it possible to declare a custom directory where some of the scripts needs to be installed?
No. However, you can always create a script whose job is to symlink your other scripts to the appropriate cron directory, and ask your users to run it after installation.
Can't this be done inside setup.py?
You could make a setup command, or customize the "install" command, but neither of these things would affect easy_install or pip.
[...]
(Heck, if what you've got is a singleton application of some sort, you could potentially just have it check at startup that the cron scripts are symlinked, and let the user know about the problem.)
You are right, this is a singleton web application! So, it will not be installed using pip or easy_install. I have to decide if it is best to "abuse" setuptools plugin support, in order to install system services (cron scripts, init.d script) or if it is better to provide a separate script, as you suggested. And, no, it is not that easy to do checks at startup, since it is a WSGI application embedded in Nginx (and when I'm on my PC or testing server, the cron scripts are not required). Thanks Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEUEARECAAYFAkt6/AEACgkQscQJ24LbaUSkxQCYtpARxMvMABorLqgfqYQxpdls XgCfStNbPH+WeWmwr40IQLqzFUkZ/m4= =57or -----END PGP SIGNATURE-----
At 09:11 PM 2/16/2010 +0100, Manlio Perillo wrote:
You are right, this is a singleton web application! So, it will not be installed using pip or easy_install.
I have to decide if it is best to "abuse" setuptools plugin support, in order to install system services (cron scripts, init.d script) or if it is better to provide a separate script, as you suggested.
You can also extend the "install" command, and this could be made to work with plain distutils, as well as setuptools. (Subclassing distutils commands is a standard practice, described in the documentation for distutils.) It just means that programs that don't use "install" to do the installation won't work correctly, if at all. However, if you just want "setup.py install" to do things differently, subclassing the install command is the way to go.
On 02/16/2010 09:11 PM, Manlio Perillo wrote:
You are right, this is a singleton web application! So, it will not be installed using pip or easy_install.
Ah, then you also won't be using buildout, I'd guess :-) If you had, you could have used http://pypi.python.org/pypi/z3c.recipe.usercrontab But also that recipe just points cron at one or more python scripts somewhere. Reinout -- Reinout van Rees - reinout@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets"
Manlio Perillo wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi.
I'm starting to use setuptools for my projects and I have a few questions.
In my web applications, usually I have some scripts that needs to be installed as cron scripts.
I would like to install them using setuptools, since it is important that the correct python interpreter is used (I use virtualenv), and setuptools does this automatically..
Is it possible to declare a custom directory where some of the scripts needs to be installed?
A different line of thought. For people adopting buildout http://pypi.python.org/pypi/z3c.recipe.usercrontab could come in handy at times for such use cases. Raphael
Thanks Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkt6nGQACgkQscQJ24LbaUT8QACgg2tkF6vJWWTiBoFnWtr6tb1X C7sAnjzu/l/ytRMD44STkTiiVJ/uIxmy =hSnP -----END PGP SIGNATURE----- _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Raphael Ritz ha scritto:
Manlio Perillo wrote: Hi.
I'm starting to use setuptools for my projects and I have a few questions.
In my web applications, usually I have some scripts that needs to be installed as cron scripts.
I would like to install them using setuptools, since it is important that the correct python interpreter is used (I use virtualenv), and setuptools does this automatically..
Is it possible to declare a custom directory where some of the scripts needs to be installed?
A different line of thought.
For people adopting buildout
could come in handy at times for such use cases.
Thanks, there is also a Unix deployment recipe. However, for my web application there is more work to do. I use Nginx + wsgi module, so I also need to configure Nginx. The Nginx configuration file is actually a Mako template, since some parameters (server name, location paths) depends on the deployment type (development PC, testing server, production server). These parameters are defined in a configuration file, and during setup the configuration file needs to be generated. Should this be done subclassing the config command?
Raphael
Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkt783UACgkQscQJ24LbaUQj5ACfYxFnEs3GUUi8ILccx1nDKLx9 3bgAn0yXdNn8kI92IhPxxI4AE6NHeINR =aZvH -----END PGP SIGNATURE-----
Manlio Perillo wrote: [..]
However, for my web application there is more work to do.
I use Nginx + wsgi module, so I also need to configure Nginx. The Nginx configuration file is actually a Mako template, since some parameters (server name, location paths) depends on the deployment type (development PC, testing server, production server).
Again, if that's your use case I encourage you to look into using buildout. At least I use it myself in situations that seem similar to yours and I'm happy with it (thanks Jim!). One of the many nice things about buildout configuration files is that you can quite flexibly mix-and-match, meaning you can have a 'base.cfg' which is then extended by other more specific cfg files, etc. And it is very easy to selective overwrite individual settings from those more specialized ones. In case you want to explore that option, here a few more pointers: buildout: http://pypi.python.org/pypi/zc.buildout nginx: http://pypi.python.org/pypi/gocept.nginx A non-trivial example explicitly spelled out: http://www.martinaspeli.net/articles/an-uber-buildout-for-a-production-plone... (some but not all parts in there are Zope/Plone specific but still it should help getting the big picture) http://www.martinaspeli.net/articles/new-uber-buildout-with-repoze-and-deliv... which points to cfgs in http://svn.plone.org/svn/collective/buildout/uber/plone3.x-repoze/ would be another example illustrating a multi-platform, development-and-production setup. See in particular http://svn.plone.org/svn/collective/buildout/uber/plone3.x-repoze/README.txt for more. The last example sets up the Zope server clients to run under 'paster' with a WSGI pipeline. Again, I'm not suggesting to use Plone here but I happen to know that stuff ;-) and I think the examples illustrate nicely how one can use buildout to manage somewhat complex systems quite comfortably. (and I know some people are doing way more crazy things with it ...) YMMV, Raphael
These parameters are defined in a configuration file, and during setup the configuration file needs to be generated. Should this be done subclassing the config command?
Raphael
Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkt783UACgkQscQJ24LbaUQj5ACfYxFnEs3GUUi8ILccx1nDKLx9 3bgAn0yXdNn8kI92IhPxxI4AE6NHeINR =aZvH -----END PGP SIGNATURE----- _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
participants (4)
-
Manlio Perillo
-
P.J. Eby
-
Raphael Ritz
-
Reinout van Rees