Skip to content

Commit

Permalink
Reformat with nixpkgs-fmt 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adisbladis committed Oct 1, 2020
1 parent f218d27 commit 52a484b
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 227 deletions.
7 changes: 4 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ lib.makeScope pkgs.newScope (self: {
) { inherit app; };
};

meta = lib.optionalAttrs (lib.hasAttr "description" pyProject.tool.poetry) {
inherit (pyProject.tool.poetry) description;
} // lib.optionalAttrs (lib.hasAttr "homepage" pyProject.tool.poetry) {
meta = lib.optionalAttrs (lib.hasAttr "description" pyProject.tool.poetry)
{
inherit (pyProject.tool.poetry) description;
} // lib.optionalAttrs (lib.hasAttr "homepage" pyProject.tool.poetry) {
inherit (pyProject.tool.poetry) homepage;
} // {
inherit (py.meta) platforms;
Expand Down
35 changes: 18 additions & 17 deletions editable.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,26 @@ let
# A python package that contains simple .egg-info and .pth files for an editable installation
editablePackage = python.pkgs.toPythonModule (pkgs.runCommandNoCC "${name}-editable"
{ } ''
mkdir -p "$out/${python.sitePackages}"
cd "$out/${python.sitePackages}"
mkdir -p "$out/${python.sitePackages}"
cd "$out/${python.sitePackages}"
# See https://docs.python.org/3.8/library/site.html for info on such .pth files
# These add another site package path for each line
touch poetry2nix-editable.pth
${lib.concatMapStringsSep "\n" (src: ''
echo "${toString src}" >> poetry2nix-editable.pth
'')
(lib.attrValues editablePackageSources)}
# See https://docs.python.org/3.8/library/site.html for info on such .pth files
# These add another site package path for each line
touch poetry2nix-editable.pth
${lib.concatMapStringsSep "\n"
(src: ''
echo "${toString src}" >> poetry2nix-editable.pth
'')
(lib.attrValues editablePackageSources)}
# Create a very simple egg so pkg_resources can find this package
# See https://setuptools.readthedocs.io/en/latest/formats.html for more info on the egg format
mkdir "${name}.egg-info"
cd "${name}.egg-info"
ln -s ${pkgInfoFile} PKG-INFO
${lib.optionalString (pyProject.tool.poetry ? plugins) ''
ln -s ${entryPointsFile} entry_points.txt
''}
# Create a very simple egg so pkg_resources can find this package
# See https://setuptools.readthedocs.io/en/latest/formats.html for more info on the egg format
mkdir "${name}.egg-info"
cd "${name}.egg-info"
ln -s ${pkgInfoFile} PKG-INFO
${lib.optionalString (pyProject.tool.poetry ? plugins) ''
ln -s ${entryPointsFile} entry_points.txt
''}
''
);
in
Expand Down
12 changes: 8 additions & 4 deletions hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ in
pyprojectPatchScript = "${./pyproject-without-path.py}";
};
} ./remove-path-dependencies.sh
) { };
)
{ };

pipBuildHook = callPackage
(
Expand All @@ -37,7 +38,8 @@ in
inherit pythonInterpreter pythonSitePackages;
};
} ./pip-build-hook.sh
) { };
)
{ };

poetry2nixFixupHook = callPackage
(
Expand All @@ -47,7 +49,8 @@ in
name = "fixup-hook.sh";
deps = [ ];
} ./fixup-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.
Expand All @@ -58,7 +61,8 @@ in
name = "wheel-unpack-hook.sh";
deps = [ ];
} ./wheel-unpack-hook.sh
) { };
)
{ };


}
3 changes: 2 additions & 1 deletion lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ let
+ "Add such a section as described in https://python-poetry.org/docs/pyproject/#poetry-and-pep-517";
requires = lib.attrByPath [ "build-system" "requires" ] (throw missingBuildBackendError) pyProject;
requiredPkgs = builtins.map (n: lib.elemAt (builtins.match "([^!=<>~\[]+).*" n) 0) requires;
in builtins.map (drvAttr: pythonPackages.${drvAttr} or (throw "unsupported build system requirement ${drvAttr}")) requiredPkgs;
in
builtins.map (drvAttr: pythonPackages.${drvAttr} or (throw "unsupported build system requirement ${drvAttr}")) requiredPkgs;

# Find gitignore files recursively in parent directory stopping with .git
findGitIgnores = path:
Expand Down
27 changes: 16 additions & 11 deletions mk-poetry-dep.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ pythonPackages.callPackage
pyProjectPath = localDepPath + "/pyproject.toml";
pyProject = poetryLib.readTOML pyProjectPath;
in
if builtins.pathExists pyProjectPath then poetryLib.getBuildSystemPkgs {
inherit pythonPackages pyProject;
} else [ ];
if builtins.pathExists pyProjectPath then
poetryLib.getBuildSystemPkgs
{
inherit pythonPackages pyProject;
} else [ ];

fileInfo =
let
Expand Down Expand Up @@ -151,15 +153,18 @@ pythonPackages.callPackage
# Interpreters should declare what wheel types they're compatible with (python type + ABI)
# Here we can then choose a file based on that info.
src =
if isGit then (
builtins.fetchGit {
inherit (source) url;
rev = source.reference;
ref = sourceSpec.branch or sourceSpec.rev or sourceSpec.tag or "HEAD";
}
) else if isLocal then (poetryLib.cleanPythonSources { src = localDepPath; }) else fetchFromPypi {
if isGit then
(
builtins.fetchGit {
inherit (source) url;
rev = source.reference;
ref = sourceSpec.branch or sourceSpec.rev or sourceSpec.tag or "HEAD";
}
) else if isLocal then (poetryLib.cleanPythonSources { src = localDepPath; }) else
fetchFromPypi {
pname = name;
inherit (fileInfo) file hash kind;
};
}
) { }
)
{ }
8 changes: 5 additions & 3 deletions nix/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ let
$ niv modify <package> -a type=tarball -a builtin=true
''
builtins_fetchTarball { inherit (spec) url sha256; };
builtins_fetchTarball
{ inherit (spec) url sha256; };
fetch_builtin-url = spec:
builtins.trace
''
Expand Down Expand Up @@ -106,8 +107,9 @@ let
(
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
then
abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = fetch config.pkgs name spec; }
)
Expand Down
Loading

0 comments on commit 52a484b

Please sign in to comment.