Skip to content

Update python derivation template#419

Merged
Mic92 merged 2 commits intonix-community:mainfrom
mweinelt:python-changes
Jul 8, 2024
Merged

Update python derivation template#419
Mic92 merged 2 commits intonix-community:mainfrom
mweinelt:python-changes

Conversation

@mweinelt
Copy link
Member

@mweinelt mweinelt commented Mar 11, 2024

  • setuptools builds don't actually require specifying wheel, which can be seen in the example¹ in the setuptools documentation.
  • migrate from
    • nativeBuildInputs to build-system
    • propagatedBuildInputs to dependencies
    • passthru.optional-dependencies to optional-dependencies
  • Expand pythonImportsCheck, so the item is on a new line.

[1] https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

The primary motivation is to save me many review remarks. I don't generally write rust, so feel free to improve the code.

The new pyproject lingo for the inputs has been introduced on master and will be part of NixOS 24.05.

old

{ lib
, buildPythonPackage
, fetchFromGitHub
, setuptools
, wheel
, cryptography
, pycryptodome
}:

buildPythonPackage rec {
  pname = "joserfc";
  version = "0.9.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "authlib";
    repo = "joserfc";
    rev = version;
    hash = "sha256-+NFCveMPzE0hSs2Qe20/MDHApXVtU3cR/GPFKPqfVV4=";
  };

  nativeBuildInputs = [
    setuptools
    wheel
  ];

  propagatedBuildInputs = [
    cryptography
  ];

  passthru.optional-dependencies = {
    drafts = [
      pycryptodome
    ];
  };

  pythonImportsCheck = [ "joserfc" ];

  meta = with lib; {
    description = "Implementations of JOSE RFCs in Python";
    homepage = "https://github.com/authlib/joserfc";
    license = licenses.bsd3;
    maintainers = with maintainers; [ ];
  };
}

new

{ lib
, buildPythonPackage
, fetchFromGitHub
, setuptools
, cryptography
, pycryptodome
}:

buildPythonPackage rec {
  pname = "joserfc";
  version = "0.9.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "authlib";
    repo = "joserfc";
    rev = version;
    hash = "sha256-+NFCveMPzE0hSs2Qe20/MDHApXVtU3cR/GPFKPqfVV4=";
  };

  build-system = [
    setuptools
  ];

  dependencies = [
    cryptography
  ];

  optional-dependencies = {
    drafts = [
      pycryptodome
    ];
  };

  pythonImportsCheck = [
    "joserfc"
  ];

  meta = with lib; {
    description = "Implementations of JOSE RFCs in Python";
    homepage = "https://github.com/authlib/joserfc";
    license = licenses.bsd3;
    maintainers = with maintainers; [ ];
  };
}

- setuptools builds don't actually require specifying wheel, which can
  be seen in the example¹ in the setuptools documentation.
- migrate from
  - nativeBuildInputs to build-system
  - propagatedBuildInputs to dependencies
  - passthru.optional-dependencies to optional-dependencies
- Expand pythonImportsCheck, so the item is on a new line.

[1] https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
@mweinelt
Copy link
Member Author

mweinelt commented May 6, 2024

Friendly ping, two months in.

@drupol
Copy link

drupol commented May 10, 2024

@figsoda ^^

@mweinelt
Copy link
Member Author

mweinelt commented Jul 8, 2024

Now with the lambda input style used by nixfmt:

{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  cryptography,
  pycryptodome,
}:

buildPythonPackage rec {
  pname = "joserfc";
  version = "0.9.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "authlib";
    repo = "joserfc";
    rev = version;
    hash = "sha256-+NFCveMPzE0hSs2Qe20/MDHApXVtU3cR/GPFKPqfVV4=";
  };

  build-system = [
    setuptools
  ];

  dependencies = [
    cryptography
  ];

  optional-dependencies = {
    drafts = [
      pycryptodome
    ];
  };

  pythonImportsCheck = [
    "joserfc"
  ];

  meta = with lib; {
    description = "Implementations of JOSE RFCs in Python";
    homepage = "https://github.com/authlib/joserfc";
    license = licenses.bsd3;
    maintainers = with maintainers; [ ];
  };
}

@drupol

This comment was marked as off-topic.

@MattSturgeon

This comment was marked as off-topic.

@drupol

This comment was marked as off-topic.

]
["python3.pkgs.setuptools".into()]
} else {
["setuptools".into(), "wheel".into()]
Copy link
Member

Choose a reason for hiding this comment

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

Great to have that fixed. I spotted Nancy of those in reviews and didn't understand why it was there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants