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

Chris Warrick kwpolska at gmail.com
Fri Jul 10 10:49:49 EDT 2015


CC’ing the mailing list; please use Reply All in the future.

On 10 July 2015 at 16:36,  <c.buhtz at posteo.jp> wrote:
> Hi Chris,
>
> thank you for your answer.
>
> On 2015-07-10 09:39 Chris Warrick <kwpolska at gmail.com> wrote:
>> You should NEVER use sudo with pip.  Instead, use virtualenvs as a
>> regular user, or create your own .deb packages.
>
> I am not sure, but maybe this is an Ubuntu-specific "problem"?
> When I don't use sudo I got errors like this
> "PermissionError: [Errno 13] Permission denied:
> '/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.0.6.dist-info"
>
> And it make sense for me.

This is correct.  Don’t install things system-wide with pip.

> Don't tell me about deb-Packages! :D I am stuck with that currently. I
> would be glad to have a correct working whl-file for my local needs.
> After that - maybe! - I will start again with thinking about a deb.
>
> How can virtualenv help here? I need to install
> python-software/packages to the system and not to a different
> environment or sandbox.
> I never used virtualenv but as I understand it it is for testing
> purpose not for productive system.

virtualenv should be used for both testing AND production
environments. Your projects can have different versions of
dependencies, and this is what virtualenv helps with: they are
separate from each other. You can also modify the system packages
without messing with your system packages.

You can also use pip install --user to install to ~/.local

>> And you should not create the files in your install script.  Instead,
>> install them to a different data dir (somewhere in 'share/appname'
>
> What do you mean with "data dir"? For a default config-file it could
> be /etc/appname/default.conf. But I have no rights for that.

https://pythonhosted.org/setuptools/setuptools.html#including-data-files

Makes your package installable through wheel files and friendly for
all environments.

>> should copy this file to user’s config directory (use pkg_resources to
>> help you get it) if it does not exist yet.
>
> I will look at this package.

https://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime

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



More information about the Python-list mailing list