Merge pull request #150132 from wamserma/remove-python2Writer

writers.writePython2: remove / writers.writePyPy{2,3}: init

authored by Lassulus and committed by GitHub 65ca86b1 f59d62e4

+122 -15
+22 -1
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
··· 83 83 release based on GTK+3 and Python 3. 84 84 </para> 85 85 </listitem> 86 + <listitem> 87 + <para> 88 + The <literal>writers.writePython2</literal> and corresponding 89 + <literal>writers.writePython2Bin</literal> convenience 90 + functions to create executable Python 2 scripts in the store 91 + were removed in preparation of removal of the Python 2 92 + interpreter. Scripts have to be converted to Python 3 for use 93 + with <literal>writers.writePython3</literal> or 94 + <literal>writers.writePyPy2</literal> needs to be used. 95 + </para> 96 + </listitem> 86 97 </itemizedlist> 87 98 </section> 88 99 <section xml:id="sec-release-22.05-notable-changes"> 89 100 <title>Other Notable Changes</title> 90 - <itemizedlist spacing="compact"> 101 + <itemizedlist> 91 102 <listitem> 92 103 <para> 93 104 The option ··· 111 122 are only accessible by default to the members of the Unix 112 123 group <literal>redis-${serverName}</literal> through the Unix 113 124 socket <literal>/run/redis-${serverName}/redis.sock</literal>. 125 + </para> 126 + </listitem> 127 + <listitem> 128 + <para> 129 + The 130 + <literal>writers.writePyPy2</literal>/<literal>writers.writePyPy3</literal> 131 + and corresponding 132 + <literal>writers.writePyPy2Bin</literal>/<literal>writers.writePyPy3Bin</literal> 133 + convenience functions to create executable Python 2/3 scripts 134 + using the PyPy interpreter were added. 114 135 </para> 115 136 </listitem> 116 137 </itemizedlist>
+5
nixos/doc/manual/release-notes/rl-2205.section.md
··· 34 34 - `pkgs.claws-mail-gtk2`, representing Claws Mail's older release version three, was removed in order to get rid of Python 2. 35 35 Please switch to `claws-mail`, which is Claws Mail's latest release based on GTK+3 and Python 3. 36 36 37 + - The `writers.writePython2` and corresponding `writers.writePython2Bin` convenience functions to create executable Python 2 scripts in the store were removed in preparation of removal of the Python 2 interpreter. 38 + Scripts have to be converted to Python 3 for use with `writers.writePython3` or `writers.writePyPy2` needs to be used. 39 + 37 40 ## Other Notable Changes {#sec-release-22.05-notable-changes} 38 41 39 42 - The option [services.redis.servers](#opt-services.redis.servers) was added ··· 51 54 are only accessible by default 52 55 to the members of the Unix group `redis-${serverName}` 53 56 through the Unix socket `/run/redis-${serverName}/redis.sock`. 57 + 58 + - The `writers.writePyPy2`/`writers.writePyPy3` and corresponding `writers.writePyPy2Bin`/`writers.writePyPy3Bin` convenience functions to create executable Python 2/3 scripts using the PyPy interpreter were added.
+35
pkgs/build-support/writers/aliases.nix
··· 1 + lib: prev: 2 + 3 + let 4 + # Removing recurseForDerivation prevents derivations of aliased attribute 5 + # set to appear while listing all the packages available. 6 + removeRecurseForDerivations = alias: with lib; 7 + if alias.recurseForDerivations or false then 8 + removeAttrs alias ["recurseForDerivations"] 9 + else alias; 10 + 11 + # Disabling distribution prevents top-level aliases for non-recursed package 12 + # sets from building on Hydra. 13 + removeDistribute = alias: with lib; 14 + if isDerivation alias then 15 + dontDistribute alias 16 + else alias; 17 + 18 + # Make sure that we are not shadowing something from 19 + # writers. 20 + checkInPkgs = n: alias: if builtins.hasAttr n prev 21 + then throw "Alias ${n} is still in writers" 22 + else alias; 23 + 24 + mapAliases = aliases: 25 + lib.mapAttrs (n: alias: removeDistribute 26 + (removeRecurseForDerivations 27 + (checkInPkgs n alias))) 28 + aliases; 29 + 30 + in 31 + mapAliases ({ 32 + /* Cleanup before 22.05, Added 2021-12-11 */ 33 + writePython2 = "Python 2 is EOL and the use of writers.writePython2 is deprecated."; 34 + writePython2Bin = "Python 2 is EOL and the use of writers.writePython2Bin is deprecated."; 35 + })
+33 -10
pkgs/build-support/writers/default.nix
··· 1 - { pkgs, buildPackages, lib, stdenv, libiconv, gawk, gnused, gixy }: 1 + { pkgs, config, buildPackages, lib, stdenv, libiconv, gawk, gnused, gixy }: 2 2 3 - with lib; 4 - rec { 3 + let 4 + aliases = if (config.allowAliases or true) then (import ./aliases.nix lib) else prev: {}; 5 + 6 + writers = with lib; rec { 5 7 # Base implementation for non-compiled executables. 6 8 # Takes an interpreter, for example `${pkgs.bash}/bin/bash` 7 9 # ··· 245 247 ''); 246 248 } name; 247 249 248 - # writePython2 takes a name an attributeset with libraries and some python2 sourcecode and 250 + # writePyPy2 takes a name an attributeset with libraries and some pypy2 sourcecode and 249 251 # returns an executable 250 252 # 251 253 # Example: 252 - # writePython2 "test_python2" { libraries = [ pkgs.python2Packages.enum ]; } '' 254 + # writePyPy2 "test_pypy2" { libraries = [ pkgs.pypy2Packages.enum ]; } '' 253 255 # from enum import Enum 254 256 # 255 257 # class Test(Enum): ··· 257 259 # 258 260 # print Test.a 259 261 # '' 260 - writePython2 = makePythonWriter pkgs.python2 pkgs.python2Packages; 262 + writePyPy2 = makePythonWriter pkgs.pypy2 pkgs.pypy2Packages; 261 263 262 - # writePython2Bin takes the same arguments as writePython2 but outputs a directory (like writeScriptBin) 263 - writePython2Bin = name: 264 - writePython2 "/bin/${name}"; 264 + # writePyPy2Bin takes the same arguments as writePyPy2 but outputs a directory (like writeScriptBin) 265 + writePyPy2Bin = name: 266 + writePyPy2 "/bin/${name}"; 265 267 266 268 # writePython3 takes a name an attributeset with libraries and some python3 sourcecode and 267 269 # returns an executable ··· 280 282 # writePython3Bin takes the same arguments as writePython3 but outputs a directory (like writeScriptBin) 281 283 writePython3Bin = name: 282 284 writePython3 "/bin/${name}"; 283 - } 285 + 286 + # writePyPy3 takes a name an attributeset with libraries and some pypy3 sourcecode and 287 + # returns an executable 288 + # 289 + # Example: 290 + # writePyPy3 "test_pypy3" { libraries = [ pkgs.pypy3Packages.pyyaml ]; } '' 291 + # import yaml 292 + # 293 + # y = yaml.load(""" 294 + # - test: success 295 + # """) 296 + # print(y[0]['test']) 297 + # '' 298 + writePyPy3 = makePythonWriter pkgs.pypy3 pkgs.pypy3Packages; 299 + 300 + # writePyPy3Bin takes the same arguments as writePyPy3 but outputs a directory (like writeScriptBin) 301 + writePyPy3Bin = name: 302 + writePyPy3 "/bin/${name}"; 303 + 304 + }; 305 + in 306 + writers // (aliases writers)
+27 -4
pkgs/build-support/writers/test.nix
··· 3 3 , lib 4 4 , nodePackages 5 5 , perlPackages 6 - , python2Packages 6 + , pypy2Packages 7 7 , python3Packages 8 + , pypy3Packages 8 9 , runCommand 9 10 , writers 10 11 , writeText ··· 54 55 print "success\n" if true; 55 56 ''; 56 57 57 - python2 = writePython2Bin "test-writers-python2-bin" { libraries = [ python2Packages.enum ]; } '' 58 + pypy2 = writePyPy2Bin "test-writers-pypy2-bin" { libraries = [ pypy2Packages.enum ]; } '' 58 59 from enum import Enum 59 60 60 61 ··· 73 74 """) 74 75 print(y[0]['test']) 75 76 ''; 77 + 78 + pypy3 = writePyPy3Bin "test-writers-pypy3-bin" { libraries = [ pypy3Packages.pyyaml ]; } '' 79 + import yaml 80 + 81 + y = yaml.load(""" 82 + - test: success 83 + """) 84 + print(y[0]['test']) 85 + ''; 76 86 }; 77 87 78 88 simple = { ··· 111 121 print "success\n" if true; 112 122 ''; 113 123 114 - python2 = writePython2 "test-writers-python2" { libraries = [ python2Packages.enum ]; } '' 124 + pypy2 = writePyPy2 "test-writers-pypy2" { libraries = [ pypy2Packages.enum ]; } '' 115 125 from enum import Enum 116 126 117 127 ··· 131 141 print(y[0]['test']) 132 142 ''; 133 143 134 - python2NoLibs = writePython2 "test-writers-python2-no-libs" {} '' 144 + pypy3 = writePyPy3 "test-writers-pypy3" { libraries = [ pypy3Packages.pyyaml ]; } '' 145 + import yaml 146 + 147 + y = yaml.load(""" 148 + - test: success 149 + """) 150 + print(y[0]['test']) 151 + ''; 152 + 153 + pypy2NoLibs = writePyPy2 "test-writers-pypy2-no-libs" {} '' 135 154 print("success") 136 155 ''; 137 156 138 157 python3NoLibs = writePython3 "test-writers-python3-no-libs" {} '' 158 + print("success") 159 + ''; 160 + 161 + pypy3NoLibs = writePyPy3 "test-writers-pypy3-no-libs" {} '' 139 162 print("success") 140 163 ''; 141 164 };