Pergunta

I'm attempting to create a python package that when installed also creates an upstart service. Currently, my options are symlinking the service from the package directory to /etc/init, or copying the file to /etc/init. Either one works fine so long as I can unlink/delete the file upon uninstallation of the package. I saw another related question where a commenter expressed that this should not be the job of setuputils in the first place. So my question is as follows:

Should setuputils even be responsible for creating the service on the machine, or rather should this be handled by an external package manager like dpkg/apt/rpm; if it is prudent, is there a way to somehow run a script upon uninstallation of a package or have setuputils remove the file from /etc/init without modifying SOURCES.txt in the egg after running sdist?

Thanks!

Foi útil?

Solução

Should setuputils even be responsible for creating the service on the machine, or rather should this be handled by an external package manager like dpkg/apt/rpm

Almost certainly the latter.

distutils/setuptools is not designed to handle things like this.

There's some configuration information that's sufficient for installing site-packages, shared data, executables, and maybe a few other things in ways that make sense on your platforms. But there's nowhere near enough to handle things like installing init scripts.

These tools are designed to handle not just slightly different early-2010s-era Ubuntu-like linux distros, but a wide variety of different platforms. On non-Ubuntu-like distros (and pre-lucid Ubuntu) there is no Upstart, but there is SysV-style init. On some other *nixes, there isn't even SysV-style init, but there is BSD-style init. On OS X, while SysV-style init does exist, it's heavily deprecated and launchd is used instead. On Windows, there isn't anything even remotely similar, but there are completely different ways to set up "services" and "run-at-startup" programs and related concepts.

On top of that, on many platforms, the package manager wants to be able to own all startup scripts, and you don't want to violate that expectation on a user/sysadmin's behalf without him specifically asking for it.

So, you need a platform-specific package for each platform. If you just create a PyPI package and a .deb for Ubuntu Precise or whatever you use, if some Fedora or Mac or Ubuntu Natty user gets jealous, they'll either do it themselves, or ask you.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top