Skip to content

Commit

Permalink
add C++11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Nov 21, 2020
1 parent b224dc2 commit 67b02ff
Show file tree
Hide file tree
Showing 9 changed files with 659 additions and 446 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/pythonbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,36 @@ jobs:
with:
path: ./wheelhouse/*.whl

build_wheels_manylinux1:
needs: [test_python]
name: Build wheel with manylinux1
runs-on: ubuntu-18.04
strategy:
fail-fast: false
env:
CIBW_BUILD: cp*
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
CIBW_MANYLINUX_I686_IMAGE: manylinux1

steps:
- uses: actions/checkout@v1
with:
submodules: 'true'

- uses: actions/setup-python@v1
name: Install Python
with:
python-version: '3.7'

- name: Install cibuildwheel
run: |
python -m pip install git+https://github.com/joerick/cibuildwheel.git@f6eaa9f
- name: Build wheels
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_wheels_python27_windows_64:
needs: [test_python]
Expand Down Expand Up @@ -173,7 +203,7 @@ jobs:

deploy-wheels:
if: github.event_name == 'release' && github.event.action == 'published'
needs: [build_wheels, build_wheels_python27_windows_64, build_wheels_python27_windows_32, build_sdist]
needs: [build_wheels, build_wheels_manylinux1, build_wheels_python27_windows_64, build_wheels_python27_windows_32, build_sdist]
name: deploy wheels to pypi
runs-on: ubuntu-18.04

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.2
0.13.3
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
'msvc': ['/EHsc', '/O2', '/std:c++14'],
'unix': ['-O3', '-std=c++14', '-Wextra', '-Wall'],
'msvc': ['/EHsc', '/O2', '/std:c++11'],
'unix': ['-O3', '-std=c++11', '-Wextra', '-Wall'],
}
l_opts = {
'msvc': [],
Expand Down
5 changes: 2 additions & 3 deletions src/py2_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/* Copyright © 2020 Max Bachmann */

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "details/types.hpp"
#include <Python.h>
#include <variant/variant.hpp>

bool valid_str(PyObject* str, const char* name)
Expand All @@ -23,7 +23,7 @@ bool valid_str(PyObject* str, const char* name)

using python_string =
mpark::variant<std::basic_string<uint8_t>, std::basic_string<Py_UNICODE>,
rapidfuzz::basic_string_view<uint8_t>, rapidfuzz::basic_string_view<Py_UNICODE>>;
rapidfuzz::basic_string_view<uint8_t>, rapidfuzz::basic_string_view<Py_UNICODE>>;

using python_string_view =
mpark::variant<rapidfuzz::basic_string_view<uint8_t>, rapidfuzz::basic_string_view<Py_UNICODE>>;
Expand Down Expand Up @@ -56,7 +56,6 @@ python_string_view decode_python_string_view(PyObject* py_str)
}
}


PyObject* encode_python_string(rapidfuzz::basic_string_view<uint8_t> str)
{
return PyString_FromStringAndSize(reinterpret_cast<const char*>(str.data()), str.size());
Expand Down
10 changes: 5 additions & 5 deletions src/py3_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/* Copyright © 2020 Max Bachmann */

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "details/types.hpp"
#include <Python.h>
#include <variant/variant.hpp>

bool valid_str(PyObject* str, const char* name)
Expand All @@ -15,7 +15,7 @@ bool valid_str(PyObject* str, const char* name)

// PEP 623 deprecates legacy strings and therefor
// deprecates e.g. PyUnicode_READY in Python 3.10
#if PY_VERSION_HEX < PYTHON_VERSION(3,10,0)
#if PY_VERSION_HEX < PYTHON_VERSION(3, 10, 0)
if (PyUnicode_READY(str)) {
return false;
}
Expand All @@ -33,9 +33,9 @@ bool valid_str(PyObject* str, const char* name)
}

using python_string =
mpark::variant<std::basic_string<uint8_t>, std::basic_string<uint16_t>, std::basic_string<uint32_t>,
rapidfuzz::basic_string_view<uint8_t>, rapidfuzz::basic_string_view<uint16_t>,
rapidfuzz::basic_string_view<uint32_t>>;
mpark::variant<std::basic_string<uint8_t>, std::basic_string<uint16_t>,
std::basic_string<uint32_t>, rapidfuzz::basic_string_view<uint8_t>,
rapidfuzz::basic_string_view<uint16_t>, rapidfuzz::basic_string_view<uint32_t>>;

using python_string_view =
mpark::variant<rapidfuzz::basic_string_view<uint8_t>, rapidfuzz::basic_string_view<uint16_t>,
Expand Down
Loading

0 comments on commit 67b02ff

Please sign in to comment.