Skip to content

Commit

Permalink
Merge pull request #40 from zopefoundation/config-with-c-code
Browse files Browse the repository at this point in the history
Update to the latest c-code template
  • Loading branch information
mgedmin committed Sep 14, 2022
2 parents acc1dfb + 755b2a7 commit eae9bc3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 9 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ env:
PIP_NO_PYTHON_VERSION_WARNING: 1
PIP_NO_WARN_SCRIPT_LOCATION: 1

CFLAGS: -Ofast -pipe
CXXFLAGS: -Ofast -pipe
CFLAGS: -O3 -pipe
CXXFLAGS: -O3 -pipe
# Uploading built wheels for releases.
# TWINE_PASSWORD is encrypted and stored directly in the
# github repo settings.
Expand Down Expand Up @@ -91,6 +91,7 @@ jobs:
# Sigh. Note that the matrix must be kept in sync
# with `test`, and `docs` must use a subset.
runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -141,18 +142,36 @@ jobs:
- name: Install Build Dependencies (PyPy2)
if: >
startsWith(matrix.python-version, 'pypy-2.7')
startsWith(matrix.python-version, 'pypy-2.7')
run: |
pip install -U pip
pip install -U setuptools wheel twine "cffi != 1.15.1"
- name: Install Build Dependencies (other Python versions)
if: >
!startsWith(matrix.python-version, 'pypy-2.7')
!startsWith(matrix.python-version, 'pypy-2.7')
run: |
pip install -U pip
pip install -U setuptools wheel twine cffi
- name: Build zope.index
- name: Build zope.index (Python 3.10 on MacOS)
if: >
startsWith(runner.os, 'Mac')
&& startsWith(matrix.python-version, '3.10')
env:
_PYTHON_HOST_PLATFORM: macosx-11-x86_64
run: |
# Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure
# output (pip install uses a random temporary directory, making this difficult).
python setup.py build_ext -i
python setup.py bdist_wheel
# Also install it, so that we get dependencies in the (pip) cache.
pip install -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"'
pip install .[test]
- name: Build zope.index (all other versions)
if: >
!startsWith(runner.os, 'Mac')
|| !startsWith(matrix.python-version, '3.10')
run: |
# Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure
# output (pip install uses a random temporary directory, making this difficult).
Expand Down
18 changes: 16 additions & 2 deletions .manylinux-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ ls -ld /cache/pip
# We need some libraries because we build wheels from scratch:
yum -y install libffi-devel

tox_env_map() {
case $1 in
*"cp27"*) echo 'py27';;
*"cp35"*) echo 'py35';;
*"cp36"*) echo 'py36';;
*"cp37"*) echo 'py37';;
*"cp38"*) echo 'py38';;
*"cp39"*) echo 'py39';;
*"cp310"*) echo 'py310';;
*) echo 'py';;
esac
}

# Compile wheels
for PYBIN in /opt/python/*/bin; do
if \
Expand All @@ -40,8 +53,9 @@ for PYBIN in /opt/python/*/bin; do
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
if [ `uname -m` == 'aarch64' ]; then
cd /io/
"${PYBIN}/pip" install tox
"${PYBIN}/tox" -e py
${PYBIN}/pip install tox
TOXENV=$(tox_env_map "${PYBIN}")
${PYBIN}/tox -e ${TOXENV}
cd ..
fi
rm -rf /io/build /io/*.egg-info
Expand Down
2 changes: 1 addition & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/zopefoundation/meta/tree/master/config/c-code
[meta]
template = "c-code"
commit-id = "cde9741a5a0d9d04cee25cb617ee1590afebb17d"
commit-id = "acc1dfb686e114c78aae58d975d51acdf6b54bff"

[python]
with-appveyor = true
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
5.2.1 (unreleased)
==================

- Nothing changed yet.
- Disable unsafe math optimizations in C code. See `pull request 40
<https://github.com/zopefoundation/zope.index/pull/40>`_.


5.2.0 (2022-04-06)
Expand Down
Empty file.
30 changes: 30 additions & 0 deletions src/zope/index/tests/test_compile_flags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
##############################################################################
#
# Copyright (c) 2022 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import struct
import unittest

# try to load a C module for side effectsa
import zope.index.text.okapiindex # noqa


class TestFloatingPoint(unittest.TestCase):

def test_no_fast_math_optimization(self):
# Building with -Ofast enables -ffast-math, which sets certain FPU
# flags that can cause breakage elsewhere. A library such as BTrees
# has no business changing global FPU flags for the entire process.
zero_bits = struct.unpack("!Q", struct.pack("!d", 0.0))[0]
next_up = zero_bits + 1
smallest_subnormal = struct.unpack("!d", struct.pack("!Q", next_up))[0]
self.assertNotEqual(smallest_subnormal, 0.0)
File renamed without changes.

0 comments on commit eae9bc3

Please sign in to comment.