-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propogate Python exceptions through err_handler
- Loading branch information
Showing
16 changed files
with
283 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{# Displays the copyright information (which is defined in conf.py). #} | ||
{% if show_copyright and copyright %} | ||
<p class="copyright"> | ||
{% if hasdoc('copyright') %} | ||
© <a href="{{ pathto('copyright') }}">{% trans copyright=copyright|e %}Copyright {{ copyright }}{% endtrans %}</a>. | ||
<br/> | ||
{% else %} | ||
{% trans copyright=copyright|e %}© {{ copyright }}.{% endtrans %} | ||
<br/> | ||
{% endif %} | ||
</p> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ name: sun | |
channels: | ||
- conda-forge | ||
dependencies: | ||
- sundials=7.1 | ||
- sundials=7.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ channels: | |
- defaults | ||
dependencies: | ||
- python=3.12 | ||
- sundials=7.1 | ||
- sundials=7.2 | ||
- pip>=24.3 | ||
- pip: | ||
- ../.[docs] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import requests | ||
import argparse | ||
from packaging.version import Version | ||
|
||
|
||
def get_latest_version(package: str, prefix: str = None) -> str: | ||
""" | ||
Fetch the latest version with matching prefix from PyPI. | ||
Parameters | ||
---------- | ||
package : str | ||
The name of the package to query. | ||
prefix : str | ||
A filtering prefix used to get a subset of releases, e.g., '1.1' will | ||
return the latest patch to version 1.1 even if 1.2 exists. | ||
Returns | ||
------- | ||
latest_version : str | ||
The latest version available on PyPI. '0.0.0' is returned if there | ||
are no versions. | ||
Raises | ||
------ | ||
ValueError | ||
Failed to fetch PyPI data for requested package. | ||
""" | ||
|
||
url = f"https://pypi.org/pypi/{package}/json" | ||
|
||
response = requests.get(url) | ||
if response.status_code != 200: | ||
raise ValueError(f"Failed to fetch PyPI data for '{package}'.") | ||
|
||
data = response.json() | ||
versions = list(data['releases'].keys()) | ||
if not versions: | ||
print(f"{package=} not found on PyPI.") | ||
return '0.0.0' | ||
|
||
if prefix: | ||
versions = [v for v in versions if v.startswith(prefix)] | ||
assert len(versions) != 0, f"{prefix=} has no existing matches." | ||
|
||
sorted_versions = sorted(versions, key=Version, reverse=True) | ||
latest_version = sorted_versions[0] | ||
|
||
print(f"Latest PyPI version for {package}: {latest_version}.") | ||
return latest_version | ||
|
||
|
||
def check_against_pypi(pypi: str, local: str) -> None: | ||
""" | ||
Verify the local version is newer than PyPI. | ||
Parameters | ||
---------- | ||
pypi : str | ||
Latest version on PyPI. | ||
local : str | ||
Local package version. | ||
Returns | ||
------- | ||
None. | ||
Raises | ||
------ | ||
ValueError | ||
Local package is older than PyPI. | ||
""" | ||
|
||
pypi = Version(pypi) | ||
local = Version(local) | ||
|
||
if local < pypi: | ||
raise ValueError(f"Local package {local} is older than PyPI {pypi}.") | ||
|
||
print(f"Local package {local} is newer than PyPI {pypi}.") | ||
|
||
|
||
def check_against_tag(tag: str, local: str) -> None: | ||
""" | ||
Check that the tag matches the package version. | ||
Parameters | ||
---------- | ||
tag : str | ||
Semmantically versioned tag. | ||
local : str | ||
Local package version. | ||
Returns | ||
------- | ||
None. | ||
Raises | ||
------ | ||
ValueError | ||
Version mismatch: tag differs from local. | ||
""" | ||
|
||
tag = Version(tag) | ||
local = Version(local) | ||
|
||
if tag != local: | ||
raise ValueError(f"Version mismatch: {tag=} vs. {local=}") | ||
|
||
print(f"Local and tag versions match: {tag} == {local}.") | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--tag', required=True) | ||
parser.add_argument('--local', required=True) | ||
args = parser.parse_args() | ||
|
||
check_against_tag(args.tag, args.local) | ||
|
||
patch_check = Version(args.local) | ||
if patch_check.micro > 0: | ||
prefix = str(patch_check.major) + '.' + str(patch_check.minor) | ||
else: | ||
prefix = None | ||
|
||
pypi = get_latest_version('scikit-sundae', prefix) | ||
|
||
check_against_pypi(pypi, args.local) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,4 @@ | |
|
||
__all__ = ['ida', 'utils', 'cvode', 'SUNDIALS_VERSION'] | ||
|
||
__version__ = '1.0.0rc3' | ||
__version__ = '1.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.