NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.14k stars 14.17k forks source link

pythonRelaxDepsHook removes executable bit #201184

Open Luflosi opened 2 years ago

Luflosi commented 2 years ago

Describe the bug

When including pythonRelaxDepsHook in the nativeBuildInputs, files in the result/bin/ directory lose their executable bit.

Steps To Reproduce

Steps to reproduce the behavior:

  1. mkdir pkgs/development/python-modules/invisible-watermark-test
  2. Write
    
    { lib
    , buildPythonPackage
    , pythonOlder
    , fetchFromGitHub
    , pythonRelaxDepsHook
    , opencv4
    , pytorch
    , onnx
    , onnxruntime
    , pillow
    , pywavelets
    , numpy
    }:

buildPythonPackage rec { pname = "invisible-watermark"; version = "0.1.5"; disabled = pythonOlder "3.6";

src = fetchFromGitHub { owner = "ShieldMnt"; repo = "invisible-watermark"; rev = version; sha256 = "sha256-NGDPEETuM7rYbo8kXYoRWLJWpa/lWLKEvaaiDzSWYZ4="; };

nativeBuildInputs = [ pythonRelaxDepsHook ];

propagatedBuildInputs = [ opencv4 pytorch onnx onnxruntime pillow pywavelets numpy ];

postPatch = '' substituteInPlace setup.py \ --replace 'opencv-python>=4.1.0.25' 'opencv' '';

pythonRelaxDeps = true;

pythonImportsCheck = [ "imwatermark" ];

meta = with lib; { description = "A library for creating and decoding invisible image watermarks"; homepage = "https://github.com/ShieldMnt/invisible-watermark"; license = licenses.mit; maintainers = with maintainers; [ Luflosi ]; }; }

into `pkgs/development/python-modules/invisible-watermark-test/default.nix`
3. `nix-build -A python3Packages.invisible-watermark-test`

### Expected behavior
`result/bin/` contains the `invisible-watermark` file with executable permissions.

### Additional context
This happens even without doing anything else like adding `pythonRelaxDeps = true;`.
@thiagokokada asked me to write this issue in https://github.com/NixOS/nixpkgs/pull/194961#issuecomment-1305500835.

### Notify maintainers
@thiagokokada

### Metadata
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.

```console
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.19.17, NixOS, 22.05 (Quokka), 22.05.20221102.4f09cfc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `""`
 - nixpkgs: `/nix/store/ssxpysqgkcaq804i60va05vni375dd37-source`
FRidh commented 1 year ago

I guess this only happens with scripts being added and not entry_points. Note there are several permissions-related issues with the https://github.com/pypa/wheel/ project.