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
Credstash not runnable as an application #47751
Comments
A quick thought - try building it with |
@peterhoeg It looks like setting self: super: {
pythonX = self.python.override {
packageOverrides = self': super': {
credstash = super'.credstash.overridePythonAttrs(old: rec {
dontWrapPythonPrograms = true;
});
};
};
} and installed:
But now I get:
|
Offhand no idea, sorry. Maybe @FRidh can chip in? |
The .py is a library and should be moved to a site packages folder. |
Does that involve changing the credstash derivation or the way I'm using it? I'm not all that familiar with managing Python packages. |
It looks like I'm able to solve this with the following changes:
Here's a minimal nix shell with that working, can you say whether it works for you?
One question about this is how to upstream. I don't know enough about the Python nix machinery to know whether switching |
@sean-bennett112 Thanks for the example, it works!. Looking at the docs again I'm starting to understand the situation, and was able to write a shell.nix that references the original credstash derivation rather than re-writing it: { pkgs ? import <nixpkgs> {} }:
with pkgs;
let
credstash = python3Packages.toPythonApplication (
python3Packages.credstash.overridePythonAttrs (old: rec {
dontWrapPythonPrograms = true;
})
);
in mkShell { buildInputs = [ credstash ]; } and it still works: $ nix-shell --pure --command 'credstash get my.secret.key'
supersecretvalue
We can see this by searching $ cd $(grep -oP 'nixpkgs=\K[^:]+' <<< "$NIX_PATH")
$ grep --include='*.nix' --recursive 'youtube-dl = '
pkgs/top-level/python-packages.nix: youtube-dl = callPackage ../tools/misc/youtube-dl {};
pkgs/top-level/all-packages.nix: youtube-dl = with python3Packages; toPythonApplication youtube-dl; And this corresponds to $ nix-env -f '<nixpkgs>' --query --available --attr python3.pkgs.youtube-dl
python3.7-youtube-dl-2018.11.18
$ nix-env -f '<nixpkgs>' --query --available --attr youtube-dl
youtube-dl-2018.11.18 In contrast, $ grep --include='*.nix' --recursive 'credstash = '
pkgs/top-level/python-packages.nix: credstash = callPackage ../development/python-modules/credstash { };
$ nix-env -f '<nixpkgs>' --query --available --attr python3.pkgs.credstash
python3.7-credstash-1.15.0
$ nix-env -f '<nixpkgs>' --query --available --attr credstash
error: attribute 'credstash' in selection path 'credstash' not found So maybe the fix is to change credstash/default.nix to include: dontWrapPythonPrograms = true; and add a line to all-packages.nix: credstash = with python3Packages; toPythonApplication credstash; I haven't been able to get this working in an overlay, however. # credstash-overlay-1.nix
self: super: {
credstash = super.python3Packages.toPythonApplication (
super.python3Packages.credstash.overridePythonAttrs (old: rec {
dontWrapPythonPrograms = true;
})
);
} $ credstash get my.secret.key
Traceback (most recent call last):
File "/run/current-system/sw/bin/credstash", line 7, in <module>
from credstash import main
File "/nix/store/8rmldlvlv1z1xl7w02dy7f5qhkzdrg8z-python3.7-credstash-1.15.0/bin/credstash.py", line 26, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3' I've tried all combinations of |
Well I think I figured out what was going on. I put up PR #51807 describing the issue and the fix in more detail. Maybe there's a cleaner solution, but I guess that's what the PR process is for 😁 In the meantime, here's the solution rolled into an overlay: self: super: {
credstash = with super.python3Packages; toPythonApplication (
credstash.overridePythonAttrs (old: rec {
postInstall = "rm $out/bin/credstash.py";
})
);
} |
Issue description
After installing credstash with nix-env, running it raises a SyntaxError. It looks like Python is attempting to import a module from one of the wrapper bash scripts.
The bin directory has shell scripts
credstash
andcredstash.py
, each of whichexec
s actual python code held in.credstash-wrapped
and.credstash.py-wrapped
. In.credstash-wrapped
, it tries to load a Python module from thecredstash.py
shell wrapper, causing aSyntaxError
.bin/.credstash-wrapped
bin/credstash.py
I've repro'd with the Python 3 version as well.
Steps to reproduce
Technical details
"x86_64-linux"
Linux 4.14.54, NixOS, 18.09pre145679.dae9cf6106d (Jellyfish)
yes
no
nix-env (Nix) 2.0.4
"nixos-18.09pre145679.dae9cf6106d"
/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
I've also repro'd on Ubuntu 18.04
The text was updated successfully, but these errors were encountered: