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

Sage on nixos #39981

Merged
merged 23 commits into from Jul 1, 2018
Merged

Sage on nixos #39981

merged 23 commits into from Jul 1, 2018

Conversation

timokau
Copy link
Member

@timokau timokau commented May 4, 2018

Motivation for this change

The current sage package rebuilds all its dependencies with its own build system. Thats a mess:

  • It takes a long time
  • Its basically 50% luck it works at all. Probably lots of failing tests too, I never tried.
  • Its hard to patch
  • It has to re-invent some nixpkgs features to patch the build system
  • Its hard to integrate with other sofware (own python etc.)
  • Its big

So this PR builds all the dependencies with nix instead. All the tests are passing.

It depends on (and includes) #39555, #39405, #38794 (without tests), #38787 and the mpfr update in staging. #39405 is responsible for most of the diff.

It is not quite ready to merge yet, because it updates to sage 8.2.rc4 (last rc) which is not released yet and I still need to fix some FIXMEs, do some TODOs, document patches and remove redundant dependencies.

I'm creating this WIP PR because 8.2 is about to be released and I don't want anybody else wasting time updating sage.

Testing this will take a lot of rebuilding because of the mpfr update (stdenv) and the python patch. If you want to review, your time is probably best spend waiting until I'm finished. If you want to give feedback already, that is of course welcome.

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
    • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@7c6f434c
Copy link
Member

7c6f434c commented May 4, 2018

  1. Impressive.

  2. I think among the things to do before removing [WIP] is making sure you don't commit any clearly temporary files.

@timokau
Copy link
Member Author

timokau commented May 5, 2018

Thanks :)

Oh right the .orig files. I put the PR up in a bit of a hurry and missed those. Removed.

@timokau
Copy link
Member Author

timokau commented May 5, 2018

I'm not sure about the ofBorg error, it appears to have something to do with the node packages. I'm not sure about those anyways, I'm still hoping for some feedback from someone who knows more about node packaging.

Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

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

Thanks @timokau , it is good to see this all together.

I went through it, and then the changes look good to me, although I am still of the opinion we should not be adding old and unmaintained packages to Nixpkgs. Therefore, if these dependencies are really needed, I suggest you move them under the scope of sage and out of python-packages.nix and python-modules/.

@7c6f434c
Copy link
Member

7c6f434c commented May 8, 2018

@FRidh I am not sure if it is fully correct to call such packages unmaintained, as the Sage team is clearly capable and quite likely to perform maintenance on these packages if unavoidable (of course they can also drop the dependency, in which case we would find out the packages were indeed unmaintained along the way…)

On the other hand, maybe they are not worth putting in the global Python namespace, just as liborcus for LibreOffice lived together with it because nothing else was likely to ever use it.

@timokau
Copy link
Member Author

timokau commented May 9, 2018

@FRidh I've moved flask-oldsessions, flask-openid and python-openid under the sage scope.

Status update:

I have removed all unnecessary dependencies and made lots of minor improvements. I'm
currently polishing patches and upstreaming them when possible and appropriate.

I'll also have to figure out how makeScope and newScope work because I think I
should use those in default.nix.

Other than that all the dependencies except the python patches have been merged. Also
sage 8.2 final was released.

@timokau
Copy link
Member Author

timokau commented May 11, 2018

Can somebody (@7c6f434c, @FRidh?) help me figure out how to avoid all the inherit xyz in default.nix? I think I need some of newScope, makeScope, import pkgs.path { overlays = [ (self: super: {...})] } and python.pkgs.override. But whatever I try, it either eats all my RAM in endless recursion, doesn't recognize the overrides or doesn't allow me to define new packages.

Could someone give me a minimal example how to create a new scope that overrides one python package and one regular pacakge? Something like:

pkgs = nixpkgs.giveMeNewScope (self: super: {
    glpk = super.glpk.overrideDerivation (...); # regular package
    numpy = super.python2.pkgs.numpy.override {}; # python package
    fantasy-py = self.python2.callPackage ./fantasy-py.nix {}; # new python package
});

@7c6f434c
Copy link
Member

7c6f434c commented May 11, 2018 via email

@timokau
Copy link
Member Author

timokau commented May 11, 2018

That defines a function right? But where do I call that function / give it as an argument?

@7c6f434c
Copy link
Member

I am not sure — reimporting with overlays sound dirty, packageOverrides are deprecated…

@timokau
Copy link
Member Author

timokau commented May 11, 2018

Yeah reimporting with overlays is what the manual suggested, but I think thats probably a different use-case. Do you know who to ask?

@7c6f434c
Copy link
Member

7c6f434c commented May 11, 2018 via email

@timokau
Copy link
Member Author

timokau commented May 11, 2018

That would be @grahamc in doc/functions.xml and @nbp in doc/language-frameworks/python.section.md. Any help would be much appreciated.

@timokau
Copy link
Member Author

timokau commented May 14, 2018

Alright I think this is ready for review now. The only remaining blocker for merge is #39555. Once thats merged and through staging I will rebase this PR.

If I can clarify anything, let me know.

@timokau timokau changed the title [WIP] Sage on nixos Sage on nixos May 14, 2018
@teto teto mentioned this pull request May 21, 2018
8 tasks
@teto
Copy link
Member

teto commented May 24, 2018

thanks that's an awesome contribution. I wanted to use sage at some point, had some problems, wanted to fix it but gave up when facing the huge task (plus sage developers don't seem too receptive about packaging concerns). I am no maintainer but I believe merging the new packages in one or several PRs would make things easier. I've seen that a maintainer didn't want merging one (old) python package but I would advocate that sage is worth it ?

@timokau
Copy link
Member Author

timokau commented May 24, 2018

thanks that's an awesome contribution.

You're welcome :)

I wanted to use sage at some point, had some problems, wanted to fix it but gave up when facing the huge task (plus sage developers don't seem too receptive about packaging concerns).

There is some work ongoing upstream, but its not as much of an priority as I would like, true. I have also suggested all my relevant changes upstream[1] and at least none of them have been flat out rejected yet. So hopefully it will get better in the future.

I am no maintainer but I believe merging the new packages in one or several PRs would make things easier. I've seen that a maintainer didn't want merging one (old) python package but I would advocate that sage is worth it ?

I have already split most new packages, package fixes and package updates in seperate PRs (lots of them). They've all been merged by now. The only things remaining are the pythong packages @FRidh doesn't want in the main tree, packages that don't make any sense without sage (like pybrial) and sage itself.

I think more or less the only thing blocking this PR is #39555, which is itself only blocked on the staging branch being a mess right now (not sure if thats still the case).

So once staging is cleaned up, #39555 can be merged into staging. Then we have to wait for staging to be merged into master and then this can be merged.

[1] https://trac.sagemath.org/query?status=closed&status=needs_info&status=needs_review&status=needs_work&status=new&status=positive_review&reporter=gh-timokau&order=priority

@timokau
Copy link
Member Author

timokau commented Jun 28, 2018

Finally all the dependencies are in master. I've cleaned up the history and rebased on nixpkgs-unstable for easier testing.

I think this is ready for test/merge.

@GrahamcOfBorg build sage.lib

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: sage.lib

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: sage.lib

Partial log (click to expand)

make[1]: Leaving directory '/build/source'
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/v92icw9c0xqhml86n5xl1yj7rsdd4q9q-pynac-0.7.16
shrinking /nix/store/v92icw9c0xqhml86n5xl1yj7rsdd4q9q-pynac-0.7.16/lib/libpynac.so.17.1.0
strip is /nix/store/0pjsgkxz0rp5baycq5sp2s72lrr5q9sg-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/v92icw9c0xqhml86n5xl1yj7rsdd4q9q-pynac-0.7.16/lib
patching script interpreter paths in /nix/store/v92icw9c0xqhml86n5xl1yj7rsdd4q9q-pynac-0.7.16
checking for references to /build in /nix/store/v92icw9c0xqhml86n5xl1yj7rsdd4q9q-pynac-0.7.16...
cannot build derivation '/nix/store/82rrk0bx5hjv91hbjsj9qfbyyrvjnv82-python2.7-sagelib-8.2.drv': 6 dependencies couldn't be built
error: build of '/nix/store/82rrk0bx5hjv91hbjsj9qfbyyrvjnv82-python2.7-sagelib-8.2.drv' failed

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: sage.lib

Partial log (click to expand)

100  1340  100  1340    0     0   1413      0 --:--:-- --:--:-- --:--:--  1413
building '/nix/store/c1614jmjiipk1aaswckmjwxhlsrchg3c-zero_division_error_formatting.patch.drv'...

trying https://git.sagemath.org/sage.git/patch/?h=f79070ddd09fa0ad6b340b097bd8d690a7aa35f0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1631    0  1631    0     0   3294      0 --:--:-- --:--:-- --:--:--  3294
cannot build derivation '/nix/store/vsvv2dadn6mbdf4vzy9h4p09f59zksma-sage-src-8.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/ivpj81ax61c5gvp31xj3icidsrg9bzil-python2.7-sagelib-8.2.drv': 4 dependencies couldn't be built
error: build of '/nix/store/ivpj81ax61c5gvp31xj3icidsrg9bzil-python2.7-sagelib-8.2.drv' failed

Not actually needed by any package and adds and indirect dependency to
atlas.
Fixes the build with current flask, which deprecated the old import
syntax.
Fixes the build with current flask, which deprecated the old import
syntax.
@timokau
Copy link
Member Author

timokau commented Jun 29, 2018

Oh that must've been a mistake while fixing some merge conflict because I assumed that was my version of python-openid. I've rebased on latest master. Since python-openid for python2 is removed there, the eval should succeed now.

@7c6f434c
Copy link
Member

@timokau re: batch updates: when upstream of the language ecosystem has a package manager, it makes sense to track it via batch updates because the outcome is easier to reason about when comparing to the upstream situation.

@timokau
Copy link
Member Author

timokau commented Jun 30, 2018

Why is that? Python packages can depend on specific version (ranges) and if a update builds in nixpkgs and doesn't break any reverse-dependencies, I see no reason not to include it right then.

@dotlambda
Copy link
Member

dotlambda commented Jun 30, 2018

It's simply that just a small percentage of the python packages would be updated at all if we didn't have batch upgrades. And since the batch upgrades only happen on the unstable channel, people encountering broken builds should expect that this happens from time to time. Before a new release, we try to stabilize the python package set.
Btw, @FRidh proposed https://groups.google.com/forum/#!topic/nix-devel/koLvsCVjQcA, which would allow maintainers to opt out of batch upgrades.

Removes the version pinning for arb and pynac by backporting the
upstream (sage) package upgrades. This necessitates a new patch for arb,
which was however already proposed and accepted upstream.
@timokau
Copy link
Member Author

timokau commented Jun 30, 2018

Lets continue the python discussion here: https://discourse.nixos.org/t/continuation-discussion-about-python-infrastructure/441.

Back to topic: I've added another commit that un-pins two dependencies. I think that can remain its own commit, since it touches the arb packages as well and is a good example of the kind of maintenance work that will be needed to keep sage working.

Since this has been open and ready for review without major changes or objections for a while now, can we merge this? Maybe someone else can verify that sage builds for them before that. But I've rebuild from scratch after garbage-collecting, so I would be surprised if someone else got different results.

The patch was replaced by a better upstream patch that doesn't mvoe the
jupyter dir to the user's home.
@7c6f434c 7c6f434c merged commit 055a29c into NixOS:master Jul 1, 2018
@7c6f434c
Copy link
Member

7c6f434c commented Jul 1, 2018

And a semi-related note: I think you should ask to get commit rights; while it might make sense to keep a Sage update in a PR while it is a WIP, and to discuss with @FRidh if you want a non-default version of a python package from a maintained branch, it is quite likely that reviewing your sage changes is useless because you have learnt about Sage much more than everyone else counted together. Also, I do think you have enough experience that your opinion about a PR «ah, it's just an uncontroversial update and it is ready to merge» is as good as anyone's.

@teto
Copy link
Member

teto commented Jul 1, 2018

Congrats ! thanks for the awesome work to all involved.

@timokau
Copy link
Member Author

timokau commented Jul 1, 2018

Thanks for merging! @teto you seem very interested in this package. Please don't hesitate to make improvements, fix bugs or ask questions if something is unclear! It would be nice to have a bus factor > 1.

I think you should ask to get commit rights

Sounds good :) What is the process for that?

@timokau timokau deleted the sage-on-nixos branch July 1, 2018 15:28
@7c6f434c
Copy link
Member

7c6f434c commented Jul 1, 2018

@rbvermaa @domenkozar I think it is a good idea to give @timokau write access.

@7c6f434c
Copy link
Member

7c6f434c commented Jul 1, 2018

@timokau in the meantime, do you have 2FA enabled on GitHub?

@timokau
Copy link
Member Author

timokau commented Jul 1, 2018

Yes I have.

@timokau
Copy link
Member Author

timokau commented Jul 29, 2018

@rbvermaa @domenkozar was this ever discussed?

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

6 participants