Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
6bff79da
Unverified
Commit
6bff79da
authored
Jul 02, 2021
by
Nikita Titov
Committed by
GitHub
Jul 02, 2021
Browse files
[python] migrate to pathlib in create_nuget.py (#4422)
parent
962a9937
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
27 deletions
+20
-27
.nuget/create_nuget.py
.nuget/create_nuget.py
+20
-27
No files found.
.nuget/create_nuget.py
View file @
6bff79da
# coding: utf-8
"""Script for generating files with NuGet package metadata."""
import
datetime
import
os
import
sys
from
distutils.file_util
import
copy_file
from
pathlib
import
Path
from
shutil
import
copyfile
if
__name__
==
"__main__"
:
source
=
sys
.
argv
[
1
]
current_dir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
linux_folder_path
=
os
.
path
.
join
(
current_dir
,
"runtimes"
,
"linux-x64"
,
"native"
)
if
not
os
.
path
.
exists
(
linux_folder_path
):
os
.
makedirs
(
linux_folder_path
)
osx_folder_path
=
os
.
path
.
join
(
current_dir
,
"runtimes"
,
"osx-x64"
,
"native"
)
if
not
os
.
path
.
exists
(
osx_folder_path
):
os
.
makedirs
(
osx_folder_path
)
windows_folder_path
=
os
.
path
.
join
(
current_dir
,
"runtimes"
,
"win-x64"
,
"native"
)
if
not
os
.
path
.
exists
(
windows_folder_path
):
os
.
makedirs
(
windows_folder_path
)
build_folder_path
=
os
.
path
.
join
(
current_dir
,
"build"
)
if
not
os
.
path
.
exists
(
build_folder_path
):
os
.
makedirs
(
build_folder_path
)
copy_file
(
os
.
path
.
join
(
source
,
"lib_lightgbm.so"
),
os
.
path
.
join
(
linux_folder_path
,
"lib_lightgbm.so"
))
copy_file
(
os
.
path
.
join
(
source
,
"lib_lightgbm.dylib"
),
os
.
path
.
join
(
osx_folder_path
,
"lib_lightgbm.dylib"
))
copy_file
(
os
.
path
.
join
(
source
,
"lib_lightgbm.dll"
),
os
.
path
.
join
(
windows_folder_path
,
"lib_lightgbm.dll"
))
copy_file
(
os
.
path
.
join
(
source
,
"lightgbm.exe"
),
os
.
path
.
join
(
windows_folder_path
,
"lightgbm.exe"
))
version
=
open
(
os
.
path
.
join
(
current_dir
,
os
.
path
.
pardir
,
'VERSION.txt'
)).
read
().
strip
().
replace
(
'rc'
,
'-rc'
)
source
=
Path
(
sys
.
argv
[
1
])
current_dir
=
Path
(
__file__
).
parent
.
absolute
()
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'
)
nuget_str
=
rf
"""<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
...
...
@@ -79,9 +75,6 @@ if __name__ == "__main__":
</Target>
</Project>
"""
with
open
(
os
.
path
.
join
(
current_dir
,
"LightGBM.nuspec"
),
"w"
)
as
nuget_file
:
nuget_file
.
write
(
nuget_str
)
with
open
(
os
.
path
.
join
(
current_dir
,
"build"
,
"LightGBM.props"
),
"w"
)
as
prop_file
:
prop_file
.
write
(
prop_str
)
with
open
(
os
.
path
.
join
(
current_dir
,
"build"
,
"LightGBM.targets"
),
"w"
)
as
target_file
:
target_file
.
write
(
target_str
)
(
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'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment