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
OpenDAS
Torchaudio
Commits
ce04cfe3
Commit
ce04cfe3
authored
Mar 18, 2025
by
zhanggzh
Browse files
add torchaudio2.4.1 source code
parent
e8cbe177
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
6 deletions
+58
-6
install.sh
install.sh
+10
-0
packaging/torchaudio/version.py
packaging/torchaudio/version.py
+2
-0
setup.py
setup.py
+46
-6
No files found.
install.sh
0 → 100755
View file @
ce04cfe3
#!/bin/bash
rm
-rf
build
rm
-rf
*
.egg-info
pip3
install
-r
requirements.txt
export
USE_RCOM
=
1
shopt
-u
nocasematch
python setup.py bdist_wheel
packaging/torchaudio/version.py
0 → 100644
View file @
ce04cfe3
__version__
=
'2.4.1'
__hcu_version__
=
'2.4.1+das.dtk2504'
setup.py
View file @
ce04cfe3
...
@@ -30,12 +30,10 @@ def _get_version(sha):
...
@@ -30,12 +30,10 @@ def _get_version(sha):
return
version
return
version
def
_make_version_file
(
version
,
sha
):
def
_make_version_file
(
version
):
sha
=
"Unknown"
if
sha
is
None
else
sha
version_path
=
ROOT_DIR
/
"src"
/
"torchaudio"
/
"version.py"
version_path
=
ROOT_DIR
/
"src"
/
"torchaudio"
/
"version.py"
with
open
(
version_path
,
"w"
)
as
f
:
with
open
(
version_path
,
"w"
)
as
f
:
f
.
write
(
f
"__version__ = '
{
version
}
'
\n
"
)
f
.
write
(
f
"__version__ = '
{
version
}
'
\n
"
)
f
.
write
(
f
"git_version = '
{
sha
}
'
\n
"
)
def
_get_pytorch_version
():
def
_get_pytorch_version
():
...
@@ -63,6 +61,22 @@ class clean(distutils.command.clean.clean):
...
@@ -63,6 +61,22 @@ class clean(distutils.command.clean.clean):
shutil
.
rmtree
(
str
(
path
),
ignore_errors
=
True
)
shutil
.
rmtree
(
str
(
path
),
ignore_errors
=
True
)
def
_make_version_file
(
version
):
ROCM_PATH
=
os
.
getenv
(
'ROCM_PATH'
)
dtk_path
=
ROCM_PATH
+
'/.info/rocm_version'
with
open
(
dtk_path
,
'r'
)
as
file
:
content
=
file
.
read
().
strip
()
dtk_version
=
content
.
replace
(
'.'
,
''
)
hcu_version
=
f
"
{
version
}
+das.dtk
{
dtk_version
}
"
version_path
=
ROOT_DIR
/
"packaging"
/
"torchaudio"
/
"version.py"
with
open
(
version_path
,
"w"
)
as
f
:
f
.
write
(
f
"__version__ = '
{
version
}
'
\n
"
)
f
.
write
(
f
"__hcu_version__ = '
{
hcu_version
}
'
\n
"
)
return
hcu_version
def
_parse_url
(
path
):
def
_parse_url
(
path
):
with
open
(
path
,
"r"
)
as
file_
:
with
open
(
path
,
"r"
)
as
file_
:
for
line
in
file_
:
for
line
in
file_
:
...
@@ -79,6 +93,32 @@ def _fetch_archives(src):
...
@@ -79,6 +93,32 @@ def _fetch_archives(src):
torch
.
hub
.
download_url_to_file
(
url
,
dest
,
progress
=
False
)
torch
.
hub
.
download_url_to_file
(
url
,
dest
,
progress
=
False
)
import
re
def
get_version
(
file_path
:
str
=
"version.txt"
,
encoding
:
str
=
"utf-8"
)
->
str
|
None
:
"""
从指定文件中读取版本号(默认文件为 version.txt)
"""
try
:
with
open
(
file_path
,
"r"
,
encoding
=
encoding
)
as
file
:
line
=
file
.
readline
().
strip
()
# 正则匹配语义化版本号格式(如 v1.2.3 或 4.5.6-beta)
if
re
.
match
(
r
"^v?(?:\d+\.){2}\d+(-\w+)?$"
,
line
):
return
line
else
:
print
(
f
"[错误] 无效的版本号格式:
{
line
}
"
)
return
None
except
FileNotFoundError
:
print
(
f
"[错误] 文件不存在:
{
file_path
}
"
)
except
UnicodeDecodeError
:
print
(
f
"[错误] 编码不匹配,请尝试 encoding='gbk'"
)
except
Exception
as
e
:
print
(
f
"[错误] 读取失败:
{
str
(
e
)
}
"
)
return
None
def
_main
():
def
_main
():
sha
=
_run_cmd
([
"git"
,
"rev-parse"
,
"HEAD"
])
sha
=
_run_cmd
([
"git"
,
"rev-parse"
,
"HEAD"
])
branch
=
_run_cmd
([
"git"
,
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
])
branch
=
_run_cmd
([
"git"
,
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
])
...
@@ -88,17 +128,17 @@ def _main():
...
@@ -88,17 +128,17 @@ def _main():
print
(
"-- Git tag:"
,
tag
)
print
(
"-- Git tag:"
,
tag
)
pytorch_package_dep
=
_get_pytorch_version
()
pytorch_package_dep
=
_get_pytorch_version
()
print
(
"-- PyTorch dependency:"
,
pytorch_package_dep
)
print
(
"-- PyTorch dependency:"
,
pytorch_package_dep
)
version
=
_
get_version
(
sha
)
version
=
get_version
()
print
(
"-- Building version"
,
version
)
print
(
"-- Building version"
,
version
)
_make_version_file
(
version
,
sha
)
dcu_version
=
_make_version_file
(
version
)
with
open
(
"README.md"
)
as
f
:
with
open
(
"README.md"
)
as
f
:
long_description
=
f
.
read
()
long_description
=
f
.
read
()
setup
(
setup
(
name
=
"torchaudio"
,
name
=
"torchaudio"
,
version
=
version
,
version
=
dcu_
version
,
description
=
"An audio package for PyTorch"
,
description
=
"An audio package for PyTorch"
,
long_description
=
long_description
,
long_description
=
long_description
,
long_description_content_type
=
"text/markdown"
,
long_description_content_type
=
"text/markdown"
,
...
...
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