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

python/wrapper.nix: Don't try to wrap pyc files #25184

Closed
wants to merge 1 commit into from

Conversation

ahmedtd
Copy link
Contributor

@ahmedtd ahmedtd commented Apr 24, 2017

Before, the python wrapper utility had several deficiencies:

  • It would attempt to wrap non-executable files (.pyc files, for
    example).
  • It would ignore all files in subdirectories of $srcstore/bin.

Now, the python wrapper utility will wrap all executable files in the
directory hierarchy rooted at $srcstore/bin. In addition, it will
not attempt to wrap non-executable files.

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.

Before, the python wrapper utility had several deficiencies:

  * It would attempt to wrap non-executable files (`.pyc` files, for
    example).
  * It would ignore all files in subdirectories of `$srcstore/bin`.

Now, the python wrapper utility will wrap all executable files in the
directory hierarchy rooted at `$srcstore/bin`.  In addition, it will
not attempt to wrap non-executable files.
@mention-bot
Copy link

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

@FRidh
Copy link
Member

FRidh commented Apr 24, 2017

This was originally part of #24944.

@FRidh
Copy link
Member

FRidh commented Apr 30, 2017

Why would we want it to look into subdirectories of $srcstore/bin? There shouldn't even be any subdirectories.

@FRidh FRidh requested a review from Mic92 April 30, 2017 07:57
@ahmedtd
Copy link
Contributor Author

ahmedtd commented Apr 30, 2017

In other packages, omitting subdirectories had directly caused problems.

You are correct, in this case, we could get away with something like

for path in ${stdenv.lib.concatStringsSep " " paths}; do
  if [ -d "$path/bin" ]; then
    cd "$path/bin"
    for prg in *; do
      if [[ -f "$prg" && -x "$prg" ]]; then
        rm -f "$out/bin/$prg"
        makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
      fi
    done
  fi
done

if [[ -d "$srcstore"/bin ]]; then
find "$srcstore"/bin -type f -executable -print0 \
| while IFS= read -d "" srcfile; do
dstfile="$out/bin/$(basename $srcfile)"
Copy link
Member

@Mic92 Mic92 May 1, 2017

Choose a reason for hiding this comment

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

this would create collisions, if "$srcstore"/bin/foo/bar and "$srcstore"/bin/bar exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@peti
Copy link
Member

peti commented May 2, 2017

@ahmedtd,

In other packages, omitting subdirectories had directly caused problems.

which packages are you referring to?

@ahmedtd
Copy link
Contributor Author

ahmedtd commented May 3, 2017

@peti, wrapGappsHook was breaking emacs in several ways, one of which was by not wrapping executables in subdirectories of libexec.

@peti
Copy link
Member

peti commented May 3, 2017

Right, libexecmakes sense. But are there any examples of packages that have sub-directories in bin?

@ahmedtd
Copy link
Contributor Author

ahmedtd commented May 3, 2017

Not that I can think of. Now that I'm thinking of it, though, do any python packages put programs in libexec that need to be wrapped?

@c0bw3b
Copy link
Contributor

c0bw3b commented May 18, 2019

Stalled

@c0bw3b c0bw3b closed this May 18, 2019
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