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

endgame-singularity: init at 0.30c #45057

Merged
merged 1 commit into from Aug 26, 2018
Merged

Conversation

fgaz
Copy link
Member

@fgaz fgaz commented Aug 15, 2018

Motivation for this change

A game about strong AI

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

# Tell it where to find python libraries
# Also cd to the same directory as the code, since it uses relative paths
postFixup = ''
makeWrapper "$out/share/singularity.py" "$out/bin/singularity" \
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 the exe name ok or should I change it to endgame-singularity? Most distros and the source itself use just singularity

Copy link
Member

Choose a reason for hiding this comment

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

Since you already add a wrapper here, you could just merge this with the shebang change.

I think the name is fine, especially if the official docs and other distros do the same.

Copy link
Member

Choose a reason for hiding this comment

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

We do already have one other package with the same name: https://github.com/singularityware/singularity

But I guess conflicts can't be entirely avoided. Its your call. Changing the name from the upstream default might cause confusion.

postPatch = ''
echo '#!${python2Packages.python}/bin/python'\
$'\n'$(cat singularity-${version}/singularity.py)\
> singularity-${version}/singularity.py
Copy link
Member Author

Choose a reason for hiding this comment

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

Will this cause problems? Should I use sponge?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know sponge. Maybe it would be easier and nicer to just add a wrapper script endgame-singularity that just calls ${python2Packages.python}/bin/python $out/bin/singularity.py or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

I managed to do it nicely with --add-flags

format = "other";

srcs =
[
Copy link
Member

Choose a reason for hiding this comment

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

Small style nitpick: I'd prefer if you included the opening ´[in the line before. Sosrcs = [`. But since we don't have an official style guide and pretty much anybody just does whatever they want, you can keep it the way it is if you prefer.

];
sourceRoot = ".";

buildInputs = [ unzip ]; # The music is zipped
Copy link
Member

Choose a reason for hiding this comment

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

This should be nativeBuildInputs. The difference is that nativeBuildInputs are used exclusively at build time. That is important for cross-compilation.

Similar to above comment, my style preference is one line per item for most lists. It makes for cleaner diffs when dependencies change and easier reordering.

Copy link
Member

Choose a reason for hiding this comment

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

Also better for adding comments to individual items.

sourceRoot = ".";

buildInputs = [ unzip ]; # The music is zipped
propagatedBuildInputs = with python2Packages; [ python pygame numpy ];
Copy link
Member

Choose a reason for hiding this comment

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

I don't think python should be in this list.

postPatch = ''
echo '#!${python2Packages.python}/bin/python'\
$'\n'$(cat singularity-${version}/singularity.py)\
> singularity-${version}/singularity.py
Copy link
Member

Choose a reason for hiding this comment

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

I don't know sponge. Maybe it would be easier and nicer to just add a wrapper script endgame-singularity that just calls ${python2Packages.python}/bin/python $out/bin/singularity.py or something?

'';

installPhase = ''
install -Dm755 singularity-${version}/singularity.py $out/share/singularity.py
Copy link
Member

Choose a reason for hiding this comment

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

Please quote all shell variables, including $out in these couple of lines.

# Tell it where to find python libraries
# Also cd to the same directory as the code, since it uses relative paths
postFixup = ''
makeWrapper "$out/share/singularity.py" "$out/bin/singularity" \
Copy link
Member

Choose a reason for hiding this comment

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

Since you already add a wrapper here, you could just merge this with the shebang change.

I think the name is fine, especially if the official docs and other distros do the same.

# Tell it where to find python libraries
# Also cd to the same directory as the code, since it uses relative paths
postFixup = ''
makeWrapper "$out/share/singularity.py" "$out/bin/singularity" \
Copy link
Member

Choose a reason for hiding this comment

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

We do already have one other package with the same name: https://github.com/singularityware/singularity

But I guess conflicts can't be entirely avoided. Its your call. Changing the name from the upstream default might cause confusion.


meta = {
homepage = "http://www.emhsoft.com/singularity/";
description = "A simulation of a true AI. Go from computer to computer, pursued by the entire world. Keep hidden, and you might have a chance";
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit too long for description. Please split it into description and longDescription. It looks like the first sentence may be a good description, the rest may be longDescription. description should not have a dot at the end. Maybe use A game about a true AI to make clear it is a game.

'';

meta = {
homepage = "http://www.emhsoft.com/singularity/";
Copy link
Member

Choose a reason for hiding this comment

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

The quoting is unnecessary here, nix has a URL type.

@timokau timokau mentioned this pull request Aug 15, 2018
9 tasks
@fgaz fgaz force-pushed the endgame-singularity branch 2 times, most recently from 141a1b8 to 93116db Compare August 15, 2018 14:11
@fgaz
Copy link
Member Author

fgaz commented Aug 15, 2018

@timokau all done

Copy link
Member

@timokau timokau left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes :)

# Also cd to the same directory as the code, since it uses relative paths
postFixup = ''
makeWrapper "${python}/bin/python" "$out/bin/endgame-singularity" \
--set PYTHONPATH "$PYTHONPATH" \
Copy link
Member

Choose a reason for hiding this comment

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

Setting pythonpath should not be necessary with buildPythonApplication. Does it fail without that?

Copy link
Member Author

Choose a reason for hiding this comment

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

buildPythonApplication wraps exes only in certain cases. This is not one of them, since the package type is other and we don't have anything in $out/bin

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it would be a little more beautiful to just symlink $out/share/singularity.py to $out/bin/endgame-singularity in the installPhase and then add --run ... to makeWrapperArgs. Would that work? However, I think it's also ok as it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

This use of makeWrapper is officially documented in the nixpkgs manual. The symlink does not work since imports are relative

makeWrapper "${python}/bin/python" "$out/bin/endgame-singularity" \
--set PYTHONPATH "$PYTHONPATH" \
--run "cd \"$out/share\"" \
--add-flags "$out/share/singularity.py"
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity (not familiar with that flag): What does ´--add-flags` actually do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well... it adds a flag :)

Note that the wrapped exe isn't anymore singularity.py. Now I wrap the python exe and tell it what to execute using --add-flag.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I didn't notice that. But it is unfortunate if that defeats buildPythonPkgs automatic patching. PYTHONPATH is also less performant than buildPythonEnv, although that probably doesn't matter much with a small amount of dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, not that much of a loss since we have to wrap anyway

@@ -19578,6 +19578,8 @@ with pkgs;

EmptyEpsilon = callPackage ../games/empty-epsilon { };

endgame-singularity = callPackage ../games/endgame-singularity { };

Copy link
Member

Choose a reason for hiding this comment

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

Same here: @domenkozar should this be in python-packages?

Copy link
Member Author

@fgaz fgaz Aug 16, 2018

Choose a reason for hiding this comment

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

Same here too :)

edit: I'll copy it here for reference too: Nope, since it isn't a library (see the nixpkgs docs, python section)

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I thought the same applied for the python2Packages←→python.pkgs+disabled=!isPy3 thing, but apparently I was wrong?

Copy link
Member

Choose a reason for hiding this comment

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

Very possible I'm the one who is wrong, @domenkozar should know better.

Copy link
Member

Choose a reason for hiding this comment

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

Same here, I actually meant to ping you @dotlambda. Somehow the matching first two letters got me confused 😁

Copy link
Member

Choose a reason for hiding this comment

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

@fgaz is right.

Copy link
Member

@dotlambda dotlambda Aug 26, 2018

Choose a reason for hiding this comment

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

Is there a reason not to call this singularity as most distros are doing? https://repology.org/metapackage/singularity/versions
The executable should probably also be renamed: https://www.archlinux.org/packages/community/any/singularity/files/

Copy link
Member Author

Choose a reason for hiding this comment

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

Singularity is taken:

Attribute name: nixpkgs.singularity
Package name: singularity
Version: 2.5.1
Description: Designed around the notion of extreme mobility of compute and reproducible science, Singularity enables users to have full control of their operating system environment

For the same reason I also changed the exe name (not that bad since an exe name equal to the pkg name is not surprising). Should I revert it to singularity?

Copy link
Member

Choose a reason for hiding this comment

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

No, seems reasonable.

# Tell it where to find python libraries
# Also cd to the same directory as the code, since it uses relative paths
postFixup = ''
makeWrapper "${python}/bin/python" "$out/bin/endgame-singularity" \
Copy link
Member

Choose a reason for hiding this comment

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

indentation

Copy link
Member

Choose a reason for hiding this comment

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

and please use python.interpreter

@@ -0,0 +1,57 @@
{ stdenv, fetchurl, unzip, python }:
Copy link
Member

Choose a reason for hiding this comment

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

Please make this use python2 explicitly.

pname = "endgame-singularity";
version = "0.30c";
format = "other";
disabled = !(python.isPy3 or true);
Copy link
Member

Choose a reason for hiding this comment

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

not needed

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: endgame-singularity

Partial log (click to expand)

Compiling singularity-0.30c/utils/make-tree.py ...
Compiling singularity-0.30c/utils/reorder.py ...
Listing singularity-0.30c/utils/traduko ...
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/gk6060qh6l8j5j1vl4v11k7407n89vff-endgame-singularity-0.30c
strip is /nix/store/y4ymnvgxygpq05h03kyzbj572zmh6zla-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/gk6060qh6l8j5j1vl4v11k7407n89vff-endgame-singularity-0.30c
checking for references to /build in /nix/store/gk6060qh6l8j5j1vl4v11k7407n89vff-endgame-singularity-0.30c...
/nix/store/gk6060qh6l8j5j1vl4v11k7407n89vff-endgame-singularity-0.30c

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: endgame-singularity

Partial log (click to expand)

Compiling singularity-0.30c/utils/make-tree.py ...
Compiling singularity-0.30c/utils/reorder.py ...
Listing singularity-0.30c/utils/traduko ...
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/vpq8bcb5iibskim6q638fhr8nak71425-endgame-singularity-0.30c
strip is /nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/vpq8bcb5iibskim6q638fhr8nak71425-endgame-singularity-0.30c
checking for references to /build in /nix/store/vpq8bcb5iibskim6q638fhr8nak71425-endgame-singularity-0.30c...
/nix/store/vpq8bcb5iibskim6q638fhr8nak71425-endgame-singularity-0.30c

# This is not an error: it needs both compilation rounds
buildPhase = ''
python -m compileall "singularity-${version}"
python -O -m compileall "singularity-${version}"
Copy link
Member

Choose a reason for hiding this comment

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

python2.interpreter

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: endgame-singularity

Partial log (click to expand)

Compiling singularity-0.30c/utils/make-tree.py ...
Compiling singularity-0.30c/utils/reorder.py ...
Listing singularity-0.30c/utils/traduko ...
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/rjc9aqfgkz8asfc8mn4x0wj8ww4z6rzf-endgame-singularity-0.30c
strip is /nix/store/y4ymnvgxygpq05h03kyzbj572zmh6zla-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/rjc9aqfgkz8asfc8mn4x0wj8ww4z6rzf-endgame-singularity-0.30c
checking for references to /build in /nix/store/rjc9aqfgkz8asfc8mn4x0wj8ww4z6rzf-endgame-singularity-0.30c...
/nix/store/rjc9aqfgkz8asfc8mn4x0wj8ww4z6rzf-endgame-singularity-0.30c

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: endgame-singularity

Partial log (click to expand)

Compiling singularity-0.30c/utils/make-tree.py ...
Compiling singularity-0.30c/utils/reorder.py ...
Listing singularity-0.30c/utils/traduko ...
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/vbx3zbiq1lmdnvs0ra7366s3n68vakfi-endgame-singularity-0.30c
strip is /nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/vbx3zbiq1lmdnvs0ra7366s3n68vakfi-endgame-singularity-0.30c
checking for references to /build in /nix/store/vbx3zbiq1lmdnvs0ra7366s3n68vakfi-endgame-singularity-0.30c...
/nix/store/vbx3zbiq1lmdnvs0ra7366s3n68vakfi-endgame-singularity-0.30c

@dotlambda dotlambda merged commit ff583d8 into NixOS:master Aug 26, 2018
@fgaz fgaz deleted the endgame-singularity branch August 26, 2018 17:42
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

4 participants