aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/aux-files/python/sitecustomize.py
blob: e2348e0356f86ad8edbcfd3d7c04e1631e28b50e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
# GNU Guix --- Functional package management for GNU
# Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
#
# This file is part of GNU Guix.
#
# GNU Guix is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GNU Guix is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

import os
import site
import sys

# Commentary:
#
# Site-specific customization for Guix.
#
# The program below honors the GUIX_PYTHONPATH environment variable to
# discover Python packages.  File names appearing in this variable that match
# a predefined versioned installation prefix are added to the sys.path.  To be
# considered, a Python package must be installed under the
# 'lib/pythonX.Y/site-packages' directory, where X and Y are the major and
# minor version numbers of the Python interpreter.
#
# Code:

major_minor = '{}.{}'.format(*sys.version_info)
site_packages_prefix = os.path.join(
    'lib', 'python' + major_minor, 'site-packages')
python_site = os.path.join(sys.prefix, site_packages_prefix)

try:
    all_sites_raw = os.environ['GUIX_PYTHONPATH'].split(os.path.pathsep)
except KeyError:
    all_sites_raw = []
# Normalize paths, otherwise a trailing slash would cause it to not match.
all_sites_norm = [os.path.normpath(p) for p in all_sites_raw]
matching_sites = [p for p in all_sites_norm
                  if p.endswith(site_packages_prefix)]

if matching_sites:
    # Deduplicate the entries, append them to sys.path, and handle any
    # .pth files they contain.
    for s in matching_sites:
        site.addsitedir(s)

    # Move the entries that were appended to sys.path in front of
    # Python's own site-packages directory.  This enables Guix
    # packages to override Python's bundled packages, such as 'pip'.
    python_site_index = sys.path.index(python_site)
    new_site_start_index = sys.path.index(matching_sites[0])
    if python_site_index < new_site_start_index:
        sys.path = (sys.path[:python_site_index]
                    + sys.path[new_site_start_index:]
                    + sys.path[python_site_index:new_site_start_index])
ckages/qt.scm, gnu/packages/radio.scm, gnu/packages/rails.scm, gnu/packages/rdf.scm, gnu/packages/rednotebook.scm, gnu/packages/rpc.scm, gnu/packages/rsync.scm, gnu/packages/ruby.scm, gnu/packages/rust.scm, gnu/packages/scheme.scm, gnu/packages/screen.scm, gnu/packages/security-token.scm, gnu/packages/selinux.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/shellutils.scm, gnu/packages/simh.scm, gnu/packages/sml.scm, gnu/packages/ssh.scm, gnu/packages/statistics.scm, gnu/packages/stenography.scm, gnu/packages/sync.scm, gnu/packages/syncthing.scm, gnu/packages/synergy.scm, gnu/packages/telephony.scm, gnu/packages/terminals.scm, gnu/packages/tex.scm, gnu/packages/texinfo.scm, gnu/packages/text-editors.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tmux.scm, gnu/packages/tor.scm, gnu/packages/toys.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/virtualization.scm, gnu/packages/vlang.scm, gnu/packages/vnc.scm, gnu/packages/vpn.scm, gnu/packages/web-browsers.scm, gnu/packages/web.scm, gnu/packages/wireservice.scm, gnu/packages/wm.scm, gnu/packages/wxwidgets.scm, gnu/packages/xdisorg.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, tests/lint.scm: Remove trailing ".git" from 'git-reference' URL. Ludovic Courtès 2020-07-07gnu: armips: Declare a source file-name....* gnu/packages/assembly.scm (armips)[source]: Add file-name field. Efraim Flashner 2020-06-30gnu: Add armips....* gnu/packages/assembly.scm (armips): New variable. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Leo Prikler 2020-06-02gnu: xa: Update to 2.3.11....* gnu/packages/assembly.scm (xa): Update to 2.3.11. Tobias Geerinckx-Rice 2020-06-02gnu: fasm: Update to 1.73.24....* gnu/packages/assembly.scm (fasm): Update to 1.73.24. Tobias Geerinckx-Rice 2020-04-06gnu: rgbds: Update to 0.4.0....* gnu/packages/assembly.scm (rgbds): Update to 0.4.0 Jakub Kądziołka 2020-03-29gnu: rgbds: Update to 0.3.10....* gnu/packages/assembly.scm (rgbds): Update to 0.3.10. Jakub Kądziołka 2020-03-11gnu: Add xa....* gnu/packages/assembly.scm (xa): New variable. Christopher Lemmer Webber 2020-03-07gnu: yasm: Use HTTPS home page....* gnu/packages/assembly.scm (yasm)[home-page]: Use HTTPS. Tobias Geerinckx-Rice 2020-02-20gnu: libjit: Use git-file-name...* gnu/packages/assembly.scm (libjit): Use git-file-name. Jakub Kądziołka 2020-02-16gnu: fasm: Update to 1.73.22....* gnu/packages/assembly.scm (fasm): Update to 1.73.22. Tobias Geerinckx-Rice 2020-01-11gnu: Add wla-dx....* gnu/packages/assembly.scm (wla-dx): New variable. Signed-off-by: Julien Lepiller <julien@lepiller.eu> Jakub Kądziołka 2020-01-03gnu: fasm: Expand acronym in description....* gnu/packages/assembly.scm (fasm)[description]: Expand @acronym. Tobias Geerinckx-Rice 2020-01-03gnu: fasm: Update to 1.73.21....* gnu/packages/assembly.scm (fasm): Update to 1.73.21. Tobias Geerinckx-Rice 2020-01-03gnu: Add rgbds....* gnu/packages/assembly.scm (rgbds): New variable. Jakub Kądziołka 2019-12-01gnu: nasm: Don't use NAME in source URI....* gnu/packages/assembly.scm (nasm)[source]: Hard-code NAME. Tobias Geerinckx-Rice