Return-Path: X-Original-To: Python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'yet.': 0.03; 'subject:file': 0.07; 'cc:addr:python-list': 0.09; '(use': 0.09; 'app,': 0.09; 'packages.': 0.15; 'package).': 0.16; 'placeholder': 0.16; 'setuptools': 0.16; 'subject:home': 0.16; 'subject:install': 0.16; 'sudo': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'config': 0.18; 'script.': 0.18; 'runs': 0.18; 'subject:] ': 0.19; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'file.': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply- To:1': 0.24; 'script': 0.25; 'install': 0.25; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'skip:( 20': 0.28; 'regular': 0.29; 'subject:users': 0.29; 'that.': 0.30; 'url:mailman': 0.30; 'e.g.': 0.30; 'skip:[ 10': 0.31; 'url:python': 0.33; 'instead,': 0.33; 'ubuntu': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'dir': 0.35; 'exist': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'two': 0.37; 'someone': 0.38; 'files': 0.38; 'means': 0.39; 'data': 0.39; 'does': 0.39; 'subject:-': 0.39; 'url:mail': 0.40; 'your': 0.60; 'here.': 0.62; 'different': 0.63; 'here:': 0.63; 'here': 0.66; 'user,': 0.67; 'case?': 0.84; 'pip': 0.84; 'skip:/ 30': 0.84; 'wheel': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=5cKcwB+jU8Hlj6y6X2upfCN1iJ65bxJAEOiKAUwX7oA=; b=I/aGhZj0SmoR3107kXwwQ5B+1H/jo0kgL+NHqHJfUCQTP2FrSrgVGtnA6yGIIwURwT Jzg+6Ca1VElNUpdBLG/GxdKABbsumcITNCaYIR/Pm2IzdlS1OUF3qRn5rljknHu77lbH zOcoP2izEK5zLlnDpM2uY+2CxMdxhiLQjEC7s9Lc5WyDQh8x3ebpLzDo6M7d/4eODn+5 jKJOx32N4O5c8TT6T8+HXNabhvNKmtl386ldyXQoU8d8K5dre6de8NfpXcCTETYdbV8h yexitF7kmVsEVogVdLZI0KnRkSMgHIaEdvHNQ1ObihLB2bBubyzF9mQyi6rqhfIsRuqw b2Rg== MIME-Version: 1.0 X-Received: by 10.152.206.75 with SMTP id lm11mr18211659lac.41.1436513975873; Fri, 10 Jul 2015 00:39:35 -0700 (PDT) In-Reply-To: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> References: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> Date: Fri, 10 Jul 2015 09:39:35 +0200 Subject: Re: [setuptools] install data-file in users home-dir From: Chris Warrick To: c.buhtz@posteo.jp Cc: Python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436513985 news.xs4all.nl 2893 [2001:888:2000:d::a6]:58779 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:93627 On 10 July 2015 at 03:11, 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 =3D [ ('~/.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=E2=80=99t. You would have to use os.path.expanduser, but don=E2= =80=99t 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=E2=80=99s config directory (use pkg_resources= to help you get it) if it does not exist yet. --=20 Chris Warrick PGP: 5EAAEA16