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

mwic: Fix Python wrapping #95119

Merged
merged 1 commit into from Dec 29, 2020
Merged

mwic: Fix Python wrapping #95119

merged 1 commit into from Dec 29, 2020

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Aug 10, 2020

Motivation for this change

Fixes this error when mwic is installed with nix-env:

$ mwic
Traceback (most recent call last):
  File "/home/anders/.nix-profile/bin/mwic", line 30, in <module>
    import lib.cli  # pylint: disable=wrong-import-position
  File "/nix/store/zn9jli2v7znh6w6rpkjp6w0iz3na79yz-mwic-0.7.8/share/mwic/lib/cli.py", line 32, in <module>
    import enchant.tokenize
ModuleNotFoundError: No module named 'enchant'
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Fixes this error when mwic is installed with nix-env:

$ mwic
Traceback (most recent call last):
  File "/home/anders/.nix-profile/bin/mwic", line 30, in <module>
    import lib.cli  # pylint: disable=wrong-import-position
  File "/nix/store/zn9jli2v7znh6w6rpkjp6w0iz3na79yz-mwic-0.7.8/share/mwic/lib/cli.py", line 32, in <module>
    import enchant.tokenize
ModuleNotFoundError: No module named 'enchant'

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Copy link
Contributor

@drewrisinger drewrisinger left a comment

Choose a reason for hiding this comment

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

  • Diff LGTM
  • Commits LGTM
  • Builds via nix-review

NOTE: I tried briefly to do a bit more of an overhaul of this package, but it's a little weird in how it repackages python applications, and I wasn't able to get everything working. In my mind, a rework would:

  • use fetchFromGitHub
  • Run the tests that are included in the directory ./tests

I ran into trouble with the tests, pyenchant was looking for spell check dictionaries that couldn't be found, and I had trouble figuring out the right directory to link them to.

Here's what I had for future reference.

Reworked mwic packaging
{ stdenv, fetchFromGitHub, python3Packages }:

stdenv.mkDerivation rec {
  pname = "mwic";
  version = "0.7.8";

  src = fetchFromGitHub {
    owner = "jwilk";
    repo = pname;
    rev = version;
    sha256 = "11h5kf84s3an06dsh06vfw5v6rn1r4mf1md71mf3nnwrfjglrpa3";
  };

  makeFlags=["PREFIX=\${out}"];

  propagatedBuildInputs = with python3Packages; [ pyenchant regex ];

  checkInputs = [
    python3Packages.nose
  ];

  doCheck = true;

  checkPhase = ''
    patchShebangs ./tests/run-tests
    ./tests/run-tests
  '';

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 95119 run on x86_64-linux 1

1 package built:
  • mwic

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

3 participants