Packaging/Python: Difference between revisions

imported>Milahu
add TODO pip2nix
imported>Milahu
update HTTP 404 with fetchPypi
Line 82: Line 82:
</blockquote>
</blockquote>


when we look at https://pypi.org/project/stt/#files we see only <code>*.whl</code> files
when we look at https://pypi.org/project/stt/#files we see only <code>*.whl</code> files:
 
* <code>stt-1.2.0-cp310-cp310-win_amd64.whl</code>
* <code>stt-1.2.0-cp310-cp310-manylinux_2_24_x86_64.whl</code>
* <code>stt-1.2.0-cp310-cp310-macosx_10_10_universal2.whl</code>
* ...


this means, this is a binary release, so we have two options:
this means, this is a binary release, so we have two options:
Line 93: Line 98:
replace this
replace this


<pre>
<syntaxHighlight lang=nix>
    buildPythonPackage {
      pname = "TODO";
      version = "TODO";
       src = fetchPypi {
       src = fetchPypi {
         inherit pname version;
         inherit pname version;
         sha256 = "";
         sha256 = ""; # TODO
       };
       };
</pre>
</syntaxHighlight>


with this
with this


<pre>
<syntaxHighlight lang=nix>
    buildPythonPackage {
      pname = "TODO";
      version = "TODO";
       src = fetchFromGitHub {
       src = fetchFromGitHub {
         owner = "todo";
         owner = "TODO";
         repo = "todo";
         repo = "TODO";
         rev = "todo";
         rev = "v${version}";
         sha256 = "";
         sha256 = ""; # TODO
       };
       };
</pre>
</syntaxHighlight>
 


==== install binary release ====
==== install binary release ====


TODO
replace this
 
<syntaxHighlight lang=nix>
    buildPythonPackage {
      pname = "TODO";
      version = "TODO";
      src = fetchPypi {
        inherit pname version;
        sha256 = ""; # TODO
      };
</syntaxHighlight>
 
with this
 
<syntaxHighlight lang=nix>
    buildPythonPackage {
      pname = "TODO";
      version = "TODO";
      format = "wheel";
      src = fetchPypi {
        inherit pname version format;
        sha256 = ""; # TODO
        dist = "py3";
        python = "py3";
        #abi = "none";
        #platform = "any";
      };
</syntaxHighlight>


... or use <code>fetchurl</code> to download the <code>*.whl</code> file directly.<br>
examples: [https://grep.app/search?filter%5Brepo%5D%5B0%5D=NixOS/nixpkgs&filter%5Blang%5D%5B0%5D=Nix&filter%5Bpath%5D%5B0%5D=pkgs/development/python-modules/&q=.whl grep for ".whl" in nixpkgs/pkgs/development/python-modules/]
examples: [https://grep.app/search?filter%5Brepo%5D%5B0%5D=NixOS/nixpkgs&filter%5Blang%5D%5B0%5D=Nix&filter%5Bpath%5D%5B0%5D=pkgs/development/python-modules/&q=.whl grep for ".whl" in nixpkgs/pkgs/development/python-modules/]


TODO or use <code>buildPythonPackage { format = "wheel"; }</code>?
reference: [https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/fetchpypi.nix fetchPypi implementation]


== setup.py ==
== setup.py ==