|
8 | 8 | from importlib_resources import open_text |
9 | 9 | import yaml |
10 | 10 | from pace_neutrons import __version__ |
11 | | -from pace_neutrons_cli.utils import release_exists |
| 11 | +from pace_neutrons_cli.utils import release_exists, download_github |
12 | 12 |
|
13 | 13 | def main(): |
14 | 14 | parser = get_parser() |
@@ -58,11 +58,27 @@ def release_github(test=True): |
58 | 58 |
|
59 | 59 |
|
60 | 60 | def release_pypi(test=True): |
61 | | - subprocess.run(['rm','-r','dist']) |
62 | | - subprocess.run(['rm','-r','build']) |
63 | | - subprocess.run(['python', 'setup.py', 'sdist']) |
| 61 | + # Downloads wheels from github and upload to PyPI |
| 62 | + response = requests.get( |
| 63 | + 'https://api.github.com/repos/pace-neutrons/pace-python/releases') |
| 64 | + # Get the latest release |
| 65 | + releases = response.json() |
| 66 | + ids = [r['id'] for r in releases] |
| 67 | + latest = [r for r in releases if r['id'] == max(ids)][0] |
| 68 | + # Creates a custom wheelhouse folder |
| 69 | + try: |
| 70 | + os.mkdir('pace_wheelhouse') |
| 71 | + except FileExistsError: |
| 72 | + pass |
| 73 | + # Loops through assets and downloads all the wheels |
| 74 | + headers = {"Accept":"application/octet-stream"} |
| 75 | + for asset in latest['assets']: |
| 76 | + if asset['name'].endswith('whl'): |
| 77 | + print('Downloading %s' % (asset['name'])) |
| 78 | + localfile = os.path.join('pace_wheelhouse', asset['name']) |
| 79 | + download_github(asset['url'], localfile, use_auth=False) |
64 | 80 | if not test: |
65 | | - subprocess.run(['twine', 'upload', 'dist/*']) |
| 81 | + subprocess.run(['twine', 'upload', 'pace_wheelhouse/*']) |
66 | 82 |
|
67 | 83 |
|
68 | 84 | def get_parser(): |
|
0 commit comments