Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93627 > unrolled thread

Re: [setuptools] install data-file in users home-dir

Started byChris Warrick <kwpolska@gmail.com>
First post2015-07-10 09:39 +0200
Last post2015-07-10 09:39 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [setuptools] install data-file in users home-dir Chris Warrick <kwpolska@gmail.com> - 2015-07-10 09:39 +0200

#93627 — Re: [setuptools] install data-file in users home-dir

FromChris Warrick <kwpolska@gmail.com>
Date2015-07-10 09:39 +0200
SubjectRe: [setuptools] install data-file in users home-dir
Message-ID<mailman.388.1436513985.3674.python-list@python.org>
On 10 July 2015 at 03:11,  <c.buhtz@posteo.jp> wrote:
> I am using setuptools to create a wheel file.
>
> There is a conf-file I want to install into the users config-diretory.
> e.g. /home/user/.config/appname/app.conf
>
> setup(...,
>       data_files = [ ('~/.config/appname/', ['app.conf']) ]
>      )
>
> I see two problems here:
>
> 1.
> I don't know the users "name". So I have to use a placeholder here.
> Does '~' work here in that case?

It doesn’t.  You would have to use os.path.expanduser, but don’t do that.

> 2.
> To install the wheel-file with pip I need sudo-privilegs on Ubuntu
> 14.04.2. That means while the install script runs I can not ask for the
> users name because it is "root" in that case.
> --
> https://mail.python.org/mailman/listinfo/python-list

You should NEVER use sudo with pip.  Instead, use virtualenvs as a
regular user, or create your own .deb packages.

And you should not create the files in your install script.  Instead,
install them to a different data dir (somewhere in 'share/appname', or
alongside your package). When someone runs your app, only then you
should copy this file to user’s config directory (use pkg_resources to
help you get it) if it does not exist yet.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web