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

pyvips: init at 2.1.12 #98866

Merged
merged 1 commit into from Sep 28, 2020
Merged

pyvips: init at 2.1.12 #98866

merged 1 commit into from Sep 28, 2020

Conversation

ccellado
Copy link
Contributor

Motivation for this change

Add python bindings for libvips in API mode to nixpkgs rep.

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.

Comment on lines 1 to 2
{ buildPythonPackage, fetchPypi, python, pytestrunner, gcc, glib, cffi
, python3Packages, pkgconfig, stdenv, vips, lib}:
Copy link
Contributor

Choose a reason for hiding this comment

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

Using pythonXPackages isn't allowed from python-modules as this will mix interpreter versions for a given package. For example, if you were to do python37Packages.<mypkg>, but the expression pulled from python3[8]Packages. Python will be mis-importing several libraries, and this will likely cause issues at runtime.

Please refer to Python dependency handling on the best practices for handling dependencies within python-modules. Namely, you should be importing each python package individually, and not refer to another python package set (E.g. python3Packages).

If you're new to nixpkgs, you're free to view some of my videos on nixpkgs and python:

pkgs/development/python-modules/pyvips/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyvips/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyvips/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyvips/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyvips/default.nix Outdated Show resolved Hide resolved
Comment on lines 1 to 2
{ buildPythonPackage, fetchPypi, python, pytestrunner, gcc, glib, cffi
, python3Packages, pkgconfig, stdenv, vips, lib}:
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused and invalid packages

Suggested change
{ buildPythonPackage, fetchPypi, python, pytestrunner, gcc, glib, cffi
, python3Packages, pkgconfig, stdenv, vips, lib}:
{ buildPythonPackage, fetchPypi, pytestrunner, glib, cffi
, pkg-config, vips, lib}:

pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyvips/default.nix Outdated Show resolved Hide resolved
@ccellado
Copy link
Contributor Author

@jonringer i've tried all of your suggestions and the package doesn't build anymore.

My original recipe should see at compile time the pkgconfig files, now it says
"ERROR: Could not find a version that satisfies the requirement pkgconfig (from versions: none)
ERROR: No matching distribution found for pkgconfig"

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

here's how I would package this:

python-packages.nix

  pyvips = callPackage ../development/python-modules/pyvips {
    inherit (pkgs) glib pkg-config vips;
  };

pyvips/default.nix:

{ lib, buildPythonPackage, fetchPypi
, pytestrunner
, pytestCheckHook
, glib
, cffi
, pkgconfig
, pkg-config
, vips
}:

buildPythonPackage rec {
  pname = "pyvips";
  version = "2.1.12";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0pg0dxhxgi2m7bb5bi5wpx9hgnbi8ws1bz6w2dldbhi52pizghl4";
  };

  nativeBuildInputs = [
    pkg-config # for pkg-config hook
    pkgconfig  # python package
    pytestrunner
  ];

  buildInputs = [
    glib
    vips
  ];

  propagatedBuildInputs = [ cffi ];

  # no tests in pypi tarball
  doCheck = false;
  checkInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "pyvips" ];

  meta = with lib; {
    description = "A python wrapper for libvips";
    homepage = "https://github.com/libvips/pyvips";
    license = licenses.mit;
    maintainers = with maintainers; [ ccellado ];
  };
}

@jonringer
Copy link
Contributor

one of my suggestions i forgot to include a closing ''; so it was failing to eval

@ccellado
Copy link
Contributor Author

Now it works and I hope its good!

I'm new to the whole nix packaging thing - doing this one took me several months to complete in API mode.
Sometimes the documentation is too arcane or I am not so through to get the specifics.

Thank you for the patience.

@ccellado
Copy link
Contributor Author

At last: for some reason this bit won't work

checkInputs = [ pytestCheckHook ];

It says : "error: undefined variable 'pytestCheckHook'"

@jonringer
Copy link
Contributor

At last: for some reason this bit won't work

checkInputs = [ pytestCheckHook ];

It says : "error: undefined variable 'pytestCheckHook'"

looks like I forgot to re-add it when i was reformatting the inputs, I adjusted the original comment

@ccellado
Copy link
Contributor Author

Oh, so you have to add it explicitly.

The manual says it's in the buildPythonPackage module... well that's that.

Thanks again, I'll summarize the commits.

@jonringer
Copy link
Contributor

jonringer commented Sep 27, 2020

Please follow CONTRIBUTING.md and manual#submitting-changes-making-patches and squash the fix-up commits.

This can be done without git rebase -i by doing:

git reset HEAD~7                   # move fix-up commits into unstaged
git add -- pkgs/                    # move changes into staged
git commit --amend --no-edit        # add changes to previous commit
git push ... ... --force            # modify current PR branch

However, git rebase -i is a more powerful alternative, I created a small video demonstrating it's use here. A more indepth text tutorial can be found here

pyvips: init at 2.1.12

pyvips: init at 2.1.12

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

Update pkgs/top-level/python-packages.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>

pyvips: init at 2.1.12

Update pkgs/development/python-modules/pyvips/default.nix

Co-authored-by: Jon <jonringer@users.noreply.github.com>
Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

LGTM

Result of nixpkgs-review pr 98866 1

3 packages built:
  • python27Packages.pyvips
  • python37Packages.pyvips
  • python38Packages.pyvips

@jonringer jonringer merged commit 2f4f052 into NixOS:master Sep 28, 2020
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