cpython: Pull in the mime-types database

Closes #113901
This commit is contained in:
nicoo 2021-02-21 15:09:12 +01:00 committed by Frederik Rietdijk
parent 977005c64f
commit faf0f8a8a4
2 changed files with 28 additions and 0 deletions

View file

@ -4,6 +4,7 @@
, libffi
, gdbm
, lzma
, mime-types
, ncurses
, openssl
, readline
@ -187,6 +188,8 @@ in with passthru; stdenv.mkDerivation {
# (since it will do a futile invocation of gcc (!) to find
# libuuid, slowing down program startup a lot).
(./. + "/${sourceVersion.major}.${sourceVersion.minor}/no-ldconfig.patch")
# Make the mimetypes module refer to the right file
./mimetypes.patch
] ++ optionals (isPy35 || isPy36) [
# Determinism: Write null timestamps when compiling python files.
./3.5/force_bytecode_determinism.patch
@ -247,6 +250,8 @@ in with passthru; stdenv.mkDerivation {
postPatch = ''
substituteInPlace Lib/subprocess.py \
--replace "'/bin/sh'" "'${bash}/bin/sh'"
substituteInPlace Lib/mimetypes.py \
--replace "@mime-types@" "${mime-types}"
'' + optionalString (x11Support && (tix != null)) ''
substituteInPlace "Lib/tkinter/tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
'';

View file

@ -0,0 +1,23 @@
diff --git i/Lib/mimetypes.py w/Lib/mimetypes.py
index f3343c8..ab5b886 100644
--- i/Lib/mimetypes.py
+++ w/Lib/mimetypes.py
@@ -40,16 +40,8 @@
]
knownfiles = [
- "/etc/mime.types",
- "/etc/httpd/mime.types", # Mac OS X
- "/etc/httpd/conf/mime.types", # Apache
- "/etc/apache/mime.types", # Apache 1
- "/etc/apache2/mime.types", # Apache 2
- "/usr/local/etc/httpd/conf/mime.types",
- "/usr/local/lib/netscape/mime.types",
- "/usr/local/etc/httpd/conf/mime.types", # Apache 1.2
- "/usr/local/etc/mime.types", # Apache 1.3
- ]
+ "@mime-types@/etc/mime.types",
+]
inited = False
_db = None