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

New bootstrap fixes #1329

Merged
merged 53 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7a5a573
chore: update nixpkgs to include python bootstrap rework
K900 Aug 28, 2023
65e5241
fix: remove overrides for everything involved in new bootstrap
K900 Aug 28, 2023
91e59e9
hack: rewrite all tests to use poetry-core
K900 Aug 28, 2023
dad0bb4
fix: rename uses of flit and add to packages that use it
sciyoshi Oct 1, 2023
03af324
get things working
sciyoshi Oct 3, 2023
d303ebb
chore: fix pyproject.tomls in tests
cpcloud Oct 22, 2023
8624024
chore: remove poetry from `pytest-metadata` test
cpcloud Oct 23, 2023
8aaf699
chore: relock utf8-pyproject test
cpcloud Oct 23, 2023
6761453
chore: fix python lower bound for git-deps-pinned
cpcloud Oct 23, 2023
85feb80
chore: add hooks
cpcloud Oct 23, 2023
2fbf946
chore: relock poetry itself
cpcloud Oct 23, 2023
b279a0f
chore: add hooks
cpcloud Oct 23, 2023
e035187
chore: checkpoint
cpcloud Oct 23, 2023
fce7cb4
chore: bring back the pypa build hook
cpcloud Oct 23, 2023
363e85f
chore: clean up tests; disable broken ones
cpcloud Oct 23, 2023
d1dbb1e
chore: manylinux is broken; part way through trying to fix it
cpcloud Oct 23, 2023
9316bf3
style: remove unnecessary parens
cpcloud Oct 24, 2023
6bb62c6
style: rename unused parameter
cpcloud Oct 24, 2023
34278c0
chore: remove dead import
cpcloud Oct 24, 2023
c17f130
test: get `trivial` test passing
cpcloud Oct 24, 2023
bad8f08
test: patch test to use poetry-core
cpcloud Oct 24, 2023
87c7794
chore: use pip build hook
cpcloud Oct 24, 2023
d5a2e6d
test(manylinux): test wheels instead of building from source
cpcloud Oct 24, 2023
ae2f682
chore: remove unused pip-install-hook.sh
cpcloud Oct 24, 2023
76d7d38
chore: remove more unused hooks
cpcloud Oct 24, 2023
b427aff
chore: remove vendored flit-core
cpcloud Oct 24, 2023
5682cf9
chore: remove vendored installer
cpcloud Oct 24, 2023
70ecc01
chore: remove vendored packaging
cpcloud Oct 24, 2023
7035e65
chore: remove vendored pyproject-hooks
cpcloud Oct 24, 2023
faa127b
chore: remove overridden check inputs
cpcloud Oct 24, 2023
44e8277
chore: remove vendored build package
cpcloud Oct 24, 2023
87ed113
chore: remove vendored tomli package
cpcloud Oct 24, 2023
880f0bd
chore: build bootstrapping packages using `pythonForBuild` to support…
cpcloud Oct 24, 2023
c8829ba
chore: revert opencv test to existing versions
cpcloud Oct 24, 2023
ba9716d
chore: sort build systems
cpcloud Oct 24, 2023
1810cc2
chore: use the correct python version for bootstrapping
cpcloud Oct 24, 2023
84db6c9
chore: fix jq for python311
cpcloud Oct 24, 2023
705cf90
chore: pin mutmut test to python310
cpcloud Oct 24, 2023
806eb84
chore: use poetry from upstream nixpkgs
cpcloud Oct 24, 2023
a86df00
ci: use nix commands
cpcloud Oct 24, 2023
8610d83
ci: use runner commands
cpcloud Oct 24, 2023
733412c
chore: use nix-shell
cpcloud Oct 25, 2023
b3d597d
chore: use exit 0 instead of YAML `true` constant
cpcloud Oct 25, 2023
6775f89
chore: do not fail fast in CI for nix-build jobs
cpcloud Oct 25, 2023
8463729
chore: build as far as possible
cpcloud Oct 25, 2023
eae09d1
chore: remove dead code
cpcloud Oct 25, 2023
e3d8509
fix(sphinx): get sphinx5+ working
cpcloud Oct 25, 2023
ad983b4
chore: fix pandas build that does not have pyproject.toml
cpcloud Oct 25, 2023
26e75e5
chore: fix psutil for darwin on newer nixpkgs
cpcloud Oct 25, 2023
321e0e9
chore: try against `nixpkgs/master`
cpcloud Oct 25, 2023
b251275
chore: pin psutil on mac
cpcloud Oct 25, 2023
3fe4315
chore: pin psutil in `scientific`
cpcloud Oct 25, 2023
93c345c
chore: pin ml-stack
cpcloud Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
use nix
use flake
watch_file ./nix/*
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- uses: actions/checkout@v4
- name: Check format
run: nix-shell --packages jq --pure --run 'diff --unified overrides/build-systems.json <(jq --from-file overrides/sort-build-systems.jq --raw-output --sort-keys < overrides/build-systems.json)'
run: nix-shell --packages jq diffutils --run "diff --unified overrides/build-systems.json <(jq --from-file overrides/sort-build-systems.jq --raw-output --sort-keys < overrides/build-systems.json)"

nixpkgs-fmt:
runs-on: ubuntu-latest
Expand All @@ -27,7 +27,7 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- uses: actions/checkout@v4
- name: Check format
run: nix-shell --arg packages 'pkgs:[ pkgs.nixpkgs-fmt ]' --run 'nixpkgs-fmt --check .'
run: nix run 'nixpkgs#nixpkgs-fmt' -- --check .

black-fmt:
runs-on: ubuntu-latest
Expand All @@ -41,7 +41,7 @@ jobs:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
- name: Check format
run: nix-shell --arg packages 'pkgs:[ pkgs.p2nix-tools.env ]' --run 'black --check .'
run: nix develop -c black --check .

nix-matrix:
runs-on: ubuntu-latest
Expand All @@ -60,15 +60,16 @@ jobs:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
fail-fast: false
matrix: ${{ fromJSON(needs.nix-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
- uses: cachix/cachix-action@v12
with:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
- run: nix build -L ".#${{ matrix.attr }}"
- run: nix build -L ".#${{ matrix.attr }}" --keep-going

collect:
runs-on: ubuntu-latest
Expand All @@ -78,4 +79,4 @@ jobs:
- nix-build
- sort-build-systems
steps:
- run: true
- run: exit 0
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ poetry2nix.mkPoetryApplication {
}
```

See [./pkgs/poetry/default.nix](./pkgs/poetry/default.nix) for a working example.

#### Dependency environment

The resulting derivation also has the passthru attribute `dependencyEnv`, which is an environment with a python interpreter, all non-development dependencies and your application.
Expand Down
6 changes: 0 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ lib.makeScope pkgs.newScope (self: {
};
getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn;

poetryPkg = pkgs.callPackage ./pkgs/poetry { inherit python; poetry2nix = self; };

scripts = pyProject.tool.poetry.scripts or { };
hasScripts = scripts != { };
scriptsPackage = self.mkPoetryScriptsPackage {
Expand Down Expand Up @@ -251,10 +249,6 @@ lib.makeScope pkgs.newScope (self: {
inherit lib python poetryLib evalPep508;
};

# # Use poetry-core from the poetry build (pep517/518 build-system)
poetry-core = poetryPkg.passthru.python.pkgs.poetry-core;
poetry = poetryPkg;

__toPluginAble = toPluginAble self;
} // lib.optionalAttrs (! super ? setuptools-scm) {
# The canonical name is setuptools-scm
Expand Down
20 changes: 10 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 48 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
description = "Poetry2nix flake";

inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/master";

inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, nix-github-actions }:
{
Expand All @@ -16,7 +20,7 @@
mkPkgs = system: import nixpkgs {
config = {
allowAliases = false;
allowInsecurePredicate = x: true;
allowInsecurePredicate = _: true;
};
overlays = [ self.overlay ];
inherit system;
Expand All @@ -40,7 +44,7 @@
# Aggregate all tests into one derivation so that only one GHA runner is scheduled for all darwin jobs
aggregate = pkgs.runCommand "darwin-aggregate"
{
env.TEST_INPUTS = (lib.concatStringsSep " " (lib.attrValues (lib.filterAttrs (n: v: lib.isDerivation v) tests)));
env.TEST_INPUTS = lib.concatStringsSep " " (lib.attrValues (lib.filterAttrs (_: v: lib.isDerivation v) tests));
} "touch $out";
};
};
Expand All @@ -53,24 +57,56 @@
};
default = self.templates.app;
};

} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs = import nixpkgs {
inherit system;
overlays = [
(_: _: {
p2nix-tools = pkgs.callPackage ./tools { };
})
];
config = {
allowAliases = false;
permittedInsecurePackages = [
"python3.8-requests-2.29.0"
"python3.8-cryptography-40.0.2"
"python3.9-requests-2.29.0"
"python3.9-cryptography-40.0.2"
"python3.10-requests-2.29.0"
"python3.10-cryptography-40.0.2"
"python3.11-requests-2.29.0"
"python3.11-cryptography-40.0.2"
];
};
};

poetry2nix = import ./default.nix { inherit pkgs; };
poetry = pkgs.callPackage ./pkgs/poetry { python = pkgs.python3; inherit poetry2nix; };
in
rec {
packages = {
inherit poetry;
poetry2nix = poetry2nix.cli;
default = poetry2nix.cli;
};

legacyPackages = poetry2nix;
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
p2nix-tools.env
p2nix-tools.flamegraph
nixpkgs-fmt
poetry
niv
jq
nix-prefetch-git
nix-eval-jobs
nix-build-uncached
];
};
};

apps = {
poetry = flake-utils.lib.mkApp { drv = packages.poetry; };
inherit (pkgs) poetry;
poetry2nix = flake-utils.lib.mkApp { drv = packages.poetry2nix; };
default = apps.poetry2nix;
};
Expand Down
45 changes: 7 additions & 38 deletions hooks/default.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
{ python
, stdenv
, buildPackages
, makeSetupHook
, wheel
, pip
, pkgs
, lib
,
}:
{ python, stdenv, makeSetupHook, pkgs, lib }:
let
inherit (python.pythonForBuild.pkgs) callPackage;
pythonInterpreter = python.pythonForBuild.interpreter;
inherit (python) pythonForBuild;
inherit (pythonForBuild.pkgs) callPackage;
pythonInterpreter = pythonForBuild.interpreter;
pythonSitePackages = python.sitePackages;

nonOverlayedPython = pkgs.python3.pythonForBuild.withPackages (ps: [ ps.tomlkit ]);
makeRemoveSpecialDependenciesHook =
{ fields
, kind
,
}:
makeRemoveSpecialDependenciesHook = { fields, kind }:
nonOverlayedPython.pkgs.callPackage
(
_:
Expand Down Expand Up @@ -57,10 +45,7 @@ in
pipBuildHook =
callPackage
(
{ pip
, wheel
,
}:
{ pip, wheel }:
makeSetupHook
({
name = "pip-build-hook.sh";
Expand Down Expand Up @@ -118,9 +103,7 @@ in
'';
};

pythonPath =
[ ]
++ lib.optional (lib.versionOlder python.version "3.9") unparser;
pythonPath = lib.optional (lib.versionOlder python.version "3.9") unparser;
in
makeSetupHook
{
Expand All @@ -133,18 +116,4 @@ in
./python-requires-patch-hook.sh
)
{ };

# When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion
# It doesn't _really_ depend on wheel though, it just copies the wheel.
wheelUnpackHook =
callPackage
(
_:
makeSetupHook
{
name = "wheel-unpack-hook.sh";
}
./wheel-unpack-hook.sh
)
{ };
}
14 changes: 12 additions & 2 deletions hooks/pip-build-hook.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# Setup hook to use for pip projects
echo "Sourcing pip-build-hook"

declare -a pipBuildFlags

pipBuildPhase() {
echo "Executing pipBuildPhase"
runHook preBuild

mkdir -p dist
echo "Creating a wheel..."
@pythonInterpreter@ -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .
@pythonInterpreter@ -m pip wheel \
--verbose \
--no-index \
--no-deps \
--no-clean \
--no-build-isolation \
--wheel-dir dist \
$pipBuildFlags .
echo "Finished creating a wheel..."

runHook postBuild
Expand All @@ -24,7 +33,8 @@ pipShellHook() {
export PATH="$tmp_path/bin:$PATH"
export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH"
mkdir -p "$tmp_path/@pythonSitePackages@"
@pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" >&2
@pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" \
--no-build-isolation >&2
fi

runHook postShellHook
Expand Down
21 changes: 10 additions & 11 deletions known-build-systems.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[
"poetry",
"poetry-core",
"flit",
"flit-core",
"pbr",
"flitBuildHook",
Copy link
Contributor

Choose a reason for hiding this comment

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

It's kinda hard to tell that this is the only line which changed without ignoring whitespace. Would it be possible to either move the whitespace change to a separate commit or omit it entirely?

"cython",
"hatchling",
"hatch-vcs",
"setuptools",
"setuptools-scm"
"poetry",
"poetry-core",
"flit",
"flit-core",
"pbr",
"cython",
"hatchling",
"hatch-vcs",
"setuptools",
"setuptools-scm"
]
Loading