FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add Redist-Linux NuGet script · MSavameri/TensorFlow.NET@b4aaa26 · GitHub

Repository navigation

Commit b4aaa26

Browse files
committed
add Redist-Linux NuGet script
1 parent 7780c25 commit b4aaa26

2 files changed

Lines changed: 176 additions & 3 deletions

File tree

‎src/SciSharp.TensorFlow.Redist/README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PM> Install-Package SciSharp.TensorFlow.Redist
1010

1111
* GPU version for Windows
1212
```powershell
13-
PM> Install-Package SciSharp.TensorFlow.Redist
13+
PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
1414
```
1515

1616
https://www.nuget.org/packages/SciSharp.TensorFlow.Redist
@@ -21,8 +21,7 @@ Related merged [commits](https://github.com/SciSharp/TensorFlow.NET/commit/854a5
2121

2222
On Windows, the tar command does not support extracting archives with symlinks. So when `dotnet pack` runs on Windows it will only package the Windows binaries.
2323

24-
1. Run `dotnet pack` under `src/SciSharp.TensorFlow.Redist` directory in Linux.
24+
1. Run `dotnet pack SciSharp.TensorFlow.Redist-CPU.nupkgproj` under `src/SciSharp.TensorFlow.Redist` directory in Linux.
2525
2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.1.14.0.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json`
2626

2727

28-
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<ProjDir>$(MSBuildThisFileDirectory)</ProjDir>
5+
<BinDir>$(ProjDir)bin\</BinDir>
6+
<ObjDir>$(ProjDir)obj\</ObjDir>
7+
8+
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
9+
<TargetFramework>netstandard2.0</TargetFramework>
10+
<TensorFlowVersion>1.14.0</TensorFlowVersion>
11+
<TensorFlowMajorVersion>1</TensorFlowMajorVersion>
12+
13+
<PackageAssetsPath>$(BinDir)packages\</PackageAssetsPath>
14+
<PackageId>$(MSBuildProjectName)</PackageId>
15+
<PackageVersion>$(TensorFlowVersion)</PackageVersion>
16+
17+
<NoBuild>true</NoBuild>
18+
<IncludeBuildOutput>false</IncludeBuildOutput>
19+
20+
<NuspecFile>Redist-Windows-GPU.nuspec</NuspecFile>
21+
<NuspecProperties>packageId=$(PackageId);version=$(PackageVersion)</NuspecProperties>
22+
<NuspecBasePath>$(ProjDir)</NuspecBasePath>
23+
24+
<GenerateNuspecDependsOn>CopyFilesFromArchive</GenerateNuspecDependsOn>
25+
26+
<PackageRid Condition="'$(OS)' == 'Windows_NT'">win</PackageRid>
27+
<PackageRid Condition="'$(OS)' != 'Windows_NT'">linux</PackageRid>
28+
<PackageRid Condition="$([MSBuild]::IsOSPlatform('osx'))">osx</PackageRid>
29+
<PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>
30+
31+
</PropertyGroup>
32+
33+
<PropertyGroup>
34+
<IncludeMLNetNotices>false</IncludeMLNetNotices>
35+
</PropertyGroup>
36+
37+
<ItemGroup>
38+
<TensorFlowConfig Condition="'$(OS)' != 'Windows_NT'"
39+
Include="linux"
40+
FileExtension=".tar.gz"
41+
FilesFromArchive="lib\libtensorflow.so;
42+
lib\libtensorflow_framework.so.$(TensorFlowMajorVersion);
43+
include\tensorflow\c\LICENSE"
44+
Runtime="linux-x64" />
45+
46+
<AdditionalDownloadFile Include="https://raw.githubusercontent.com/tensorflow/tensorflow/master/LICENSE"
47+
DownloadFile="$(BinDir)LICENSE" />
48+
</ItemGroup>
49+
50+
<Target Name="PrepareArchives">
51+
<ItemGroup>
52+
<!-- although we could extract all archives on all machines, mac requires a fixup which can only be run on mac
53+
so we split these per-rid and join during the official build packaging. -->
54+
<TensorFlowArchive
55+
Include="@(TensorFlowConfig->'https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-%(Identity)-x86_64-$(TensorFlowVersion)%(FileExtension)')" />
56+
<!-- set up metdata used by all targets -->
57+
<TensorFlowArchive DownloadFile="$(BinDir)%(FileName)%(Extension)"
58+
DownloadShaFile="$(BinDir)%(FileName)%(Extension).sha"
59+
ExtractDirectory="$(BinDir)%(FileName)"
60+
ExtractSemaphore="$(BinDir)%(FileName)\.extracted"
61+
LocalShaFile="$(MSBuildProjectDirectory)\%(FileName)%(Extension).sha"/>
62+
</ItemGroup>
63+
<Message Importance="high" Text="%(TensorFlowConfig.Runtime)"/>
64+
</Target>
65+
66+
<Target Name="DownloadArchives"
67+
DependsOnTargets="PrepareArchives"
68+
Inputs="$(MSBuildProjectFile)"
69+
Outputs="@(TensorFlowArchive->'%(DownloadFile)');@(AdditionalDownloadFile->'%(DownloadFile)')">
70+
<MakeDir Directories="$(BinDir)" />
71+
<ItemGroup>
72+
<_downloadFiles Include="@(TensorFlowArchive);@(AdditionalDownloadFile)" Url="%(Identity)" DestinationFile="%(DownloadFile)" />
73+
</ItemGroup>
74+
<Message Importance="High" Text="Downloading '%(_downloadFiles.Identity)' to '$(BinDir)'." />
75+
<DownloadFile SourceUrl="%(_downloadFiles.Identity)" DestinationFolder="$(BinDir)">
76+
<Output TaskParameter="DownloadedFile" ItemName="Content" />
77+
</DownloadFile>
78+
</Target>
79+
80+
81+
<Target Name="ValidateAndExtractArchives"
82+
DependsOnTargets="DownloadArchives"
83+
Inputs="@(TensorFlowArchive->'%(DownloadFile)')"
84+
Outputs="@(TensorFlowArchive->'%(ExtractSemaphore)')">
85+
86+
<GetFileHash Files="@(TensorFlowArchive->'%(DownloadFile)')" Algorithm="SHA512">
87+
<Output
88+
TaskParameter="Items"
89+
ItemName="FilesWithHashes" />
90+
</GetFileHash>
91+
92+
<WriteLinesToFile File="%(FilesWithHashes.Identity).sha" Lines="%(FilesWithHashes.FileHash)" Overwrite="true"/>
93+
94+
<!-- If specified we'll update the checked in SHAs with the downloaded ones. -->
95+
<Copy Condition="'$(UpdateSHA)' == 'true'"
96+
SourceFiles="@(TensorFlowArchive->'%(DownloadShaFile)')"
97+
DestinationFiles="@(TensorFlowArchive->'%(LocalShaFile)')" />
98+
99+
<ItemGroup>
100+
<TensorFlowArchive>
101+
<DownloadSha>@(FilesWithHashes->'%(FileHash)')</DownloadSha>
102+
<LocalSha>$([System.IO.File]::ReadAllText('%(LocalShaFile)').Replace("%0A", "").Replace("%0D", ""))</LocalSha>
103+
</TensorFlowArchive>
104+
</ItemGroup>
105+
106+
<Error Condition="!Exists('%(TensorFlowArchive.LocalShaFile)')" Text="SHA file '%(TensorFlowArchive.LocalShaFile)' does not exist. Build with /p:UpdateSHA=true to save it." />
107+
108+
<Message Importance="High" Text="@TensorFlowArchive->'%(TensorFlowArchive.DownloadFile) - %(TensorFlowArchive.LocalSha) - %(TensorFlowArchive.DownloadSha)"/>
109+
110+
<!-- Validate that the downloaded SHAs match the expected checked in SHAs -->
111+
<Error Condition="'%(TensorFlowArchive.LocalSha)' != '%(TensorFlowArchive.DownloadSha)'" Text="Downloaded file '%(TensorFlowArchive.DownloadFile)' has unexpected SHA.%0A expected: %(TensorFlowArchive.LocalSha)%0A --actual: %(TensorFlowArchive.DownloadSha)%0ABuild with /p:UpdateSHA=true if you intentionally changed the URL and wish to update the SHAs, otherwise this could indicate an incomplete download or intercerpted URL and should be examined." />
112+
113+
114+
<!-- The archives are valid, lets extract them, ensuring an empty directory -->
115+
<RemoveDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
116+
<MakeDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
117+
118+
<Message Importance="High" Text="Decompressing '%(TensorFlowArchive.DownloadFile)' to '%(TensorFlowArchive.ExtractDirectory)'." />
119+
120+
<Unzip Condition="'%(TensorFlowArchive.FileExtension)' == '.zip'"
121+
SourceFiles="%(TensorFlowArchive.DownloadFile)"
122+
DestinationFolder="%(TensorFlowArchive.ExtractDirectory)" />
123+
124+
<Exec Condition="'$(OS)' != 'Windows_NT' AND '%(TensorFlowArchive.FileExtension)' == '.tar.gz'"
125+
WorkingDirectory="$(MSBuildThisFileDirectory)"
126+
Command="tar -xzm --hard-dereference -f %(TensorFlowArchive.DownloadFile) -C %(TensorFlowArchive.ExtractDirectory)" />
127+
128+
<Exec Condition="'$(OS)' != 'Windows_NT'"
129+
Command="chmod -R +w %(TensorFlowArchive.ExtractDirectory)" />
130+
131+
<Touch Files="@(TensorFlowArchive->'%(ExtractSemaphore)')" AlwaysCreate="true" />
132+
</Target>
133+
134+
<!-- Select the files we want to copy out of each archive. -->
135+
<Target Name="GetFilesFromArchive"
136+
DependsOnTargets="ValidateAndExtractArchives" >
137+
<ItemGroup>
138+
<!-- batch rather than transform so that we can split FilesFromArchive metadata -->
139+
<_fileFromArchive Include="%(TensorFlowArchive.FilesFromArchive)" ExtractDirectory="%(TensorFlowArchive.ExtractDirectory)" Runtime="%(TensorFlowArchive.Runtime)" />
140+
<_fileFromArchive DestinationFile="%(FileName)%(Extension)"/>
141+
<_fileFromArchive PackagePath="runtimes\%(_fileFromArchive.Runtime)\native\%(_fileFromArchive.DestinationFile)" />
142+
143+
<!-- LICENSE from the package is actually THIRD_PARTY_NOTICES-->
144+
<_fileFromArchive Condition="'%(DestinationFile)' == 'LICENSE'" PackagePath="THIRD_PARTY_NOTICES.txt" Runtime="" />
145+
146+
<!-- copy to packaging location -->
147+
<FilesFromArchive Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
148+
TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\%(PackagePath)" />
149+
<!-- include LICENSE that was downloaded from GitHub -->
150+
<FilesFromArchive Include="$(BinDir)\LICENSE"
151+
TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\LICENSE.txt" />
152+
153+
<!-- copy to NativeAssets location, only for current RID, so that they may be used by tests -->
154+
<!--<FilesFromArchive Condition="'$(PackageRID)' == '%(_fileFromArchive.Runtime)'"
155+
Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
156+
TargetPath="$(NativeAssetsBuiltPath)\%(_fileFromArchive.DestinationFile)" />-->
157+
</ItemGroup>
158+
</Target>
159+
160+
<Target Name="CopyFilesFromArchive"
161+
DependsOnTargets="GetFilesFromArchive">
162+
163+
<Message Importance="High" Text="@(FilesFromArchive) -> %(FilesFromArchive.TargetPath)" />
164+
<Copy SourceFiles="@(FilesFromArchive)"
165+
DestinationFiles="@(FilesFromArchive->'%(TargetPath)')" />
166+
167+
</Target>
168+
169+
<Target Name="Clean">
170+
<Message Importance="High" Text="Deleting $(BinDir);$(ObjDir)" />
171+
<RemoveDir Directories="$(BinDir);$(ObjDir)" />
172+
</Target>
173+
174+
</Project>

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL