Skip to content

Commit 6ea4835

Browse files
committed
python-afs: Compatibility with Python 3.13
Python 3.13 introduces a header <lock.h>, which conflicts with OpenAFS's identically-named header. Python 3.15 will probably rename it to pylock.h[1], but it's here for Python 3.13 and probably Python 3.14[2]. In the interim, force OpenAFS's headers to come before Python's when building python-afs. This is a little tricky, because Python's headers use -I by default while OpenAFS's use -isystem, and -I headers all come before -isystem ones. However, if we add Python headers with -isystem at the start of the compiler command, Python's -I will be treated as a dup of a system header, and Python's headers will be moved to the system section of the search path. *However*, because they're at the *start* of the search path, they'll still beat OpenAFS, so we need to also add -isystem for OpenAFS at the start of the compiler command, so the relative order among the system section is correct. Upstream mit-athena/python-afs has an issue for this[3], but because Nix builds weirdly, the patch I wrote there doesn't work for Nix. [1] python/cpython#136759 [2] python/cpython#137075 (comment) [3] mit-athena/python-afs#6
1 parent be6fcaf commit 6ea4835

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pkgs/python-afs.nix

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ stdenv, pkgs, lib, fetchFromGitHub,
2-
cython, buildPythonPackage, setuptools,
2+
cython, python, buildPythonPackage, setuptools,
33
openafs, libkrb5,
44
}:
55

@@ -34,6 +34,27 @@ in buildPythonPackage {
3434
"afs"
3535
];
3636

37+
env = lib.optionalAttrs (python.pythonAtLeast "3.13") {
38+
# Workaround for https://github.com/mit-athena/python-afs/issues/6
39+
# Can probably be removed in 3.15 or maybe 3.14
40+
41+
# Without this hack, Python and OpenAFS have competing lock.h files, and we
42+
# need OpenAFS's to win but Python's does win. Until Python 3.15 comes out,
43+
# we force OpenAFS's headers to come before Python's when building
44+
# python-afs. This is a little tricky, because Python's headers use -I by
45+
# default while OpenAFS's use -isystem, and -I headers all come before
46+
# -isystem ones. However, if we add Python headers with -isystem at the
47+
# start of the compiler command, Python's -I will be treated as a dup of a
48+
# system header, and Python's headers will be moved to the system section
49+
# of the search path. *However*, because they're at the *start* of the
50+
# search path, they'll still beat OpenAFS, so we need to also add -isystem
51+
# for OpenAFS at the start of the compiler command, so the relative order
52+
# among the system section is correct.
53+
54+
NIX_CFLAGS_COMPILE="-isystem${openafs.dev}/include -isystem${python}/include/python${python.pythonVersion}";
55+
#NIX_DEBUG="1";
56+
};
57+
3758
# The tests assume that we have AFS installed and working on the machine
3859
# (e.g., they access files in AFS, expect ThisCell to be set, etc.), so
3960
# skip them.

0 commit comments

Comments
 (0)