Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Proposal/fetchpypi generalized fetching from pypi #22257

Closed
wants to merge 7 commits into from
Closed

[wip] Proposal/fetchpypi generalized fetching from pypi #22257

wants to merge 7 commits into from

Conversation

RonnyPfannschmidt
Copy link
Contributor

Motivation for this change

add a more general tool to fetch packages from pypi using fetchurl

step1 is adding the pypi.io base mirror and testing the first helper on a few packages
the next steps are adding wheel fetching and updating more packages

followup to #22256 22256

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@RonnyPfannschmidt, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @peti, @cmfwyp and @FRidh to be potential reviewers.

@RonnyPfannschmidt RonnyPfannschmidt changed the title [wip} Proposal/fetchpypi generalized fetching from pypi [wip] Proposal/fetchpypi generalized fetching from pypi Jan 29, 2017
@RonnyPfannschmidt
Copy link
Contributor Author

current failures are because setuptools/wheel are not implied build dependencies of pip, i beleive i should split the pr

@@ -37,6 +37,20 @@ let

graphiteVersion = "0.9.15";

fetchPypiMirror = ({ name ? null , pname ? null, version ? null, kind, ext, sha256}:
let
_name = if name == null then "${pname}-${version}" else name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do this with the default values of the attributeset

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont follow

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he means

fetchPypiMirror = ({kind, ext, sha256, ...} @ args:
  let
    _name = args.name or "${pname}-${version}";

url = "mirror://pypiio/${kind}/${builtins.substring 0 1 _name}/${_pdrv.name}/${_name}${ext}";
});

fetchSource = args: fetchPypiMirror (args // { kind = "source"; ext=".tar.gz"; });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used a types attributeset with a bunch of common extensions, that might be a bit more extensible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

care to elaborate


pypiio = [
https://pypi.io/packages/
];
pypi = [
Copy link
Member

@garbas garbas Jan 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't pypi.io be part of the pypi mirror?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

different root base url, the pypi mirror is having a bad starting segment not useful for the different types

in
pkgs.fetchurl {
inherit sha256;
url = "mirror://pypiio/${kind}/${builtins.substring 0 1 _name}/${_pdrv.name}/${_name}${ext}";
Copy link
Member

@garbas garbas Jan 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually won't work in all cases :) I know your code should work, but I found out that there are many different ways how URL is generated on pypi.python.org. Also, the below code should make fetchSourceZip obsolete.

  fetchpypi = name: version: hash: pkgs.fetchurl {
      urls = [
        "https://pypi.python.org/packages/source/${builtins.substring 0 1 name}/${name}/${name}-${version}.tar.gz"
        "https://pypi.python.org/packages/source/${builtins.substring 0 1 name}/${name}/${pkgs.lib.toLower name}-${version}.tar.gz"
        "https://pypi.python.org/packages/source/${builtins.substring 0 1 name}/${name}/${name}-${version}.tgz"
        "https://pypi.python.org/packages/source/${builtins.substring 0 1 name}/${name}/${pkgs.lib.toLower name}-${version}.tgz"
        "https://pypi.python.org/packages/source/${builtins.substring 0 1 name}/${name}/${name}-${version}.zip"
        "https://pypi.python.org/packages/source/${builtins.substring 0 1 name}/${name}/${pkgs.lib.toLower name}-${version}.zip"
      ];
      md5 = "${hash}";
  };

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work if if normalized names are used, pip does the same since 9.x.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it should work with normalized names, but my experience tells me different :)

Copy link
Member

@LnL7 LnL7 Jan 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, perhaps it's only for the metadata then? That's why I used pip download for my implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely idea

@Mic92
Copy link
Member

Mic92 commented Jan 29, 2017

see also #16005 by @FRidh, which introduce a buildPyPIPackage

@RonnyPfannschmidt
Copy link
Contributor Author

@Mic92 thanks for the reference, i believe the 2 pull requests are orthogonal - my functions could be used as part of the functions made by @FRidh tho

FRidh added a commit that referenced this pull request Feb 1, 2017
Inspired by #22257.
It is recommend to use fetchpypi and, when fetching a wheel, to pass
`format = "wheel"` (typically you can just `inherit format;`).

The hash type is fixed (for now) because this is the hash type PyPI
uses.
@FRidh
Copy link
Member

FRidh commented Feb 1, 2017

I intend to merge 695ff0d

@FRidh
Copy link
Member

FRidh commented Feb 1, 2017

Though maybe more urls have to be added as @garbas wrote.

@RonnyPfannschmidt
Copy link
Contributor Author

i haven't gotten around updating, i#ll try to take a look after work

@RonnyPfannschmidt
Copy link
Contributor Author

@FRidh i belive this is obsolete now?

@FRidh
Copy link
Member

FRidh commented Feb 10, 2017

i belive this is obsolete now?

Yes, I think it is. Thanks for the proposal though!

@FRidh FRidh closed this Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants