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

fetchPypi -> fetchFromPyPI #146564

Closed
wants to merge 3 commits into from
Closed

fetchPypi -> fetchFromPyPI #146564

wants to merge 3 commits into from

Conversation

AndersonTorres
Copy link
Member

@AndersonTorres AndersonTorres commented Nov 19, 2021

Motivation for this change

Since the Python Package Index works as a package index, it is more intuitive to
call the function that fetches packages from it fetchFromPyPI, following the
unwritten rule for sources obtained from a "repository" like fetchFrom{GitHub,
Gitlab, Bitbucket, ...}

For now, this commit will act as a placeholder for the new fetchFromPyPI
function, while the old one will act as a safe alias.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

I can't think of any reasons not to, and it's more consistent with the other platform-specific fetchers.

curious if @FRidh has any feedback though.

@AndersonTorres
Copy link
Member Author

#119896

@figsoda
Copy link
Member

figsoda commented Nov 19, 2021

why PyPI instead of Pypi?

@AndersonTorres
Copy link
Member Author

why PyPI instead of Pypi?

Py thon Package Index

@figsoda
Copy link
Member

figsoda commented Nov 19, 2021

I am not sure about the benefits of capitalizing acronyms in here
It is slightly harder to type and makes case conversions harder, especially when there is a lower case letter within the acronym

@@ -56,7 +56,9 @@ let
# See build-setupcfg/default.nix for documentation.
buildSetupcfg = import ../build-support/build-setupcfg self;

fetchPypi = callPackage ../development/interpreters/python/fetchpypi.nix { };
# fetchPypi -> fetchFromPyPI
fetchPypi = fetchFromPyPI;
Copy link
Member

Choose a reason for hiding this comment

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

maybe we can deprecate this and remove in the (long) future?

Copy link
Contributor

Choose a reason for hiding this comment

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

there's not a good way to deprecate within nixpkgs. If you emit warnings then that breaks a lot of CI's (including ofborg)

Copy link
Member

@SuperSandro2000 SuperSandro2000 Nov 19, 2021

Choose a reason for hiding this comment

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

If you emit warnings then that breaks a lot of CI's (including ofborg)

Which is kinda stupid.

I see myself already doing this quite often so why not.

Suggested change
fetchPypi = fetchFromPyPI;
fetchPypi = fetchFromPyPI;
fetchFromPyPi = throw "Did you mean fetchFromPyPI?"

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this useful? The compiler will catch it anyway...

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say so, it's pretty common to do a typo like this, but it reads as correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this useful? The compiler will catch it anyway...

I am all about this alias. Same as fetchFromGithub.

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like a case for a whole mistaken-aliases.nix file.

@legendofmiracles
Copy link
Contributor

I am not sure about the benefits of capitalizing acronyms in here

It is slightly harder to type and makes case conversions harder, especially when there is a lower case letter within the acronym

We also have mixed case with the GitHub fetcher.
Sure, I guess there's a difference between an acronym and the real name of a platform, but generally PyPI also always seems to be capitalized.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Nov 19, 2021
Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

Using the new fetcher will probably break nix-update, nixpkgs-update and nix-prefetch-url.

@@ -56,7 +56,9 @@ let
# See build-setupcfg/default.nix for documentation.
buildSetupcfg = import ../build-support/build-setupcfg self;

fetchPypi = callPackage ../development/interpreters/python/fetchpypi.nix { };
# fetchPypi -> fetchFromPyPI
Copy link
Member

@SuperSandro2000 SuperSandro2000 Nov 19, 2021

Choose a reason for hiding this comment

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

Suggested change
# fetchPypi -> fetchFromPyPI

This is pretty clear from the line below, no need to comment it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Using the new fetcher will probably break nix-update, nixpkgs-update and nix-prefetch-url.

How?
This is not a "new fetcher", it is the same with a new name. Do the updaters rely on the name of the function?

This is pretty clear from the line below, no need to comment it.

Okay!

Copy link
Contributor

Choose a reason for hiding this comment

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

nix-prefetch-url should be fine. AFAIK, it only works with the nix store and curl.

nix-update might be sensitive to that term. But it's not like we are rolling it out immediately

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I accidently edited your message instead of replying @SuperSandro2000

I wanted to say that there are other possible spellings like fetchFromPypi, I'm not sure about the change in capitalization

@@ -56,7 +56,9 @@ let
# See build-setupcfg/default.nix for documentation.
buildSetupcfg = import ../build-support/build-setupcfg self;

fetchPypi = callPackage ../development/interpreters/python/fetchpypi.nix { };
# fetchPypi -> fetchFromPyPI
fetchPypi = fetchFromPyPI;
Copy link
Member

@SuperSandro2000 SuperSandro2000 Nov 19, 2021

Choose a reason for hiding this comment

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

If you emit warnings then that breaks a lot of CI's (including ofborg)

Which is kinda stupid.

I see myself already doing this quite often so why not.

Suggested change
fetchPypi = fetchFromPyPI;
fetchPypi = fetchFromPyPI;
fetchFromPyPi = throw "Did you mean fetchFromPyPI?"

Since the Python Package Index works as a package index, it is more intuitive to
call the function that fetches packages from it `fetchFromPyPI`, following the
unwritten rule for sources obtained from a "repository" like fetchFrom{GitHub,
Gitlab, Bitbucket, ...}

For now, this commit will act as a placeholder for the new fetchFromPyPI
function, while the old one will act as a safe alias.
@AndersonTorres
Copy link
Member Author

I have tested it locally. It is failing:

error: attribute 'fetchFromPyPI' missing

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/pkgs/development/interpreters/python/default.nix:37:25:

           36|           };
           37|           keep = self: {
             |                         ^
           38|             # TODO maybe only define these here so nothing is needed to be kept in sync.

       … while evaluating the attribute 'src.name'

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/pkgs/development/python-modules/3to2/default.nix:11:3:

           10|
           11|   src = fetchFromPyPI {
             |   ^
           12|     inherit version;

       … while evaluating 'hasSuffix'

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/lib/strings.nix:234:5:

          233|     # Input string
          234|     content:
             |     ^
          235|     let

       … from call site

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/pkgs/development/interpreters/python/mk-python-derivation.nix:127:25:

          126|       pythonRemoveBinBytecodeHook
          127|     ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [
             |                         ^
          128|       unzip

       … while evaluating 'optionals'

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/lib/lists.nix:270:5:

          269|     # List to return if condition is true
          270|     elems: if cond then elems else [];
             |     ^
          271|

       … from call site

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/pkgs/development/interpreters/python/mk-python-derivation.nix:127:10:

          126|       pythonRemoveBinBytecodeHook
          127|     ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [
             |          ^
          128|       unzip

       … while evaluating 'chooseDevOutputs'

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/lib/attrsets.nix:500:22:

          499|   /* Pick the outputs of packages to place in buildInputs */
          500|   chooseDevOutputs = drvs: builtins.map getDev drvs;
             |                      ^
          501|

       … from call site

       … while evaluating the attribute 'nativeBuildInputs' of the derivation 'python2.7-py3to2-1.1.1'

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let

       … while evaluating the attribute 'drvPath'

       at /nix/store/rplkxyhnzsz7cj435ppifx2jlmv9jipj-source/lib/customisation.nix:163:7:

          162|     in commonAttrs // {
          163|       drvPath = assert condition; drv.drvPath;
             |       ^
          164|       outPath = assert condition; drv.outPath;

@AndersonTorres
Copy link
Member Author

I will close and redo this.

@FRidh
Copy link
Member

FRidh commented Jan 16, 2022

I have quite mixed feelings about this. By now, I don't really like fetchers that build upon other actual fetchers. So, in case of fetchPypi, I much rather have a function that returns the url that can then be passed to fetchurl. But I guess preferences differ. Without really having a documented way on what direction we want to go with fetchers I'd say either way could go.

@AndersonTorres
Copy link
Member Author

I much rather have a function that returns the url that can then be passed to fetchurl.

Something like fetchurl {url = generatePyPIUrl {...}}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants