Gentoo Archives: gentoo-user

From: Marc Joliet <marcec@×××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Python: ebuilds vs. pip3 install --user
Date: Wed, 11 Mar 2020 20:13:20
Message-Id: 3194465.LZWGnKmheA@thetick
In Reply to: [gentoo-user] Python: ebuilds vs. pip3 install --user by Grant Edwards
1 Am Mittwoch, 11. März 2020, 18:54:43 CET schrieb Grant Edwards:
2 > Background: a utility written in Python that I use regularly
3 > (weasyprint) was out-of-date and is being dropped from Gentoo's
4 > package database. I tried (and faield) to creaate an ebuild for a
5 > more recent version. So I ended up doing
6 >
7 > $ pip3 install --user weasyprint
8 >
9 > That installed weasyprint and a few depdendancies (tinycss2,
10 > defusedxml, ciarocffi) under ~/.local/{bin,lib64}.
11 >
12 > Question:
13 >
14 > Can those dependancies installed under ~/.local cause problems for
15 > things that were installed using standard ebuilds which require
16 > older/other versions of those libraries (which were installed using
17 > standard ebuilds)?
18 >
19 > For example, weasyprint requires cairosvg 2.4, and 2.4.2 was installed
20 > under .local via the pip3 command shown above.
21 >
22 > My stable cairosvg is 2.0.3 and it is installed in the usual "system"
23 > location /usr/lib64/python3.6/site-packages by the normal "emerge"
24 > process. [IIRC, at one point I tried unmasking 2.4.2, but that caused
25 > a cascade of other problems.]
26 >
27 > Q: Under what conditions will having a second installation of a Python
28 > library under .local cause problems?
29
30 IIUC you shouldn't have any problems, simply because ~/.local/ is not part of
31 the system python's module search path:
32
33 % python3
34 Python 3.6.10 (default, Feb 26 2020, 01:09:02)
35 [GCC 9.2.0] on linux
36 Type "help", "copyright", "credits" or "license" for more information.
37 >>> import sys
38 >>> sys.path
39 ['', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/
40 lib-dynload', '/usr/lib64/python3.6/site-packages']
41
42 So whatever uses the system Python will not see your local packages unless it
43 manipulates sys.path appropriately (which I don't think any sane software ever
44 does).
45
46 A virtualenv, as suggested by Mark, would have its own module search paths. I
47 don't know if those ever *can* include the system paths (because they normally
48 use their own Python binary with its own standard library and site-packages),
49 but none of the environments I have do, e.g.:
50
51 % conda activate base
52 % python
53 (base)
54 Python 3.7.4 (default, Aug 13 2019, 20:35:49)
55 [GCC 7.3.0] :: Anaconda, Inc. on linux
56 Type "help", "copyright", "credits" or "license" for more information.
57 >>> import sys
58 >>> sys.path
59 ['', '/home/marcec/.miniconda3/lib/python37.zip', '/home/marcec/.miniconda3/
60 lib/python3.7', '/home/marcec/.miniconda3/lib/python3.7/lib-dynload', '/home/
61 marcec/.miniconda3/lib/python3.7/site-packages']
62 >>>
63
64 (Granted it's conda and not plain virtualenv, but I think the principles are
65 the same.)
66
67 HTH
68 --
69 Marc Joliet
70 --
71 "People who think they know everything really annoy those of us who know we
72 don't" - Bjarne Stroustrup

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
[gentoo-user] Re: Python: ebuilds vs. pip3 install --user Grant Edwards <grant.b.edwards@×××××.com>