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 release based on GTK+3 and Python 3. 84 </para> 85 </listitem> 86 </itemizedlist> 87 </section> 88 <section xml:id="sec-release-22.05-notable-changes"> 89 <title>Other Notable Changes</title> 90 - <itemizedlist spacing="compact"> 91 <listitem> 92 <para> 93 The option ··· 111 are only accessible by default to the members of the Unix 112 group <literal>redis-${serverName}</literal> through the Unix 113 socket <literal>/run/redis-${serverName}/redis.sock</literal>. 114 </para> 115 </listitem> 116 </itemizedlist>
··· 83 release based on GTK+3 and Python 3. 84 </para> 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> 97 </itemizedlist> 98 </section> 99 <section xml:id="sec-release-22.05-notable-changes"> 100 <title>Other Notable Changes</title> 101 + <itemizedlist> 102 <listitem> 103 <para> 104 The option ··· 122 are only accessible by default to the members of the Unix 123 group <literal>redis-${serverName}</literal> through the Unix 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. 135 </para> 136 </listitem> 137 </itemizedlist>
+5
nixos/doc/manual/release-notes/rl-2205.section.md
··· 34 - `pkgs.claws-mail-gtk2`, representing Claws Mail's older release version three, was removed in order to get rid of Python 2. 35 Please switch to `claws-mail`, which is Claws Mail's latest release based on GTK+3 and Python 3. 36 37 ## Other Notable Changes {#sec-release-22.05-notable-changes} 38 39 - The option [services.redis.servers](#opt-services.redis.servers) was added ··· 51 are only accessible by default 52 to the members of the Unix group `redis-${serverName}` 53 through the Unix socket `/run/redis-${serverName}/redis.sock`.
··· 34 - `pkgs.claws-mail-gtk2`, representing Claws Mail's older release version three, was removed in order to get rid of Python 2. 35 Please switch to `claws-mail`, which is Claws Mail's latest release based on GTK+3 and Python 3. 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 + 40 ## Other Notable Changes {#sec-release-22.05-notable-changes} 41 42 - The option [services.redis.servers](#opt-services.redis.servers) was added ··· 54 are only accessible by default 55 to the members of the Unix group `redis-${serverName}` 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 }: 2 3 - with lib; 4 - rec { 5 # Base implementation for non-compiled executables. 6 # Takes an interpreter, for example `${pkgs.bash}/bin/bash` 7 # ··· 245 ''); 246 } name; 247 248 - # writePython2 takes a name an attributeset with libraries and some python2 sourcecode and 249 # returns an executable 250 # 251 # Example: 252 - # writePython2 "test_python2" { libraries = [ pkgs.python2Packages.enum ]; } '' 253 # from enum import Enum 254 # 255 # class Test(Enum): ··· 257 # 258 # print Test.a 259 # '' 260 - writePython2 = makePythonWriter pkgs.python2 pkgs.python2Packages; 261 262 - # writePython2Bin takes the same arguments as writePython2 but outputs a directory (like writeScriptBin) 263 - writePython2Bin = name: 264 - writePython2 "/bin/${name}"; 265 266 # writePython3 takes a name an attributeset with libraries and some python3 sourcecode and 267 # returns an executable ··· 280 # writePython3Bin takes the same arguments as writePython3 but outputs a directory (like writeScriptBin) 281 writePython3Bin = name: 282 writePython3 "/bin/${name}"; 283 - }
··· 1 + { pkgs, config, buildPackages, lib, stdenv, libiconv, gawk, gnused, gixy }: 2 3 + let 4 + aliases = if (config.allowAliases or true) then (import ./aliases.nix lib) else prev: {}; 5 + 6 + writers = with lib; rec { 7 # Base implementation for non-compiled executables. 8 # Takes an interpreter, for example `${pkgs.bash}/bin/bash` 9 # ··· 247 ''); 248 } name; 249 250 + # writePyPy2 takes a name an attributeset with libraries and some pypy2 sourcecode and 251 # returns an executable 252 # 253 # Example: 254 + # writePyPy2 "test_pypy2" { libraries = [ pkgs.pypy2Packages.enum ]; } '' 255 # from enum import Enum 256 # 257 # class Test(Enum): ··· 259 # 260 # print Test.a 261 # '' 262 + writePyPy2 = makePythonWriter pkgs.pypy2 pkgs.pypy2Packages; 263 264 + # writePyPy2Bin takes the same arguments as writePyPy2 but outputs a directory (like writeScriptBin) 265 + writePyPy2Bin = name: 266 + writePyPy2 "/bin/${name}"; 267 268 # writePython3 takes a name an attributeset with libraries and some python3 sourcecode and 269 # returns an executable ··· 282 # writePython3Bin takes the same arguments as writePython3 but outputs a directory (like writeScriptBin) 283 writePython3Bin = name: 284 writePython3 "/bin/${name}"; 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 , lib 4 , nodePackages 5 , perlPackages 6 - , python2Packages 7 , python3Packages 8 , runCommand 9 , writers 10 , writeText ··· 54 print "success\n" if true; 55 ''; 56 57 - python2 = writePython2Bin "test-writers-python2-bin" { libraries = [ python2Packages.enum ]; } '' 58 from enum import Enum 59 60 ··· 73 """) 74 print(y[0]['test']) 75 ''; 76 }; 77 78 simple = { ··· 111 print "success\n" if true; 112 ''; 113 114 - python2 = writePython2 "test-writers-python2" { libraries = [ python2Packages.enum ]; } '' 115 from enum import Enum 116 117 ··· 131 print(y[0]['test']) 132 ''; 133 134 - python2NoLibs = writePython2 "test-writers-python2-no-libs" {} '' 135 print("success") 136 ''; 137 138 python3NoLibs = writePython3 "test-writers-python3-no-libs" {} '' 139 print("success") 140 ''; 141 };
··· 3 , lib 4 , nodePackages 5 , perlPackages 6 + , pypy2Packages 7 , python3Packages 8 + , pypy3Packages 9 , runCommand 10 , writers 11 , writeText ··· 55 print "success\n" if true; 56 ''; 57 58 + pypy2 = writePyPy2Bin "test-writers-pypy2-bin" { libraries = [ pypy2Packages.enum ]; } '' 59 from enum import Enum 60 61 ··· 74 """) 75 print(y[0]['test']) 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 + ''; 86 }; 87 88 simple = { ··· 121 print "success\n" if true; 122 ''; 123 124 + pypy2 = writePyPy2 "test-writers-pypy2" { libraries = [ pypy2Packages.enum ]; } '' 125 from enum import Enum 126 127 ··· 141 print(y[0]['test']) 142 ''; 143 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" {} '' 154 print("success") 155 ''; 156 157 python3NoLibs = writePython3 "test-writers-python3-no-libs" {} '' 158 + print("success") 159 + ''; 160 + 161 + pypy3NoLibs = writePyPy3 "test-writers-pypy3-no-libs" {} '' 162 print("success") 163 ''; 164 };