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

python3Packages.matplotlib: 3.1.3 -> 3.2.1, and various cleanups #84362

Merged
merged 7 commits into from Apr 21, 2020

Conversation

veprbl
Copy link
Member

@veprbl veprbl commented Apr 5, 2020

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@veprbl
Copy link
Member Author

veprbl commented Apr 5, 2020

@GrahamcOfBorg build python2Packages.matplotlib python37Packages.matplotlib python38Packages.matplotlib

@FRidh FRidh self-assigned this Apr 5, 2020
++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ]
++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ]
++ stdenv.lib.optionals enableQt [ pyqt5 ];

patches =
[ ./basedirlist.patch ];
setup_cfg = ./setup.cfg;
Copy link
Member

Choose a reason for hiding this comment

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

no need to create an environment variable, can just substitute it directly in preBuild

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a need. You can now easily overrideAttrs it.

Copy link
Member

Choose a reason for hiding this comment

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

If it is intended to be overridable, then make it a parameter of the function. overrideAttrs should be avoided because it overrides the low-level stdenv.mkDerivation.

Copy link
Member Author

Choose a reason for hiding this comment

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

@FRidh We certainly should not try to maintain options for every case, and, in fact, we don't even provide options for most common overrides, otherwise we would have functions defined like { stdenv, pname ? "matplotlib", version ? "2.3.1", src ? fetchurl { ... }, ... }:. I thought, the accepted solution to this was that we are not standing in the way of the "low-level" plumbing and thus users can still override src. And I was sticking with this approach to defining my derivations and suggesting it when reviewing other PR's. This is the first time I hear that overrideAttrs should be avoided, because we don't really need overhead of overrideDerivation or overridePythonAttrs or a higher level functions in this particular case.

Just in case, I will try to present my original point again. If I have a derivation:

let
  foo = ./bar;
in
stdenv.mkDerivation {
  fooPhase = ''
    # ...
    cp ${foo} foo
    # ...
  '';
}

I am unable to do a lot of things, like easily access the value of foo (unless I use <nixpkgs/path/to/bar>, which is not overlay-friendly), or easily exchange it for something else (for example I'm not even sure if builtins.replaceStrings will discard the context of old value of foo). This is what we loose when we do it this way, but what do we gain for that?

Copy link
Member

Choose a reason for hiding this comment

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

I see your point. We should indeed not make options for everything. The issue at least with overrideAttrs (and worse, overrideDerivation) is that overriding attributes may not always work as intended. It is this issue, not being able to tell whether it works or not without inspecting how buildPython* works, which is why I say, do not use overrideAttrs.

Now, in this case it indeed would work fine because neither buildPython* nor stdenv.mkDerivation does anything with this specific variable. But, if this is deemed something that you want to offer that should work, I'd argue it should be part of the function interface where it is created. Does it happen often people create variables like these so they can override it later?

Copy link
Member Author

@veprbl veprbl Apr 6, 2020

Choose a reason for hiding this comment

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

But, if this is deemed something that you want to offer that should work, I'd argue it should be part of the function interface where it is created.

I'm having trouble understanding you here. Could you, maybe, rephrase?

Does it happen often people create variables like these so they can override it later?

People, who use overrides, will likely be able to quickly learn which kinds of expressions are easy to override and which are not. Once they have learned the good patterns, they will employ them for their contributions to nixpkgs. When I review PR's, I make suggestions based on my experience doing overrides to improve this aspect. Of course, there are many contributions out there that go against my "best practice", but that doesn't immediately invalidate my effort. And, yes, I saw there are few other people that do put $variables in their phase overrides.

Copy link
Member

@FRidh FRidh Apr 16, 2020

Choose a reason for hiding this comment

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

I thought I had replied but apparently not.

I'm having trouble understanding you here. Could you, maybe, rephrase?

The $setup_cfg variable is specific to matplotlib, not to stdenv.mkDerivation or buildPythonPackage. Put differently, it's a parameter of the matplotlib builder, and not of stdenv.mkDerivation or buildPythonPackage.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, now I see what the point was.

The setup_cfg is not a part of an interface, but a part of implementation, just like XDG_RUNTIME_DIR. But we want the implementation to be conviniently overridable when we do "crazy" things (like build on a system without /tmp, or adding more stuff to setup_cfg).

pkgs/development/python-modules/matplotlib/default.nix Outdated Show resolved Hide resolved
Downloading the baseline_images is not a real issue, building against
older freetype (local_freetype = True) is, perhaps, not what we
want. The good news is that the tests would pass (tested on 3.2.1) if
we were to enable them:

========== 6684 passed, 1332 skipped, 10 xfailed in 228.64s (0:03:48) ==========
@veprbl
Copy link
Member Author

veprbl commented Apr 15, 2020

@FRidh
Anything I can do to facilitate the merge?
For example, maybe it would be okay to merge just the refactoring commits now without the version bump?

@FRidh FRidh merged commit c7d4882 into NixOS:master Apr 21, 2020
@veprbl veprbl deleted the pr/matplotlib_3_2_1 branch April 21, 2020 18:35
@veprbl veprbl restored the pr/matplotlib_3_2_1 branch December 1, 2020 16:46
@veprbl veprbl deleted the pr/matplotlib_3_2_1 branch December 1, 2020 17:00
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

2 participants