2018-10-16 09:19:36 +03:00
|
|
|
# coding: utf-8
|
|
|
|
"""Script for generating files with NuGet package metadata."""
|
2024-06-03 06:33:53 +03:00
|
|
|
|
2019-01-15 13:30:51 +03:00
|
|
|
import datetime
|
2017-06-25 04:29:07 +03:00
|
|
|
import sys
|
2021-07-02 15:05:28 +03:00
|
|
|
from pathlib import Path
|
|
|
|
from shutil import copyfile
|
2018-07-12 18:43:59 +03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-07-02 15:05:28 +03:00
|
|
|
source = Path(sys.argv[1])
|
2021-07-10 16:18:50 +03:00
|
|
|
current_dir = Path(__file__).absolute().parent
|
2021-07-02 15:05:28 +03:00
|
|
|
linux_folder_path = current_dir / "runtimes" / "linux-x64" / "native"
|
|
|
|
linux_folder_path.mkdir(parents=True, exist_ok=True)
|
|
|
|
osx_folder_path = current_dir / "runtimes" / "osx-x64" / "native"
|
|
|
|
osx_folder_path.mkdir(parents=True, exist_ok=True)
|
|
|
|
windows_folder_path = current_dir / "runtimes" / "win-x64" / "native"
|
|
|
|
windows_folder_path.mkdir(parents=True, exist_ok=True)
|
|
|
|
build_folder_path = current_dir / "build"
|
|
|
|
build_folder_path.mkdir(parents=True, exist_ok=True)
|
|
|
|
copyfile(source / "lib_lightgbm.so", linux_folder_path / "lib_lightgbm.so")
|
|
|
|
copyfile(source / "lib_lightgbm.dylib", osx_folder_path / "lib_lightgbm.dylib")
|
|
|
|
copyfile(source / "lib_lightgbm.dll", windows_folder_path / "lib_lightgbm.dll")
|
|
|
|
copyfile(source / "lightgbm.exe", windows_folder_path / "lightgbm.exe")
|
|
|
|
version = (current_dir.parent / "VERSION.txt").read_text(encoding="utf-8").strip().replace("rc", "-rc")
|
2021-04-12 05:08:47 +03:00
|
|
|
nuget_str = rf"""<?xml version="1.0"?>
|
2018-07-12 18:43:59 +03:00
|
|
|
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
|
|
|
<metadata>
|
|
|
|
<id>LightGBM</id>
|
2021-04-12 05:08:47 +03:00
|
|
|
<version>{version}</version>
|
2018-07-12 18:43:59 +03:00
|
|
|
<authors>Guolin Ke</authors>
|
|
|
|
<owners>Guolin Ke</owners>
|
2021-10-12 06:11:38 +03:00
|
|
|
<license type="expression">MIT</license>
|
2019-05-08 08:51:28 +03:00
|
|
|
<projectUrl>https://github.com/microsoft/LightGBM</projectUrl>
|
2018-07-12 18:43:59 +03:00
|
|
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
|
|
|
<description>A fast, distributed, high performance gradient boosting framework</description>
|
2021-04-12 05:08:47 +03:00
|
|
|
<copyright>Copyright {datetime.datetime.now().year} @ Microsoft</copyright>
|
2018-07-12 18:43:59 +03:00
|
|
|
<tags>machine-learning data-mining distributed native boosting gbdt</tags>
|
|
|
|
<dependencies> </dependencies>
|
|
|
|
</metadata>
|
|
|
|
<files>
|
2018-08-26 06:35:50 +03:00
|
|
|
<file src="build\**" target="build"/>
|
2018-07-12 18:43:59 +03:00
|
|
|
<file src="runtimes\**" target="runtimes"/>
|
|
|
|
</files>
|
|
|
|
</package>
|
2021-04-12 05:08:47 +03:00
|
|
|
"""
|
2020-01-27 03:07:25 +03:00
|
|
|
prop_str = r"""
|
2018-08-26 06:35:50 +03:00
|
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<ItemGroup Condition="Exists('packages.config') OR
|
|
|
|
Exists('$(MSBuildProjectName).packages.config') OR
|
|
|
|
Exists('packages.$(MSBuildProjectName).config')">
|
|
|
|
<Content Include="$(MSBuildThisFileDirectory)/../runtimes/win-x64/native/*.dll"
|
|
|
|
Condition="'$(PlatformTarget)' == 'x64'">
|
|
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
|
|
<Visible>false</Visible>
|
|
|
|
</Content>
|
|
|
|
<Content Include="$(MSBuildThisFileDirectory)/../runtimes/win-x64/native/*.exe"
|
|
|
|
Condition="'$(PlatformTarget)' == 'x64'">
|
|
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
|
|
<Visible>false</Visible>
|
|
|
|
</Content>
|
|
|
|
</ItemGroup>
|
|
|
|
</Project>
|
2020-01-27 03:07:25 +03:00
|
|
|
"""
|
|
|
|
target_str = r"""
|
2018-08-26 06:35:50 +03:00
|
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<PropertyGroup>
|
|
|
|
<EnableLightGBMUnsupportedPlatformTargetCheck Condition="'$(EnableLightGBMUnsupportedPlatformTargetCheck)' == ''">true</EnableLightGBMUnsupportedPlatformTargetCheck>
|
|
|
|
</PropertyGroup>
|
|
|
|
<Target Name="_LightGBMCheckForUnsupportedPlatformTarget"
|
|
|
|
Condition="'$(EnableLightGBMUnsupportedPlatformTargetCheck)' == 'true'"
|
|
|
|
AfterTargets="_CheckForInvalidConfigurationAndPlatform">
|
|
|
|
<Error Condition="'$(PlatformTarget)' != 'x64' AND
|
|
|
|
('$(OutputType)' == 'Exe' OR '$(OutputType)'=='WinExe') AND
|
|
|
|
!('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(PlatformTarget)' == '')"
|
|
|
|
Text="LightGBM currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'." />
|
|
|
|
</Target>
|
|
|
|
</Project>
|
2020-01-27 03:07:25 +03:00
|
|
|
"""
|
2021-07-02 15:05:28 +03:00
|
|
|
(current_dir / "LightGBM.nuspec").write_text(nuget_str, encoding="utf-8")
|
|
|
|
(current_dir / "build" / "LightGBM.props").write_text(prop_str, encoding="utf-8")
|
|
|
|
(current_dir / "build" / "LightGBM.targets").write_text(target_str, encoding="utf-8")
|