Skip to content

Commit fa390e1

Browse files
authored
Update prototype exclusion (#1885)
1 parent d5e44f8 commit fa390e1

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

setup.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
import os
3+
import re
34
import shutil
45
import subprocess
56
from pathlib import Path
@@ -11,14 +12,16 @@
1112
ROOT_DIR = Path(__file__).parent.resolve()
1213

1314

15+
def _run_cmd(cmd, default):
16+
try:
17+
return subprocess.check_output(cmd, cwd=ROOT_DIR).decode('ascii').strip()
18+
except Exception:
19+
return default
20+
21+
1422
# Creating the version file
1523
version = '0.10.0a0'
16-
sha = 'Unknown'
17-
18-
try:
19-
sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT_DIR).decode('ascii').strip()
20-
except Exception:
21-
pass
24+
sha = _run_cmd(['git', 'rev-parse', 'HEAD'], default='Unknown')
2225

2326
if os.getenv('BUILD_VERSION'):
2427
version = os.getenv('BUILD_VERSION')
@@ -65,7 +68,17 @@ def _get_packages():
6568
"third_party*",
6669
"build_tools*",
6770
]
68-
if os.environ.get('UPLOAD_CHANNEL', '') == 'test':
71+
exclude_prototype = False
72+
branch_name = _run_cmd(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], default=None)
73+
is_on_tag = _run_cmd(['git', 'describe', '--tags', '--exact-match', '@'], default=None)
74+
75+
if branch_name is not None and branch_name.startswith('release/'):
76+
print('On release branch')
77+
exclude_prototype = True
78+
if is_on_tag is not None and re.match(r'v[\d.]+(-rc\d+)?', is_on_tag):
79+
print('On release tag')
80+
exclude_prototype = True
81+
if exclude_prototype:
6982
print('Excluding torchaudio.prototype from the package.')
7083
exclude.append("torchaudio.prototype")
7184
return find_packages(exclude=exclude)

0 commit comments

Comments
 (0)