File: sysconfig-debian-schemes.diff

package info (click to toggle)
python3.13 3.13.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 121,328 kB
  • sloc: python: 704,014; ansic: 653,914; xml: 31,250; sh: 5,844; cpp: 4,326; makefile: 1,981; objc: 787; lisp: 502; javascript: 213; asm: 75; csh: 12
file content (92 lines) | stat: -rw-r--r-- 3,674 bytes parent folder | download | duplicates (2)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Debian: Add our install schemes to sysconfig

This adds two schemes:
1. deb_system: Debian's installed Python layout, with modules in
   dist-packages shared across Python versions.
2. posix_local: A clone of posix_prefix that includes a built-in local
   prefix for the dist-packages and binary paths. We default to this to redict
   local installations into /usr/local.

--- a/Lib/sysconfig/__init__.py
+++ b/Lib/sysconfig/__init__.py
@@ -38,6 +38,30 @@
         'scripts': '{base}/bin',
         'data': '{base}',
         },
+    'deb_system': {
+        'stdlib': '{installed_base}/lib/python{py_version_short}',
+        'platstdlib': '{platbase}/lib/python{py_version_short}',
+        'purelib': '{base}/lib/python3/dist-packages',
+        'platlib': '{platbase}/lib/python3/dist-packages',
+        'include':
+            '{installed_base}/include/python{py_version_short}{abiflags}',
+        'platinclude':
+            '{installed_platbase}/include/python{py_version_short}{abiflags}',
+        'scripts': '{base}/bin',
+        'data': '{base}',
+        },
+    'posix_local': {
+        'stdlib': '{installed_base}/lib/python{py_version_short}',
+        'platstdlib': '{platbase}/lib/python{py_version_short}',
+        'purelib': '{base}/local/lib/python{py_version_short}/dist-packages',
+        'platlib': '{platbase}/local/lib/python{py_version_short}/dist-packages',
+        'include':
+            '{installed_base}/include/python{py_version_short}{abiflags}',
+        'platinclude':
+            '{installed_platbase}/include/python{py_version_short}{abiflags}',
+        'scripts': '{base}/local/bin',
+        'data': '{base}/local',
+        },
     'posix_home': {
         'stdlib': '{installed_base}/lib/{implementation_lower}',
         'platstdlib': '{base}/lib/{implementation_lower}',
@@ -237,7 +261,7 @@
 _PYTHON_BUILD = is_python_build()
 
 if _PYTHON_BUILD:
-    for scheme in ('posix_prefix', 'posix_home'):
+    for scheme in ('posix_prefix', 'posix_home', 'posix_local', 'deb_system'):
         # On POSIX-y platforms, Python will:
         # - Build from .h files in 'headers' (which is only added to the
         #   scheme when building CPython)
@@ -298,8 +322,19 @@
             'user': 'osx_framework_user',
         }
 
+    if sys.base_prefix != sys.prefix or hasattr(sys, "real_prefix"):
+        # virtual environments
+        prefix_scheme = 'posix_prefix'
+    else:
+        # default to /usr for package builds, /usr/local otherwise
+        deb_build = os.environ.get('DEB_PYTHON_INSTALL_LAYOUT', 'posix_local')
+        if deb_build in ('deb', 'deb_system'):
+            prefix_scheme = 'deb_system'
+        else:
+            prefix_scheme = 'posix_local'
+
     return {
-        'prefix': 'posix_prefix',
+        'prefix': prefix_scheme,
         'home': 'posix_home',
         'user': 'posix_user',
     }
@@ -431,7 +466,7 @@
         else:
             inc_dir = _PROJECT_BASE
     else:
-        inc_dir = get_path('platinclude')
+        inc_dir = get_path('platinclude', 'posix_prefix')
     return os.path.join(inc_dir, 'pyconfig.h')
 
 
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -386,7 +386,7 @@
         self.assertTrue(os.path.isfile(config_h), config_h)
 
     def test_get_scheme_names(self):
-        wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv']
+        wanted = ['deb_system', 'posix_local', 'nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv']
         if HAS_USER_BASE:
             wanted.extend(['nt_user', 'osx_framework_user', 'posix_user'])
         self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))