-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: modernize build backend and require Python 3.8+ #137
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -7,26 +7,25 @@ on: | |
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Setup uv | ||
uses: astral-sh/setup-uv@v3 | ||
- name: Install dependencies | ||
run: python -m pip install -e .[test,boost,uproot,rich] | ||
- name: Install optional dependencies for tests | ||
run: python -m pip install pandas | ||
run: uv pip install --system -e .[test,boost,uproot,rich] pandas | ||
- name: Run tests | ||
run: python -m pytest -s | ||
- name: Run CLI | ||
|
@@ -50,7 +49,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
python-version: '3.x' | ||
- uses: pre-commit/[email protected] | ||
with: | ||
extra_args: --all-files --hook-stage manual |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
import numpy as np | ||
|
||
import histoprint as hp | ||
import histoprint.formatter as formatter | ||
from histoprint import formatter | ||
|
||
|
||
@click.command() | ||
|
@@ -124,27 +124,26 @@ def histoprint(infile, **kwargs): | |
try: | ||
data_handle.seek(0) | ||
_histoprint_txt(data_handle, **kwargs) | ||
exit(0) | ||
return | ||
except ValueError: | ||
pass | ||
|
||
# Try to interpret file as CSV file | ||
try: | ||
data_handle.seek(0) | ||
_histoprint_csv(data_handle, **kwargs) | ||
exit(0) | ||
raise SystemExit(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a |
||
except ImportError: | ||
click.echo("Cannot try CSV file format. Pandas module not found.", err=True) | ||
|
||
# Try to interpret file as ROOT file | ||
try: | ||
_histoprint_root(infile, **kwargs) | ||
exit(0) | ||
return | ||
except ImportError: | ||
pass | ||
|
||
click.echo("Could not interpret file format.", err=True) | ||
exit(1) | ||
raise click.FileError(infile, "Could not interpret the file format") | ||
|
||
|
||
def _bin_edges(kwargs, data): | ||
|
@@ -180,7 +179,7 @@ def _histoprint_txt(infile, **kwargs): | |
except Exception as e: | ||
click.echo("Error interpreting the cut string:", err=True) | ||
click.echo(e, err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
|
||
# Interpret field numbers | ||
fields = kwargs.pop("fields", []) | ||
|
@@ -189,12 +188,12 @@ def _histoprint_txt(infile, **kwargs): | |
fields = [int(f) for f in fields] | ||
except ValueError: | ||
click.echo("Fields for a TXT file must be integers.", err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
try: | ||
data = data[fields] | ||
except KeyError: | ||
click.echo("Field out of bounds.", err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
|
||
# Interpret bins | ||
bins = _bin_edges(kwargs, data) | ||
|
@@ -222,7 +221,7 @@ def _histoprint_csv(infile, **kwargs): | |
except Exception as e: | ||
click.echo("Error interpreting the cut string:", err=True) | ||
click.echo(e, err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
|
||
# Interpret field numbers/names | ||
fields = list(kwargs.pop("fields", [])) | ||
|
@@ -231,7 +230,7 @@ def _histoprint_csv(infile, **kwargs): | |
data = data[fields] | ||
except KeyError: | ||
click.echo("Unknown column name.", err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
|
||
# Get default columns labels | ||
if kwargs.get("labels", ("",)) == ("",): | ||
|
@@ -276,7 +275,7 @@ def _histoprint_root(infile, **kwargs): | |
if len(fields) == 0: | ||
click.echo("Must specify at least one field for ROOT files.", err=True) | ||
click.echo(F.keys(), err=True) | ||
exit(1) | ||
raise SystemExit(1) | ||
|
||
# Get default columns labels | ||
if kwargs.get("labels", ("",)) == ("",): | ||
|
@@ -317,11 +316,11 @@ def _histoprint_root(infile, **kwargs): | |
f"Could not find key '{key}'. Possible values: {branch.keys()}", | ||
err=True, | ||
) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
# Has `arrays` method? | ||
if hasattr(branch, "arrays"): | ||
# Found it | ||
path = "/".join(splitfield[i + 1:]) | ||
path = "/".join(splitfield[i + 1 :]) | ||
if branch in trees: | ||
tree_fields[trees.index(branch)].append( | ||
{"label": label, "path": path} | ||
|
@@ -350,7 +349,7 @@ def _histoprint_root(infile, **kwargs): | |
except up.KeyInFileError as e: | ||
click.echo(e, err=True) | ||
click.echo(f"Possible keys: {tree.keys()}", err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
|
||
# Cut on values | ||
if cut is not None: | ||
|
@@ -359,11 +358,11 @@ def _histoprint_root(infile, **kwargs): | |
except up.KeyInFileError as e: | ||
click.echo(e, err=True) | ||
click.echo(f"Possible keys: {tree.keys()}", err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
except Exception as e: | ||
click.echo("Error interpreting the cut string:", err=True) | ||
click.echo(e, err=True) | ||
exit(1) | ||
raise SystemExit(1) from None | ||
|
||
for i in range(len(d)): | ||
d[i] = d[i][index] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version: str |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to add this to ensure that the pre-commit hooks run on my laptop, which is Ubuntu 20.04 LTS. Without this, they try to use the default Python 3.8, and some of the pre-commit checks seem to not support that. Is it harmful in any way to just keep this in for now?