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
234627f8
Unverified
Commit
234627f8
authored
Oct 19, 2021
by
moto
Committed by
GitHub
Oct 19, 2021
Browse files
Clean up setup.py (#1900)
parent
68318cc1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
55 deletions
+70
-55
setup.py
setup.py
+70
-55
No files found.
setup.py
View file @
234627f8
...
@@ -19,26 +19,27 @@ def _run_cmd(cmd):
...
@@ -19,26 +19,27 @@ def _run_cmd(cmd):
return
None
return
None
# Creating the version file
def
_get_version
(
sha
):
version
=
'0.11.0a0'
version
=
'0.11.0a0'
sha
=
_run_cmd
([
'git'
,
'rev-parse'
,
'HEAD'
])
if
os
.
getenv
(
'BUILD_VERSION'
):
if
os
.
getenv
(
'BUILD_VERSION'
):
version
=
os
.
getenv
(
'BUILD_VERSION'
)
version
=
os
.
getenv
(
'BUILD_VERSION'
)
elif
sha
is
not
None
:
elif
sha
is
not
None
:
version
+=
'+'
+
sha
[:
7
]
version
+=
'+'
+
sha
[:
7
]
print
(
'-- Building version '
+
version
)
return
version
version_path
=
ROOT_DIR
/
'torchaudio'
/
'version.py'
def
_make_version_file
(
version
,
sha
):
with
open
(
version_path
,
'w'
)
as
f
:
sha
=
'Unknown'
if
sha
is
None
else
sha
f
.
write
(
"__version__ = '{}'
\n
"
.
format
(
version
))
version_path
=
ROOT_DIR
/
'torchaudio'
/
'version.py'
f
.
write
(
"git_version = {}
\n
"
.
format
(
repr
(
sha
or
'Unknown'
)))
with
open
(
version_path
,
'w'
)
as
f
:
f
.
write
(
f
"__version__ = '
{
version
}
'
\n
"
)
f
.
write
(
f
"git_version = '
{
sha
}
'
\n
"
)
pytorch_package_version
=
os
.
getenv
(
'PYTORCH_VERSION'
)
pytorch_package_dep
=
'torch'
def
_get_pytorch_version
():
if
pytorch_package_version
is
not
None
:
if
'PYTORCH_VERSION'
in
os
.
environ
:
pytorch_package_dep
+=
"=="
+
pytorch_package_version
return
f
"torch==
{
os
.
environ
[
'PYTORCH_VERSION'
]
}
"
return
'torch'
class
clean
(
distutils
.
command
.
clean
.
clean
):
class
clean
(
distutils
.
command
.
clean
.
clean
):
...
@@ -60,7 +61,7 @@ class clean(distutils.command.clean.clean):
...
@@ -60,7 +61,7 @@ class clean(distutils.command.clean.clean):
shutil
.
rmtree
(
str
(
path
),
ignore_errors
=
True
)
shutil
.
rmtree
(
str
(
path
),
ignore_errors
=
True
)
def
_get_packages
():
def
_get_packages
(
branch_name
,
tag
):
exclude
=
[
exclude
=
[
"build*"
,
"build*"
,
"test*"
,
"test*"
,
...
@@ -69,13 +70,9 @@ def _get_packages():
...
@@ -69,13 +70,9 @@ def _get_packages():
"tools*"
,
"tools*"
,
]
]
exclude_prototype
=
False
exclude_prototype
=
False
branch_name
=
_run_cmd
([
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'HEAD'
])
is_on_tag
=
_run_cmd
([
'git'
,
'describe'
,
'--tags'
,
'--exact-match'
,
'@'
])
print
(
'-- On branch:'
,
branch_name
)
print
(
'-- On tag:'
,
is_on_tag
)
if
branch_name
is
not
None
and
branch_name
.
startswith
(
'release/'
):
if
branch_name
is
not
None
and
branch_name
.
startswith
(
'release/'
):
exclude_prototype
=
True
exclude_prototype
=
True
if
is_on_
tag
is
not
None
and
re
.
match
(
r
'v[\d.]+(-rc\d+)?'
,
is_on_
tag
):
if
tag
is
not
None
and
re
.
match
(
r
'v[\d.]+(-rc\d+)?'
,
tag
):
exclude_prototype
=
True
exclude_prototype
=
True
if
exclude_prototype
:
if
exclude_prototype
:
print
(
'Excluding torchaudio.prototype from the package.'
)
print
(
'Excluding torchaudio.prototype from the package.'
)
...
@@ -83,7 +80,21 @@ def _get_packages():
...
@@ -83,7 +80,21 @@ def _get_packages():
return
find_packages
(
exclude
=
exclude
)
return
find_packages
(
exclude
=
exclude
)
setup
(
def
_main
():
sha
=
_run_cmd
([
'git'
,
'rev-parse'
,
'HEAD'
])
branch
=
_run_cmd
([
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'HEAD'
])
tag
=
_run_cmd
([
'git'
,
'describe'
,
'--tags'
,
'--exact-match'
,
'@'
])
print
(
'-- Git branch:'
,
branch
)
print
(
'-- Git SHA:'
,
sha
)
print
(
'-- Git tag:'
,
tag
)
pytorch_package_dep
=
_get_pytorch_version
()
print
(
'-- PyTorch dependency:'
,
pytorch_package_dep
)
version
=
_get_version
(
sha
)
print
(
'-- Building version'
,
version
)
_make_version_file
(
version
,
sha
)
setup
(
name
=
"torchaudio"
,
name
=
"torchaudio"
,
version
=
version
,
version
=
version
,
description
=
"An audio package for PyTorch"
,
description
=
"An audio package for PyTorch"
,
...
@@ -107,7 +118,7 @@ setup(
...
@@ -107,7 +118,7 @@ setup(
"Topic :: Multimedia :: Sound/Audio"
,
"Topic :: Multimedia :: Sound/Audio"
,
"Topic :: Scientific/Engineering :: Artificial Intelligence"
"Topic :: Scientific/Engineering :: Artificial Intelligence"
],
],
packages
=
_get_packages
(),
packages
=
_get_packages
(
branch
,
tag
),
ext_modules
=
setup_helpers
.
get_ext_modules
(),
ext_modules
=
setup_helpers
.
get_ext_modules
(),
cmdclass
=
{
cmdclass
=
{
'build_ext'
:
setup_helpers
.
CMakeBuild
,
'build_ext'
:
setup_helpers
.
CMakeBuild
,
...
@@ -115,4 +126,8 @@ setup(
...
@@ -115,4 +126,8 @@ setup(
},
},
install_requires
=
[
pytorch_package_dep
],
install_requires
=
[
pytorch_package_dep
],
zip_safe
=
False
,
zip_safe
=
False
,
)
)
if
__name__
==
'__main__'
:
_main
()
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