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

mkPythonMetaPackage: init meta package function (and psycopg2-binary) #337621

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

adisbladis
Copy link
Member

@adisbladis adisbladis commented Aug 27, 2024

Description of changes

Adds a function mkPythonMetaPackage that exists to satisfy a dependency on a package, but don't actually build it.
This is useful for packages that have a split binary/source dichotomy like psycopg2/psycopg2-binary, where we want to use the former, but some projects declare a dependency on the latter.

This PR:

  • Create a mkPythonMetaPackage function
  • Adds a new package psycopg2-binary that uses it

Override hacks could be dropped from:

  • irrd
  • pretix
  • vwsfriend
  • aiopg
  • dbt-postgres
  • llama-index-vector-stores-postgres
  • patator
  • fit-trackee

cc @misuzu nix-community/pyproject.nix#143

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Copy link
Contributor

@misuzu misuzu left a comment

Choose a reason for hiding this comment

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

Thanks! This seems to work

Copy link
Member

@dotlambda dotlambda left a comment

Choose a reason for hiding this comment

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

Very nice!
I wonder if it would make sense to turn this into a function to produce such a package that could also be used for e.g. https://pypi.org/project/phonenumberslite/

@adisbladis
Copy link
Member Author

Very nice! I wonder if it would make sense to turn this into a function to produce such a package that could also be used for e.g. https://pypi.org/project/phonenumberslite/

Good idea! I've added a mkPythonMetaPackage function to the Python set and changed psycopg2-binary to use it.

@adisbladis adisbladis changed the title python3Packages.psycopg2-binary: init at 2.9.9 mkPythonMetaPackage: init meta package function (and psycopg2-binary) Aug 29, 2024
This function exists create a meta package containing [metadata files](https://packaging.python.org/en/latest/specifications/recording-installed-packages/) to satisfy a dependency on a package, without it actually having been installed into the environment.
Pscycopg2-binary is normally used in Python development to avoid having to build psycopg2 from source.
In nixpkgs we always want ot build from source whenever possible, but it can still be useful to provide a psycopg2-binary package.

This "fake" package exists to satisfy a dependency on psycopg2-binary, but still use the build from psycopg2.

cc @misuzu nix-community/pyproject.nix#143
@dotlambda dotlambda merged commit c3925f7 into NixOS:master Aug 30, 2024
23 checks passed
adisbladis added a commit to adisbladis/nixpkgs that referenced this pull request Aug 30, 2024
In NixOS#337621 I had initially
created an empty, but importable package, meaning that initial
tests worked just fine, because the top_level.txt file is always
created when an importable package exists.

Subsequent refactors removed the importable package, but didn't verify
that the dependency satisfaction still works, only that the
metadata output looked good.

It was a bit tricky to express what I wanted to with hatchling, so I switched to setuptools.
adisbladis added a commit to adisbladis/nixpkgs that referenced this pull request Aug 30, 2024
In NixOS#337621 I had initially
created an empty, but importable package, meaning that initial
tests worked just fine.

Subsequent refactors removed the importable package, but didn't verify
that the dependency satisfaction still works, only that the
metadata output looked good.
@adisbladis adisbladis deleted the psycopg2-binary branch August 30, 2024 03:28
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.

4 participants