Skip to content
Draft
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
15 changes: 13 additions & 2 deletions .github/bottleneck-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ description: "checkout repo, build, and test bottleneck"
runs:
using: composite
steps:
- name: Set up Python ${{ matrix.python-version }}
- name: Set up uv + Python ${{ matrix.python-version }}
if: ${{ !startsWith( matrix.os , 'windows' ) }}
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
with:
python-version: ${{ matrix.python-version }}
prune-cache: false
- name: Set up uv + Python ${{ matrix.python-version }}
if: ${{ startsWith( matrix.os , 'windows' ) }}
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
with:
python-version: ${{ matrix.python-version }}
prune-cache: false
- name: Install
shell: bash
run: |
uv sync --no-editable --group test ${{ case( endsWith(matrix.python-version, 't'), '--group concurrency', '' ) }}
uv venv
uv pip install pkgconf==2.5.1.post1
uv sync --inexact --no-editable --group test \
${{ case( endsWith(matrix.python-version, 't'), '--group concurrency', '' ) }} \
${{ case( startsWith(matrix.os, 'windows'), '-Csetup-args=--vsenv', '' ) }}

- name: Test with pytest
shell: bash
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,30 @@ on: ["push", "pull_request"]
permissions: {}

jobs:
test-build-helpers:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
- "3.15"
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
no-project: true
- run: uvx pytest build_helpers

test-linux-macos:
needs: [test-build-helpers]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -25,6 +48,7 @@ jobs:
- uses: ./.github/bottleneck-action

test-windows:
needs: [test-build-helpers]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -53,9 +77,17 @@ jobs:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this duplicates a Python install from ./.github/bottleneck-action with setup-uv.

uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
allow-prereleases: true
- run: echo "UV_PYTHON_PREFERENCE=only-system" >> "$GITHUB_ENV"
- uses: ./.github/bottleneck-action

test-pyversions:
needs: [test-build-helpers]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -125,6 +157,12 @@ jobs:
fetch-depth: 0
persist-credentials: false

- name: Setup MSVC (32-bit)
if: ${{ startsWith(runner.os, 'windows') && matrix.archs == 'x86' }}
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
with:
architecture: 'x86'

- name: Build wheels
uses: pypa/cibuildwheel@e090b81e30c4d855ea63bf4b6e59204c09a101ae # v4.2.1
env:
Expand Down
20 changes: 0 additions & 20 deletions MANIFEST.in

This file was deleted.

65 changes: 0 additions & 65 deletions Makefile

This file was deleted.

8 changes: 1 addition & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,12 @@ Unit tests pytest
Documentation sphinx, numpydoc
======================== ============================================================================

To install Bottleneck on Linux, Mac OS X, et al.:
To install Bottleneck:

.. code-block:: console

$ pip install .

To install bottleneck on Windows, first install MinGW and add it to your
system path. Then install Bottleneck with the command:

.. code-block:: console

$ python setup.py install --compiler=mingw32

Unit tests
==========
Expand Down
11 changes: 5 additions & 6 deletions bottleneck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@
test = PytestTester(__name__)
del PytestTester

from ._version import get_versions # noqa: E402

__version__ = get_versions()["version"]
del get_versions
def __getitem__(key: str):
if key == "__version__":
from importlib.metadata import version

from . import _version # noqa: E402

__version__ = _version.get_versions()["version"]
return version("bottleneck")
raise AttributeError
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions bottleneck/tests/test_template.py

This file was deleted.

Empty file added build_helpers/__init__.py
Empty file.
57 changes: 41 additions & 16 deletions bottleneck/src/bn_config.py → build_helpers/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
"""Based on numpy's approach to exposing compiler features via a config header.
Unfortunately that file is not exposed, so re-implement the portions we need.
"""

import os
import textwrap
from pathlib import Path

OPTIONAL_FUNCTION_ATTRIBUTES = [
("HAVE_ATTRIBUTE_OPTIMIZE_OPT_3", '__attribute__((optimize("O3")))')
Expand Down Expand Up @@ -90,25 +91,27 @@ def check_gcc_function_attribute(cmd, attribute, name):
return cmd.try_compile(body, None, None) != 0


def create_config_h(config):
dirname = os.path.dirname(__file__)
config_h = os.path.join(dirname, "bn_config.h")

if (
os.path.exists(config_h)
and os.stat(__file__).st_mtime < os.stat(config_h).st_mtime
):
return
def create_config_h(config, output_dir: Path):
config_h = output_dir / "bn_config.h"
# this_script = Path(__file__)
# if (
# config_h.exists()
# and this_script.stat().st_mtime < config_h.stat().st_mtime
# ):
# return

output = []

for config_attr, func_attr in OPTIONAL_FUNCTION_ATTRIBUTES:
if check_gcc_function_attribute(config, func_attr, config_attr.lower()):
output.append((config_attr, "1"))
else:
output.append((config_attr, "0"))
if config is not None:
for config_attr, func_attr in OPTIONAL_FUNCTION_ATTRIBUTES:
if check_gcc_function_attribute(config, func_attr, config_attr.lower()):
output.append((config_attr, "1"))
else:
output.append((config_attr, "0"))

inline_alias = check_inline(config)
inline_alias = check_inline(config)
else:
inline_alias = ""

with open(config_h, "w") as f:
for setting in output:
Expand All @@ -118,3 +121,25 @@ def create_config_h(config):
f.write("/* undef inline */\n")
else:
f.write(f"#define inline {inline_alias}\n")
print(f"wrote {config_h}")


def main(argv: list[str] | None = None) -> int:
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument(
"-o",
dest="output_dir",
help="output directory",
)
args = parser.parse_args(argv)
create_config_h(
config=None,
output_dir=Path(args.output_dir),
)
return 0


if __name__ == "__main__":
raise SystemExit(main())
Loading
Loading