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

Python: deprecate format and default to pyproject #253154

Open
2 tasks done
figsoda opened this issue Sep 3, 2023 · 11 comments
Open
2 tasks done

Python: deprecate format and default to pyproject #253154

figsoda opened this issue Sep 3, 2023 · 11 comments

Comments

@figsoda
Copy link
Member

figsoda commented Sep 3, 2023

Motivation

Since the introduction of PEP 518 and some following PEPs that expands on the idea, the pyproject.toml format has gained a lot of adoption and became the de facto format for python packages.

However, a more popular option, and the current default format in nixpkgs is setuptools. Luckily, we might still be able to build these packages with format = "pyproject" because pyproject.toml falls back to using setuptools as its build backend as documented by pypa even if the package doesn't have a pyproject.toml. This might actually be preferred, because I ran into issues with format = "setuptools" when trying to package a setup.py package.

Proposal

I am proposing to deprecate the format option and replacing it with a pyproject option for packages that don't work with pyproject. We can do this over a longer period of time:

  1. introduce a pyproject option that conflicts with the existing format option, where true is equivalent to format = "pyproject" and false is equivalent to format = "other"
  2. enforce newly added python packages to use the pyproject option instead of format
  3. convert existing format = "setuptools" and format = "pyproject" to pyproject = true and the rest to pyproject = false
  4. deprecate format with a warning and make the default behavior pyproject = true (instead of format = "setuptools")
  5. remove all pyproject = trues, as this is now the default
  6. remove the format option altogether

Related Issues

@figsoda
Copy link
Member Author

figsoda commented Sep 3, 2023

cc the python team: @FRidh @mweinelt @jonringer @tjni

@FRidh
Copy link
Member

FRidh commented Sep 4, 2023

Yes, we should get rid of format, and this way forward sounds good. Although, I'd prefer if we right away consider also #170577 as that helps flattening our dependency tree, especially now since CA-derivations are well under way.

However, a more popular option, and the current default format in nixpkgs is setuptools. Luckily, we might still be able to build these packages with format = "pyproject" because pyproject.toml falls back to using setuptools as its build backend as documented by pypa even if the package doesn't have a pyproject.toml. This might actually be preferred, because I ran into issues with format = "setuptools" when trying to package a setup.py package.

We no longer use pip during build/install.

@pbsds
Copy link
Contributor

pbsds commented Sep 4, 2023

A good chance to get rid of format = "flit".

I actually have a half decent pr to that end which I've yet to push. The only major blocker is the list of overrides defined by poetry2nix, which is massive.

@figsoda
Copy link
Member Author

figsoda commented Sep 9, 2023

step 1: #254136

@FRidh
Copy link
Member

FRidh commented Sep 9, 2023

A good chance to get rid of format = "flit".

I actually have a half decent pr to that end which I've yet to push. The only major blocker is the list of overrides defined by poetry2nix, which is massive.

I'd like us to remove format flit as soon as possible.

@pbsds
Copy link
Contributor

pbsds commented Sep 9, 2023

I'd like us to remove format flit as soon as possible.

@mweinelt
Copy link
Member

mweinelt commented Sep 10, 2023

So format = "other" will be migrated to pyproject = false?

@figsoda
Copy link
Member Author

figsoda commented Sep 10, 2023

So format = "other" will be migrated to pyproject = false?

Yes, format = "pyproject" | "setuptools" will become pyproject = true, and everything else will become pyproject = false

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-init-generate-nix-packages-from-urls-with-hash-prefetching-dependency-inference-license-detection-and-more/25035/18

@yajo
Copy link
Contributor

yajo commented Sep 18, 2023

Would it make sense to be able to point to the pyproject.toml file directly? So Nix could:

  • Parse that TOML
  • Read its build-backend.requirements
  • If there's none, default to setuptools + wheel as PEP-518 explains.
  • Try to find them by name from the current python3.pkgs

Hopefully most derivation definitions could be dramatically simplified.

@FRidh
Copy link
Member

FRidh commented Sep 18, 2023

That would mean vendoring the pyproject.toml of projects in Nixpkgs since we do not want to have IFD.

n8henrie added a commit to n8henrie/pycookiecheat that referenced this issue Oct 1, 2023
adisbladis added a commit to adisbladis/nixpkgs that referenced this issue Dec 7, 2023
Long term we should move everything over to `pyproject = true`, but in
the mean time we can work towards deprecating the implicit `format` paremeter.

cc NixOS#253154
cc @mweinelt @figsoda
adisbladis added a commit to adisbladis/nixpkgs that referenced this issue Dec 7, 2023
Long term we should move everything over to `pyproject = true`, but in
the mean time we can work towards deprecating the implicit `format` paremeter.

cc NixOS#253154
cc @mweinelt @figsoda
adisbladis added a commit to adisbladis/nixpkgs that referenced this issue Dec 7, 2023
Long term we should move everything over to `pyproject = true`, but in
the mean time we can work towards deprecating the implicit `format` paremeter.

cc NixOS#253154
cc @mweinelt @figsoda
mweinelt pushed a commit that referenced this issue Dec 7, 2023
Long term we should move everything over to `pyproject = true`, but in
the mean time we can work towards deprecating the implicit `format` paremeter.

cc #253154
cc @mweinelt @figsoda
@KUD-00 KUD-00 mentioned this issue Dec 13, 2023
13 tasks
kira-bruneau pushed a commit to kira-bruneau/nur-packages that referenced this issue Dec 14, 2023
Long term we should move everything over to `pyproject = true`, but in
the mean time we can work towards deprecating the implicit `format` paremeter.

cc NixOS/nixpkgs#253154
cc @mweinelt @figsoda
dansbandit pushed a commit to dansbandit/nixpkgs that referenced this issue Dec 27, 2023
Long term we should move everything over to `pyproject = true`, but in
the mean time we can work towards deprecating the implicit `format` paremeter.

cc NixOS#253154
cc @mweinelt @figsoda
@rafameou rafameou mentioned this issue Mar 13, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants