-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
secrets.json | ||
dist/ | ||
*.egg-info/ | ||
.venv/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exclude pymigbench_tests/* | ||
exclude data/* | ||
include version |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
""" | ||
This file is not part of the library itself, rather is a script to build the library. | ||
This should have minimal third-party dependencies so that it can be run in any environment. | ||
Third-party dependencies that should be globally installed: | ||
- requests | ||
""" | ||
import json | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
import requests | ||
|
||
|
||
class Release: | ||
def __init__(self, non_interactive: bool): | ||
self.non_interactive = non_interactive | ||
self.version = open("./version").read().strip() | ||
self.secrets = json.load(open("./secrets.json")) | ||
self.pypi_release_url = f"https://pypi.org/project/pymigbench/{self.version}/" | ||
self.github_repo = "ualberta-smr/pymigbench" | ||
self.github_url = f"https://github.com/{self.github_repo}" | ||
|
||
def validate(self): | ||
gh_tag = f"v{self.version}" | ||
|
||
try: | ||
current_tag = run_command(["git", "describe", "--tags", "--exact-match"]) | ||
if current_tag.strip() != gh_tag: | ||
raise ValueError(f"Current tag {current_tag} does not match the expected tag {gh_tag}.") | ||
except Exception as e: | ||
raise ValueError(f"Current head is not tagged with the expected version: {gh_tag}") from e | ||
|
||
response = requests.head(self.pypi_release_url) | ||
if response.status_code == 200: | ||
raise ValueError(f"Version {self.version} already released on PyPI.") | ||
|
||
print("Validated") | ||
print(f" Version: {self.version}") | ||
return self | ||
|
||
def build(self): | ||
print("Building...") | ||
run_command(["python", "-m", "build"]) | ||
print("Built successfully.") | ||
return self | ||
|
||
def publish_pypi(self): | ||
if self.non_interactive: | ||
return self | ||
if not self.non_interactive: | ||
confirm = input("Do you want to publish to PyPI? Note that this is an irreversible process. (y/n): ") | ||
if confirm.lower() != 'y': | ||
print("Not publishing to PyPI.") | ||
return self | ||
print("Publishing to PyPI...") | ||
run_command(["twine", "upload", "dist/*", "-u", "__token__", "-p", self.secrets['pypi']]) | ||
print("Published to PyPI.") | ||
return self | ||
|
||
|
||
def run_command(commands: list[any]): | ||
process = subprocess.Popen(commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
|
||
lines = [] | ||
while True: | ||
output = process.stdout.readline() | ||
if output == '' and process.poll() is not None: | ||
break | ||
if output: | ||
lines.append(output.strip()) | ||
print(output.strip()) | ||
|
||
return "\n".join(lines) | ||
|
||
|
||
def main(): | ||
non_interactive = "--non-interactive" in sys.argv | ||
Release(non_interactive).build().validate().publish_pypi() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
from setuptools import setup | ||
|
||
version = open('./.publish/version').read().strip() | ||
setup( | ||
name='pymigbench', | ||
description='APIs to access the PyMigBench dataset', | ||
long_description=open('./README.md').read(), | ||
long_description=open('README.md').read(), | ||
long_description_content_type='text/markdown', | ||
version=version, | ||
version="2.2.4", | ||
packages=['pymigbench'], | ||
author='PyMigBench Team', | ||
author_email='[email protected]', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.2.3 | ||
2.2.4 |