Skip to content

Commit

Permalink
poetry2nix: 1.17.1 -> 1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adisbladis authored and zhenyavinogradov committed Sep 10, 2021
1 parent fd0ff62 commit 1714a2e
Show file tree
Hide file tree
Showing 11 changed files with 391 additions and 168 deletions.
2 changes: 1 addition & 1 deletion pkgs/development/tools/poetry2nix/poetry2nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}:
let
# Poetry2nix version
version = "1.17.1";
version = "1.19.0";

inherit (poetryLib) isCompatible readTOML moduleName;

Expand Down
29 changes: 23 additions & 6 deletions pkgs/development/tools/poetry2nix/poetry2nix/fetch_from_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# https://discuss.python.org/t/pip-download-just-the-source-packages-no-building-no-metadata-etc/4651/12

import sys
from urllib.parse import urlparse
from urllib.parse import urlparse, urlunparse
from html.parser import HTMLParser
import urllib.request
import shutil
import ssl
import os
from os.path import normpath


# Parse the legacy index page to extract the href and package names
Expand Down Expand Up @@ -44,9 +44,13 @@ def handle_endtag(self, tag):

print("Reading index %s" % index_url)

context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE

response = urllib.request.urlopen(
index_url,
context=ssl.CERT_NONE)
context=context)
index = response.read()

parser = Pep503()
Expand All @@ -62,11 +66,24 @@ def handle_endtag(self, tag):
package_url = index_url + "/" + parser.sources[package_filename]
else:
package_url = parser.sources[package_filename]
print("Downloading %s" % package_url)

# Handle urls containing "../"
parsed_url = urlparse(package_url)
real_package_url = urlunparse(
(
parsed_url.scheme,
parsed_url.netloc,
normpath(parsed_url.path),
parsed_url.params,
parsed_url.query,
parsed_url.fragment,
)
)
print("Downloading %s" % real_package_url)

response = urllib.request.urlopen(
package_url,
context=ssl.CERT_NONE)
real_package_url,
context=context)

with response as r:
shutil.copyfileobj(r, package_file)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pipBuildPhase() {

mkdir -p dist
echo "Creating a wheel..."
@pythonInterpreter@ -m pip wheel --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 .
echo "Finished creating a wheel..."

runHook postBuild
Expand Down
16 changes: 11 additions & 5 deletions pkgs/development/tools/poetry2nix/poetry2nix/mk-poetry-dep.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ pythonPackages.callPackage
isSource = source != null;
isGit = isSource && source.type == "git";
isUrl = isSource && source.type == "url";
isLocal = isSource && source.type == "directory";
isDirectory = isSource && source.type == "directory";
isFile = isSource && source.type == "file";
isLegacy = isSource && source.type == "legacy";
localDepPath = toPath source.url;

Expand All @@ -71,7 +72,10 @@ pythonPackages.callPackage
sourceDist = builtins.filter isSdist fileCandidates;
eggs = builtins.filter isEgg fileCandidates;
entries = (if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs;
lockFileEntry = builtins.head entries;
lockFileEntry = (
if lib.length entries > 0 then builtins.head entries
else throw "Missing suitable source/wheel file entry for ${name}"
);
_isEgg = isEgg lockFileEntry;
in
rec {
Expand All @@ -94,7 +98,7 @@ pythonPackages.callPackage
"toml" # Toml is an extra for setuptools-scm
];
baseBuildInputs = lib.optional (! lib.elem name skipSetupToolsSCM) pythonPackages.setuptools-scm;
format = if isLocal || isGit || isUrl then "pyproject" else fileInfo.format;
format = if isDirectory || isGit || isUrl then "pyproject" else fileInfo.format;
in
buildPythonPackage {
pname = moduleName name;
Expand All @@ -118,7 +122,7 @@ pythonPackages.callPackage
baseBuildInputs
++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) pythonPackages.setuptools
++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg
++ lib.optional isLocal buildSystemPkgs
++ lib.optional isDirectory buildSystemPkgs
++ lib.optional (!__isBootstrap) pythonPackages.poetry
);

Expand Down Expand Up @@ -170,8 +174,10 @@ pythonPackages.callPackage
{
inherit (source) url;
}
else if isLocal then
else if isDirectory then
(poetryLib.cleanPythonSources { src = localDepPath; })
else if isFile then
localDepPath
else if isLegacy then
fetchFromLegacy
{
Expand Down
92 changes: 90 additions & 2 deletions pkgs/development/tools/poetry2nix/poetry2nix/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ self: super:
}
);

anyio = super.anyio.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace 'setup()' 'setup(version="${old.version}")'
'';
});

arpeggio = super.arpeggio.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
}
);

astroid = super.astroid.overridePythonAttrs (
old: rec {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
Expand All @@ -68,6 +80,14 @@ self: super:
}
);

backports-entry-points-selectable = super.backports-entry-points-selectable.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace \
'setuptools.setup()' \
'setuptools.setup(version="${old.version}")'
'';
});

bcrypt = super.bcrypt.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.libffi ];
Expand Down Expand Up @@ -493,7 +513,7 @@ self: super:
old: {
inherit (pkgs.python3Packages.jira) patches;
buildInputs = (old.buildInputs or [ ]) ++ [
self.pytest-runner
self.pytestrunner
self.cryptography
self.pyjwt
];
Expand Down Expand Up @@ -620,7 +640,8 @@ self: super:

buildInputs = (old.buildInputs or [ ])
++ lib.optional enableGhostscript pkgs.ghostscript
++ lib.optional stdenv.isDarwin [ Cocoa ];
++ lib.optional stdenv.isDarwin [ Cocoa ]
++ [ self.certifi ];

nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
pkgs.pkg-config
Expand Down Expand Up @@ -962,6 +983,7 @@ self: super:
];

PYARROW_BUILD_TYPE = "release";
PYARROW_WITH_DATASET = true;
PYARROW_WITH_PARQUET = true;
PYARROW_CMAKE_OPTIONS = [
"-DCMAKE_INSTALL_RPATH=${ARROW_HOME}/lib"
Expand Down Expand Up @@ -1263,6 +1285,8 @@ self: super:
}
);

pytest-runner = super.pytest-runner or super.pytestrunner;

pytest-pylint = super.pytest-pylint.overridePythonAttrs (
old: {
buildInputs = [ self.pytest-runner ];
Expand Down Expand Up @@ -1372,6 +1396,16 @@ self: super:
}
);

requests-unixsocket = super.requests-unixsocket.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pbr ];
}
);

requestsexceptions = super.requestsexceptions.overridePythonAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ self.pbr ];
});

rlp = super.rlp.overridePythonAttrs {
preConfigure = ''
substituteInPlace setup.py --replace \'setuptools-markdown\' ""
Expand Down Expand Up @@ -1831,4 +1865,58 @@ self: super:
'';
});

marisa-trie = super.marisa-trie.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
}
);

ua-parser = super.ua-parser.overridePythonAttrs (
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pyyaml ];
}
);

lazy-object-proxy = super.lazy-object-proxy.overridePythonAttrs (
old: {
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);

pendulum = super.pendulum.overridePythonAttrs (old: {
# Technically incorrect, but fixes the build error..
preInstall = lib.optionalString stdenv.isLinux ''
mv ./dist/*.whl $(echo ./dist/*.whl | sed s/'manylinux_[0-9]*_[0-9]*'/'manylinux1'/)
'';
});

pygraphviz = super.pygraphviz.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.graphviz ];
});

pyjsg = super.pyjsg.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});

pyshex = super.pyshex.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});

pyshexc = super.pyshexc.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});

shexjsg = super.shexjsg.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});

sparqlslurper = super.sparqlslurper.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});

tomli = super.tomli.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
});
}
3 changes: 2 additions & 1 deletion pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ let
mVal = ''[a-zA-Z0-9\'"_\. \-]+'';
mOp = "in|[!=<>]+";
e = stripStr exprs.value;
m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e);
m' = builtins.match ''^(${mVal}) +(${mOp}) *(${mVal})$'' e;
m = builtins.map stripStr (if m' != null then m' else builtins.match ''^(${mVal}) +(${mOp}) *(${mVal})$'' e);
m0 = processVar (builtins.elemAt m 0);
m2 = processVar (builtins.elemAt m 2);
in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{ lib, poetry2nix, python, fetchFromGitHub }:
{ lib
, poetry2nix
, python
, fetchFromGitHub
, projectDir ? ./.
, pyproject ? projectDir + "/pyproject.toml"
, poetrylock ? projectDir + "/poetry.lock"
}:


poetry2nix.mkPoetryApplication {

inherit python;

projectDir = ./.;
inherit projectDir pyproject poetrylock;

# Don't include poetry in inputs
__isBootstrap = true;
Expand Down
Loading

0 comments on commit 1714a2e

Please sign in to comment.