Skip to content

Commit

Permalink
Solve case for empty restrictions - references #462
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Dec 27, 2014
1 parent f9cf1b2 commit de378c7
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 31 deletions.
67 changes: 38 additions & 29 deletions src/Paket.Core/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,48 @@ let optimizeRestrictions packages =
yield r,packages |> Seq.map (fun (n,v,_) -> n,v) |> Seq.toList
| _ -> () ]


let emptyRestrictions =
[for (n,vr,r:FrameworkRestrictions) in packages do
if r = [] then
yield n,vr]
|> Set.ofList

[for (name,versionRequirement:VersionRequirement),group in grouped do
if name <> PackageName "" then
let plain =
group
|> Seq.map (fun (_,_,res) -> res)
|> Seq.concat
|> Seq.toList

let localMaxDotNetRestriction = findMaxDotNetRestriction plain


let restrictions =
plain
|> List.map (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly r ->
if r = localMaxDotNetRestriction then
let globalMax =
invertedRestrictions
|> Seq.skipWhile (fun (r,l) -> r <= localMaxDotNetRestriction && l |> List.exists (fun (n,vr) -> n = name && vr = versionRequirement))
|> Seq.map fst
|> Seq.toList

if globalMax = [] || r >= globalMax.Head then
FrameworkRestriction.AtLeast r
if not (Set.isEmpty emptyRestrictions) && Set.contains (name,versionRequirement) emptyRestrictions then
yield name,versionRequirement,[]
else
let plain =
group
|> Seq.map (fun (_,_,res) -> res)
|> Seq.concat
|> Seq.toList

let localMaxDotNetRestriction = findMaxDotNetRestriction plain

let restrictions =
plain
|> List.map (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly r ->
if r = localMaxDotNetRestriction then
let globalMax =
invertedRestrictions
|> Seq.skipWhile (fun (r,l) -> r <= localMaxDotNetRestriction && l |> List.exists (fun (n,vr) -> n = name && vr = versionRequirement))
|> Seq.map fst
|> Seq.toList

if globalMax = [] || r >= globalMax.Head then
FrameworkRestriction.AtLeast r
else
FrameworkRestriction.Between(r,globalMax.Head)
else
FrameworkRestriction.Between(r,globalMax.Head)
else
restriction
| _ -> restriction)
|> Seq.toList
restriction
| _ -> restriction)
|> Seq.toList

yield name,versionRequirement,restrictions]
yield name,versionRequirement,restrictions]

type PackageRequirementSource =
| DependenciesFile of string
Expand Down
18 changes: 18 additions & 0 deletions tests/Paket.Tests/NuGetOData/Math.Numerics.FSharp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?><feed xml:base="http://www.nuget.org/api/v2/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><id>http://www.nuget.org/api/v2/Packages</id><title type="text">Packages</title><updated>2014-12-27T14:02:57Z</updated><link rel="self" title="Packages" href="Packages" /><entry><id>http://www.nuget.org/api/v2/Packages(Id='MathNet.Numerics.FSharp',Version='3.3.0')</id><category term="NuGetGallery.V2FeedPackage" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" title="V2FeedPackage" href="Packages(Id='MathNet.Numerics.FSharp',Version='3.3.0')" /><title type="text">MathNet.Numerics.FSharp</title><summary type="text">F# Modules for Math.NET Numerics, providing methods and algorithms for numerical computations in science, engineering and every day use.</summary><updated>2014-12-27T11:17:08Z</updated><author><name>Christoph Ruegg, Marcus Cuda, Jurgen Van Gael</name></author><link rel="edit-media" title="V2FeedPackage" href="Packages(Id='MathNet.Numerics.FSharp',Version='3.3.0')/$value" /><content type="application/zip" src="http://www.nuget.org/api/v2/package/MathNet.Numerics.FSharp/3.3.0" /><m:properties><d:Version>3.3.0</d:Version><d:NormalizedVersion>3.3.0</d:NormalizedVersion><d:Copyright m:null="true" /><d:Created m:type="Edm.DateTime">2014-11-26T14:55:45.747</d:Created><d:Dependencies>MathNet.Numerics:[3.3.0]:|FSharp.Core.Microsoft.Signed:3.1.1.1:|MathNet.Numerics:[3.3.0]:net35|MathNet.Numerics:[3.3.0]:net40|FSharp.Core.Microsoft.Signed:3.1.1.1:net40</d:Dependencies><d:Description>Math.NET Numerics is the numerical foundation of the Math.NET project, aiming to provide methods and algorithms for numerical computations in science, engineering and every day use. Supports F# 3.0 on .Net 4.0, .Net 3.5 and Mono on Windows, Linux and Mac; Silverlight 5 and Windows 8 with PCL portable profile 47; Android/iOS with Xamarin.</d:Description><d:DownloadCount m:type="Edm.Int32">11262</d:DownloadCount><d:GalleryDetailsUrl>http://www.nuget.org/packages/MathNet.Numerics.FSharp/3.3.0</d:GalleryDetailsUrl><d:IconUrl>http://www.mathdotnet.com/images/MathNet128.png</d:IconUrl><d:IsLatestVersion m:type="Edm.Boolean">true</d:IsLatestVersion><d:IsAbsoluteLatestVersion m:type="Edm.Boolean">true</d:IsAbsoluteLatestVersion><d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease><d:Language m:null="true" /><d:Published m:type="Edm.DateTime">2014-11-26T14:55:45.747</d:Published><d:PackageHash>vIhjPNbCIakonRE18xYJ1xLsV0s/LxONkOdKIutOayt+BiPvnP2J5+x+YD0IUr3BZRlIusNtzKgsPh2wBAxWKA==</d:PackageHash><d:PackageHashAlgorithm>SHA512</d:PackageHashAlgorithm><d:PackageSize m:type="Edm.Int64">424094</d:PackageSize><d:ProjectUrl>http://numerics.mathdotnet.com/</d:ProjectUrl><d:ReportAbuseUrl>http://www.nuget.org/package/ReportAbuse/MathNet.Numerics.FSharp/3.3.0</d:ReportAbuseUrl><d:ReleaseNotes>Linear Algebra: Vector.Fold2 (fold2 in F#), storage optimized
Linear Algebra: Minor change how matrix products call the LA provider
Linear Algebra: Random generation now leveraging array sampling routines
Linear Algebra: fix bug when manually assigning System.Random to random distribution
Root Finding: Change Brent tolerance check, add bracked check ~Hythen Sidky
Root Finding: Auto zero-crossing bracketing in FindRoots facade (not in algorithms)
Statistics: RootMeanSquare (RMS)
Distributions: Array sampling routines now available through interface
Distributions: Categorical sampling now explicitly skips p=0 categories
Generate: leverage array sampling routines for random data generation
Generate: square, triangle and sawtooth waves
Distance: Jaccard Index
F#: explicitly depend on official FSharp.Core NuGet packages
F#: NuGet package with iPython IfSharp F# module integration load script
F#: load scripts with better packet support (and NuGet with -ExcludeVersion)
Build: unified build.sh and buildn.sh into combined build.sh
Build: use Paket instead of NuGet to maintain NuGet dependencies
Build: for core add PCL profiles 7, 78 and 259; for F# extensions drop PCL profile 328</d:ReleaseNotes><d:RequireLicenseAcceptance m:type="Edm.Boolean">false</d:RequireLicenseAcceptance><d:Tags>fsharp F# math numeric statistics probability integration interpolation regression solve fit linear algebra matrix fft</d:Tags><d:Title>Math.NET Numerics for F#</d:Title><d:VersionDownloadCount m:type="Edm.Int32">230</d:VersionDownloadCount><d:MinClientVersion m:null="true" /><d:LastEdited m:type="Edm.DateTime" m:null="true" /><d:LicenseUrl>http://numerics.mathdotnet.com/docs/License.html</d:LicenseUrl><d:LicenseNames m:null="true" /><d:LicenseReportUrl m:null="true" /></m:properties></entry></feed>
7 changes: 7 additions & 0 deletions tests/Paket.Tests/NuGetOData/ODataSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ let ``can detect explicit dependencies for Math.Numerics``() =
[FrameworkRestriction.Between(DotNetFramework(FrameworkVersion.V3_5),DotNetFramework(FrameworkVersion.V4_Client))]]
SourceUrl = fakeUrl }

[<Test>]
let ``can detect explicit dependencies for Math.Numerics.FSharp``() =
(parse "NuGetOData/Math.Numerics.FSharp.xml").Dependencies |> Seq.head
|> shouldEqual
(PackageName "MathNet.Numerics",
DependenciesFileParser.parseVersionRequirement("3.3.0"),[])

[<Test>]
let ``can calculate v3 path``() =
calculateNuGet3Path "https://nuget.org/api/v2" |> shouldEqual (Some "http://preview.nuget.org/ver3-preview/index.json")
Expand Down
51 changes: 51 additions & 0 deletions tests/Paket.Tests/Nuspec/MathNet.Numerics.FSharp.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>MathNet.Numerics.FSharp</id>
<version>3.3.0</version>
<title>Math.NET Numerics for F#</title>
<authors>Christoph Ruegg, Marcus Cuda, Jurgen Van Gael</authors>
<owners>Christoph Ruegg, Marcus Cuda, Jurgen Van Gael</owners>
<licenseUrl>http://numerics.mathdotnet.com/docs/License.html</licenseUrl>
<projectUrl>http://numerics.mathdotnet.com/</projectUrl>
<iconUrl>http://www.mathdotnet.com/images/MathNet128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Math.NET Numerics is the numerical foundation of the Math.NET project, aiming to provide methods and algorithms for numerical computations in science, engineering and every day use. Supports F# 3.0 on .Net 4.0, .Net 3.5 and Mono on Windows, Linux and Mac; Silverlight 5 and Windows 8 with PCL portable profile 47; Android/iOS with Xamarin.</description>
<summary>F# Modules for Math.NET Numerics, providing methods and algorithms for numerical computations in science, engineering and every day use.</summary>
<releaseNotes>Linear Algebra: Vector.Fold2 (fold2 in F#), storage optimized
Linear Algebra: Minor change how matrix products call the LA provider
Linear Algebra: Random generation now leveraging array sampling routines
Linear Algebra: fix bug when manually assigning System.Random to random distribution
Root Finding: Change Brent tolerance check, add bracked check ~Hythen Sidky
Root Finding: Auto zero-crossing bracketing in FindRoots facade (not in algorithms)
Statistics: RootMeanSquare (RMS)
Distributions: Array sampling routines now available through interface
Distributions: Categorical sampling now explicitly skips p=0 categories
Generate: leverage array sampling routines for random data generation
Generate: square, triangle and sawtooth waves
Distance: Jaccard Index
F#: explicitly depend on official FSharp.Core NuGet packages
F#: NuGet package with iPython IfSharp F# module integration load script
F#: load scripts with better packet support (and NuGet with -ExcludeVersion)
Build: unified build.sh and buildn.sh into combined build.sh
Build: use Paket instead of NuGet to maintain NuGet dependencies
Build: for core add PCL profiles 7, 78 and 259; for F# extensions drop PCL profile 328</releaseNotes>
<tags>fsharp F# math numeric statistics probability integration interpolation regression solve fit linear algebra matrix fft</tags>
<dependencies>
<group>
<dependency id="MathNet.Numerics" version="[3.3.0]" />
<dependency id="FSharp.Core.Microsoft.Signed" version="3.1.1.1" />
</group>
<group targetFramework=".NETFramework3.5">
<dependency id="MathNet.Numerics" version="[3.3.0]" />
</group>
<group targetFramework=".NETFramework4.0">
<dependency id="MathNet.Numerics" version="[3.3.0]" />
<dependency id="FSharp.Core.Microsoft.Signed" version="3.1.1.1" />
</group>
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Numerics" targetFramework=".NETFramework4.0, Windows8.0, Silverlight5.0, MonoAndroid1.0, MonoTouch1.0" />
</frameworkAssemblies>
</metadata>
</package>
8 changes: 8 additions & 0 deletions tests/Paket.Tests/Nuspec/NuspecSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ let ``can detect dependencies for MathNet.Numerics``() =
DotNetFramework(FrameworkVersion.V3_5),
DotNetFramework(FrameworkVersion.V4_Client))] ]

[<Test>]
let ``can detect dependencies for MathNet.Numerics.FSharp``() =
Nuspec.Load("Nuspec/MathNet.Numerics.FSharp.nuspec").Dependencies
|> Seq.head
|> shouldEqual
(PackageName "MathNet.Numerics",
DependenciesFileParser.parseVersionRequirement("3.3.0"),[])

[<Test>]
let ``can detect explicit dependencies for WindowsAzure.Storage``() =
Nuspec.Load("Nuspec/WindowsAzure.Storage.nuspec").Dependencies
Expand Down
10 changes: 8 additions & 2 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -112,6 +112,9 @@
<Content Include="Nuspec\MathNet.Numerics.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Nuspec\MathNet.Numerics.FSharp.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Nuspec\WindowsAzure.Storage.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -128,13 +131,16 @@
<Content Include="NuGetOData\Math.Numerics.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="NuGetOData\Math.Numerics.FSharp.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="NuGetOData\Rx-PlatformServices.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Compile Include="NuGetOData\ODataSpecs.fs" />
<Content Include="NuGetOData\NUnit.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Compile Include="NuGetOData\ODataSpecs.fs" />
<Content Include="NuGetConfig\ClearTextPasswordConfig.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down

0 comments on commit de378c7

Please sign in to comment.