Skip to content
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

MAINT,DOC: pip and network connectivity defaults #1377

Merged
merged 8 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ By using the following markdown::
License: `BSD three-clause license
<http://opensource.org/licenses/BSD-3-Clause>`__.

Authors: Michael Droettboom, Pauli Virtanen
Authors: Michael Droettboom, Pauli Virtanen, asv Developers
22 changes: 13 additions & 9 deletions asv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import importlib
from pathlib import Path

import tomli

from .console import log
from . import util, build_cache

Expand Down Expand Up @@ -537,11 +539,15 @@ def __init__(self, conf, python, requirements, tagged_env_vars):
# XXX: What if pypy installed asv tries to benchmark a cpython
# python?
self._base_requirements["pip+pympler"] = ""
if (Path.cwd() / "poetry.lock").exists():
self._base_requirements["poetry-core"] = ""

if (Path.cwd() / "pdm.lock").exists():
self._base_requirements["pdm"] = ""
pyproject_path = Path.cwd() / "pyproject.toml"
if pyproject_path.exists():
self._base_requirements["build"] = ""
with open(pyproject_path, "rb") as pyproject_file:
pyproject_data = tomli.load(pyproject_file)
requires = pyproject_data.get("build-system", {}).get("requires", [])
for requirement in requires:
self._base_requirements[f"pip+{requirement}"] = ""

# Update the _base_requirements if needed
for key in list(self._requirements.keys()):
Expand Down Expand Up @@ -920,15 +926,13 @@ def has_file(file_name):
if cmd is None:
if has_file('pyproject.toml'):
cmd = [
("PIP_NO_BUILD_ISOLATION=false "
"python -mpip wheel --no-deps --no-index "
"-w {build_cache_dir} {build_dir}")
"python -m build",
"python -mpip wheel -w {build_cache_dir} {build_dir}"
]
else:
cmd = [
"python setup.py build",
("PIP_NO_BUILD_ISOLATION=false "
"python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}")
"python -mpip wheel -w {build_cache_dir} {build_dir}"
]

if cmd:
Expand Down
4 changes: 2 additions & 2 deletions asv/template/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
// "build_command": [
// "python -m pip install build",
// "python -m build",
// "PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
// "python -mpip wheel -w {build_cache_dir} {build_dir}"
// ],
// To build the package using setuptools and a setup.py file, uncomment the following lines
// "build_command": [
// "python setup.py build",
// "PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
// "python -mpip wheel -w {build_cache_dir} {build_dir}"
// ],

// Customizable commands for installing and uninstalling the project.
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/1377.feat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``asv`` will now correctly prepare all the build backend dependencies into
``base_requirements`` and the default ``build_command`` has been modified to
allow fetching from PyPI.
26 changes: 24 additions & 2 deletions docs/source/asv.conf.json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ The ``asv.conf.json`` file contains information about a particular
benchmarking project. The following describes each of the keys in
this file and their expected values.

.. note::

The GitHub repository at `asv_samples
<https://github.com/HaoZeke/asv_samples>`_ serves as a comprehensive
showcase for integrating Air Speed Velocity (ASV) with a wide array of
Python project configurations. This includes various build systems and
advanced benchmarking features like custom parameterizations and ASV
plugins, aiming to benchmark Python code performance across diverse setups.

The repository is structured with dedicated branches for each build system
and feature demonstration, providing insights into the impacts of different
build systems and ASV's extensible features on performance metrics.

.. only:: not man

.. contents::
Expand Down Expand Up @@ -71,6 +84,17 @@ The defaults are::
["python setup.py build",
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"],

.. note::

.. versionchanged:: 0.6.2

The default build command now assume network connectivity is not
prohibited. The ``build_command`` is now::

"build_command":
["python setup.py build",
"python -mpip wheel -w {build_cache_dir} {build_dir}"],

The install commands should install the project in the active Python
environment (virtualenv/conda), so that it can be used by the
benchmark code.
Expand All @@ -84,8 +108,6 @@ environment.

If a build command is not specified in the ``asv.conf.json``, the default
assumes the build system requirements are defined in a ``setup.py`` file.
However, the ``asv.conf.json`` template also includes as a comment the
commands to build the project using a ``pyproject.toml`` file.
``pyproject.toml`` is the preferred file format to define the build system
requirements of Python projects (`PEP518
<https://peps.python.org/pep-0518/>`_), and this approach will be the
Expand Down
7 changes: 4 additions & 3 deletions docs/source/benchmarks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ The following benchmark types are recognized:

.. note::

.. versionadded:: 0.6.0
.. versionadded:: 0.6.2

Users may define their own benchmark types, see ``asv_runner`` for
examples.
External benchmarks may be defined through ``asv_runner`` and a list of
benchmark plugins (like ``asv_bench_memray``) may be found here, with
samples at `asv_samples <https://github.com/HaoZeke/asv_samples>`_.

Benchmark attributes
--------------------
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ dynamic = [
"version",
]
dependencies = [
"asv-runner>=v0.1.0",
"asv-runner>=v0.2.1",
"json5",
"tabulate",
"virtualenv",
"tomli",
"colorama; platform_system == 'Windows'",
"pyyaml; platform_python_implementation != \"PyPy\"",
"pympler; platform_python_implementation != \"PyPy\"",
Expand Down Expand Up @@ -75,6 +76,9 @@ virtualenv = [
hg = [
"python-hglib",
]
plugs = [
"asv-bench-memray",
]
[build-system]
requires = [
"wheel",
Expand Down
Loading