python-language-server: init at 2020-04-24

wip/yesman
Tom McLaughlin 4 years ago committed by Frederik Rietdijk
parent 699563af7f
commit d963bf30f5
  1. 36
      pkgs/development/dotnet-modules/python-language-server/create_deps.sh
  2. 104
      pkgs/development/dotnet-modules/python-language-server/default.nix
  3. 1321
      pkgs/development/dotnet-modules/python-language-server/deps.nix
  4. 40
      pkgs/development/dotnet-modules/python-language-server/format-deps.sh
  5. 14
      pkgs/development/dotnet-modules/python-language-server/manual_deps.txt
  6. 37
      pkgs/development/dotnet-modules/python-language-server/process_lockfile.py
  7. 4
      pkgs/top-level/all-packages.nix

@ -0,0 +1,36 @@
#! /usr/bin/env nix-shell
#! nix-shell -p python3 dotnet-sdk_3 -i bash
# Run this script to generate deps.nix
# ./create_deps.sh /path/to/microsoft/python/language/server/source/checkout
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -d "$1" ]; then
CHECKOUT_PATH="$1"
else
echo "First argument must be a directory, the path to the Microsoft Python Language Server source checkout"
exit 1
fi
# Generate lockfiles in source checkout
cd $CHECKOUT_PATH/src
dotnet nuget locals all --clear
dotnet restore -v normal --no-cache PLS.sln --use-lock-file -r linux-x64
# Use the lockfiles to make a file with two columns: name and version number
# for all possible package dependencies
cd $SCRIPTDIR
echo "" > all_versions.txt
for lockfile in $(find "$CHECKOUT_PATH" -name packages.lock.json); do
echo "Processing lockfile $lockfile"
python ./process_lockfile.py "$lockfile" >> all_versions.txt
done
# Add extra manually added packages
cat ./manual_deps.txt >> all_versions.txt
cat all_versions.txt | sed '/^$/d' | sort | uniq > tmp
mv tmp all_versions.txt
# Retrieve sha256 hashes for each dependency and format fetchNuGet calls into deps.nix
./format-deps.sh all_versions.txt > deps.nix
rm all_versions.txt

@ -0,0 +1,104 @@
{ stdenv
, fetchFromGitHub
, fetchurl
, makeWrapper
, dotnet-sdk_3
, openssl
, icu
, patchelf
, Nuget
}:
let deps = import ./deps.nix { inherit fetchurl; };
version = "2020-04-24";
# Build the nuget source needed for the later build all by itself
# since it's a time-consuming step that only depends on ./deps.nix.
# This makes it easier to experiment with the main build.
nugetSource = stdenv.mkDerivation {
pname = "python-language-server-nuget-deps";
inherit version;
dontUnpack = true;
nativeBuildInputs = [ Nuget ];
buildPhase = ''
export HOME=$(mktemp -d)
mkdir -p $out/lib
# disable default-source so nuget does not try to download from online-repo
nuget sources Disable -Name "nuget.org"
# add all dependencies to the source
for package in ${toString deps}; do
nuget add $package -Source $out/lib
done
'';
dontInstall = true;
};
in
stdenv.mkDerivation {
pname = "python-language-server";
inherit version;
src = fetchFromGitHub {
owner = "microsoft";
repo = "python-language-server";
rev = "d480cd12649dcff78ed271c92c274fab60c00f2f";
sha256 = "0p2sw6w6fymdlxn8r5ndvija2l7rd77f5rddq9n71dxj1nicljh3";
};
buildInputs = [dotnet-sdk_3 openssl icu];
nativeBuildInputs = [
Nuget
makeWrapper
patchelf
];
buildPhase = ''
mkdir home
export HOME=$(mktemp -d)
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
pushd src
nuget sources Disable -Name "nuget.org"
dotnet restore --source ${nugetSource}/lib -r linux-x64
popd
pushd src/LanguageServer/Impl
dotnet publish --no-restore -c Release -r linux-x64
popd
'';
installPhase = ''
mkdir -p $out
cp -r output/bin/Release/linux-x64/publish $out/lib
mkdir $out/bin
makeWrapper $out/lib/Microsoft.Python.LanguageServer $out/bin/python-language-server
'';
postFixup = ''
patchelf --set-rpath ${icu}/lib $out/lib/System.Globalization.Native.so
patchelf --set-rpath ${openssl.out}/lib $out/lib/System.Security.Cryptography.Native.OpenSsl.so
'';
# If we don't disable stripping, the executable fails to start with an error about being unable
# to find some of the packaged DLLs.
dontStrip = true;
meta = with stdenv.lib; {
description = "Microsoft Language Server for Python";
homepage = "https://github.com/microsoft/python-language-server";
license = licenses.asl20;
maintainers = with maintainers; [ thomasjm ];
platforms = [ "x86_64-linux" ];
};
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,40 @@
#! /usr/bin/env nix-shell
#! nix-shell -p gawk nix -i bash
# Retrieve sha256 hashes for each dependency in and format fetchNuGet calls
echo "" > deps.nix
urlbase="https://www.nuget.org/api/v2/package"
cat << EOL
# This file is autogenerated.
# To regenerate, run "create_deps.sh \$PATH_TO_LANGUAGE_SERVER_CHECKOUT"
{ fetchurl }: let
fetchNuGet = { name, version, sha256 }: fetchurl {
inherit sha256;
url = "$urlbase/\${name}/\${version}";
};
in [
EOL
IFS=''
while read line; do
name=$(echo $line | awk '{print $1}')
version=$(echo $line | awk '{print $2}')
sha256=$(nix-prefetch-url "$urlbase/$name/$version" 2>/dev/null)
if [ -n "$sha256" ]; then
cat << EOL
(fetchNuGet {
name = "$name";
version = "$version";
sha256 = "$sha256";
})
EOL
fi
done < $1
cat << EOL
]
EOL

@ -0,0 +1,14 @@
Microsoft.AspNetCore.App.Runtime.linux-x64 3.1.3
Microsoft.AspNetCore.App.Ref 3.0.1
Microsoft.AspNetCore.App.Runtime.linux-x64 3.1.2
Microsoft.AspNetCore.App.Runtime.linux-x64 3.0.3
Microsoft.AspNetCore.App.Runtime.linux-x64 3.0.2
Microsoft.NetCore.App.Ref 3.1.0
Microsoft.NetCore.App.Ref 3.0.0
Microsoft.NetCore.App.Runtime.linux-x64 3.1.3
Microsoft.NetCore.App.Runtime.linux-x64 3.1.2
Microsoft.NetCore.App.Runtime.linux-x64 3.0.2
Microsoft.NetCore.App.Runtime.linux-x64 3.0.3
Microsoft.NetCore.App.Host.linux-x64 3.1.3
Microsoft.NetCore.App.Host.linux-x64 3.0.2
Microsoft.NetCore.App.Host.linux-x64 3.0.3

@ -0,0 +1,37 @@
#!/usr/bin/python
import json
import sys
def process_section(name, section):
packages = set()
if "resolved" in section:
packages.add((name, section["resolved"]))
if "dependencies" in section:
for name in section["dependencies"]:
packages.add((name, section["dependencies"][name]))
return packages
def main():
with open(sys.argv[1], 'r') as f:
tree = json.loads(f.read())
packages = set()
topDependencies = tree["dependencies"]
for area in topDependencies:
for name in topDependencies[area]:
packages = packages.union(process_section(name, topDependencies[area][name]))
for (name, version) in packages:
print("%s %s" % (name, version))
if __name__ == "__main__":
main()

@ -10559,6 +10559,10 @@ in
mdl = callPackage ../development/tools/misc/mdl { };
python-language-server = callPackage ../development/dotnet-modules/python-language-server {
inherit (dotnetPackages) Nuget;
};
minify = callPackage ../development/web/minify { };
minizinc = callPackage ../development/tools/minizinc { };

Loading…
Cancel
Save