Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Lint
name: pre-commit

on: [push, pull_request, workflow_dispatch]

permissions: {}

jobs:
lint:
name: Check code with ruff
name: Run pre-commit checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ repos:
- id: ruff-check
name: Run Ruff (lint)
args: [--exit-non-zero-on-fix]
- id: ruff-format
name: Run Ruff (format)
args: [--exit-non-zero-on-fix]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.6.0
Expand Down
50 changes: 26 additions & 24 deletions dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,66 @@


REPO_ROOT = os.path.dirname(os.path.abspath(__file__))
VENVS = os.path.join(REPO_ROOT, '.venvs')
VENVS = os.path.join(REPO_ROOT, ".venvs")


def resolve_venv_root(kind='dev', venvsdir=VENVS):
def resolve_venv_root(kind="dev", venvsdir=VENVS):
import sysconfig

if sysconfig.is_python_build():
sys.exit('please install your built Python first (or pass it using --python)')
sys.exit("please install your built Python first (or pass it using --python)")
# XXX Handle other implementations too?
base = os.path.join(venvsdir, kind or 'dev')
base = os.path.join(venvsdir, kind or "dev")
major, minor = sys.version_info[:2]
pyloc = ((os.path.abspath(sys.executable)
).partition(os.path.sep)[2].lstrip(os.path.sep)
).replace(os.path.sep, '-')
return f'{base}-{major}.{minor}-{pyloc}'
pyloc = (
(os.path.abspath(sys.executable)).partition(os.path.sep)[2].lstrip(os.path.sep)
).replace(os.path.sep, "-")
return f"{base}-{major}.{minor}-{pyloc}"


def ensure_venv_ready(venvroot=None, kind='dev', venvsdir=VENVS):
def ensure_venv_ready(venvroot=None, kind="dev", venvsdir=VENVS):
if sys.prefix != sys.base_prefix:
assert os.path.exists(os.path.join(sys.prefix, 'pyvenv.cfg'))
assert os.path.exists(os.path.join(sys.prefix, "pyvenv.cfg"))
venvroot = sys.prefix
python = sys.executable
readyfile = os.path.join(sys.prefix, 'READY')
readyfile = os.path.join(sys.prefix, "READY")
isready = os.path.exists(readyfile)
else:
import venv

if not venvroot:
venvroot = resolve_venv_root(kind, venvsdir)
# Make sure the venv exists.
readyfile = os.path.join(venvroot, 'READY')
readyfile = os.path.join(venvroot, "READY")
isready = os.path.exists(readyfile)
if not isready:
relroot = os.path.relpath(venvroot)
if not os.path.exists(venvroot):
print(f'creating venv at {relroot}...')
print(f"creating venv at {relroot}...")
else:
print(f'venv {relroot} not ready, re-creating...')
print(f"venv {relroot} not ready, re-creating...")
venv.create(venvroot, with_pip=True, clear=True)
else:
assert os.path.exists(os.path.join(venvroot, 'pyvenv.cfg'))
assert os.path.exists(os.path.join(venvroot, "pyvenv.cfg"))
# Return the venv's Python executable.
binname = 'Scripts' if os.name == 'nt' else 'bin'
binname = "Scripts" if os.name == "nt" else "bin"
exename = os.path.basename(sys.executable)
python = os.path.join(venvroot, binname, exename)

# Now make sure the venv has pyperformance installed.
if not isready:
import subprocess

relroot = os.path.relpath(venvroot)
print(f'venv {relroot} not ready, installing dependencies...')
print(f"venv {relroot} not ready, installing dependencies...")
proc = subprocess.run(
[python, '-m', 'pip', 'install',
'--upgrade',
'--editable', REPO_ROOT],
[python, "-m", "pip", "install", "--upgrade", "--editable", REPO_ROOT],
)
if proc.returncode != 0:
sys.exit('ERROR: install failed')
with open(readyfile, 'w'):
sys.exit("ERROR: install failed")
with open(readyfile, "w"):
pass
print('...venv {relroot} ready!')
print("...venv {relroot} ready!")

return venvroot, python

Expand All @@ -77,8 +78,9 @@ def main(venvroot=None):

# Now run pyperformance.
import pyperformance.cli

pyperformance.cli.main()


if __name__ == '__main__':
if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Changelog
=========

* Run ruff format and check under pre-commit and Github action
* Bump dask[distributed] to 2024.10.1 for Windows compatibility
* Bump greenlet to 3.1.0 for compatibility with 3.13
* Bump tornado to 6.2.0
Expand Down
60 changes: 35 additions & 25 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@
extensions = []

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'Python Performance Benchmark Suite'
copyright = '2017, Victor Stinner'
author = 'Victor Stinner'
project = "Python Performance Benchmark Suite"
copyright = "2017, Victor Stinner"
author = "Victor Stinner"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = release = '1.0.6'
version = release = "1.0.6"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -67,10 +67,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -81,7 +81,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -92,13 +92,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'PythonPerformanceBenchmarkSuitedoc'
htmlhelp_basename = "PythonPerformanceBenchmarkSuitedoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -107,15 +107,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -125,8 +122,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PythonPerformanceBenchmarkSuite.tex', 'Python Performance Benchmark Suite Documentation',
'Victor Stinner', 'manual'),
(
master_doc,
"PythonPerformanceBenchmarkSuite.tex",
"Python Performance Benchmark Suite Documentation",
"Victor Stinner",
"manual",
),
]


Expand All @@ -135,8 +137,13 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pythonperformancebenchmarksuite', 'Python Performance Benchmark Suite Documentation',
[author], 1)
(
master_doc,
"pythonperformancebenchmarksuite",
"Python Performance Benchmark Suite Documentation",
[author],
1,
)
]


Expand All @@ -146,10 +153,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PythonPerformanceBenchmarkSuite', 'Python Performance Benchmark Suite Documentation',
author, 'PythonPerformanceBenchmarkSuite', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"PythonPerformanceBenchmarkSuite",
"Python Performance Benchmark Suite Documentation",
author,
"PythonPerformanceBenchmarkSuite",
"One line description of project.",
"Miscellaneous",
),
]



6 changes: 3 additions & 3 deletions pyperformance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@


VERSION = (1, 11, 0)
__version__ = '.'.join(map(str, VERSION))
__version__ = ".".join(map(str, VERSION))


PKG_ROOT = os.path.dirname(__file__)
DATA_DIR = os.path.join(PKG_ROOT, 'data-files')
DATA_DIR = os.path.join(PKG_ROOT, "data-files")


def is_installed():
Expand All @@ -22,7 +22,7 @@ def is_installed():

def is_dev():
parent = os.path.dirname(PKG_ROOT)
return os.path.exists(os.path.join(parent, 'pyproject.toml'))
return os.path.exists(os.path.join(parent, "pyproject.toml"))


def _is_venv():
Expand Down
1 change: 1 addition & 0 deletions pyperformance/__main__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import pyperformance.cli

pyperformance.cli.main()
Loading
Loading