Skip to content
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
17 changes: 11 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15]
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15]
python-version: [3.5, 3.6, 3.8]
compiler: [gcc, clang]
exclude:
Expand All @@ -32,11 +32,15 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set release name env variable (ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
echo ::set-env name=UBUNTU_RELEASE::$(lsb_release -sc)
- name: Install newer clang (ubuntu)
if: startsWith(matrix.os, 'ubuntu') && matrix.compiler == 'clang'
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' -y
sudo add-apt-repository "deb http://apt.llvm.org/$UBUNTU_RELEASE/ llvm-toolchain-$UBUNTU_RELEASE-10 main" -y
sudo apt-get update -q
sudo apt-get install -y clang-10 lld-10 libc++-10-dev libc++abi-10-dev clang-tools-10
echo ::set-env name=AR::llvm-ar-10
Expand Down Expand Up @@ -78,14 +82,15 @@ jobs:
- name: Set gcc envvars
if: matrix.compiler == 'gcc'
run: |
echo ::set-env name=CC::gcc-8
echo ::set-env name=CXX::g++-8
echo ::set-env name=CC::gcc-9
echo ::set-env name=CXX::g++-9
- name: Run the tests
run: |
make -j2 test
- name: Check that we can still install
- name: Build and install from an sdist
run: |
pip install .
python setup.py sdist
pip install dist/libpy-*.tar.gz
- name: Check that docs can be built
# note we don't build this on macOS because the GHA python is built with
# the wrong version of macOS, confusing clang.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include etc/detect-compiler.cc
include etc/build-and-run
include etc/ext_suffix.py
include etc/asan-path
include etc/ld_flags.py
include etc/python_version.py
include version
recursive-include src/ *.cc
Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ CXXFLAGS = $(BASE_CXXFLAGS) $($(COMPILER)_FLAGS)

# https://github.com/quantopian/libpy/pull/86/files#r309288697
INCLUDE_DIRS := include/ \
$(shell $(PYTHON) -c "from distutils import sysconfig; \
print(sysconfig.get_config_var('INCLUDEPY'))") \
$(shell $(PYTHON) -c "from distutils import sysconfig; \
print(sysconfig.get_config_var('INCLUDEDIR'))") \
$(shell $(PYTHON) -c "import sysconfig; \
print(sysconfig.get_config_var('INCLDIRSTOMAKE'))") \
$(shell $(PYTHON) -c 'import numpy as np;print(np.get_include())') \
$(EXTRA_INCLUDE_DIRS)
INCLUDE := $(foreach d,$(INCLUDE_DIRS), -I$d)
Expand All @@ -92,7 +90,7 @@ else
CXXFLAGS += -fstack-protector-strong
SONAME_FLAG := soname
SONAME_PATH := $(SONAME)
LDFLAGS += $(shell $(PYTHON)-config --ldflags)
LDFLAGS += $(shell $(PYTHON) etc/ld_flags.py)
LDFLAGS += -lstdc++fs
LD_PRELOAD_VAR := LD_PRELOAD
endif
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ libpy supports:

libpy requires:

- gcc>=8 or clang>=10
- gcc>=9 or clang>=10
- numpy>=1.11.3

Optional Requirements
Expand Down
2 changes: 1 addition & 1 deletion docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lipy supports:

lipy requires:

- gcc>=8 or clang>=10
- gcc>=9 or clang>=10
- numpy>=1.11.3

Optional Requirements
Expand Down
7 changes: 0 additions & 7 deletions etc/Makefile.buildkite

This file was deleted.

14 changes: 14 additions & 0 deletions etc/ld_flags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# via https://github.com/python/cpython/blob/deb016224cc506503fb05e821a60158c83918ed4/Misc/python-config.in#L50 # noqa

import sysconfig

libs = []
libpl = sysconfig.get_config_vars('LIBPL')
if libpl:
libs.append("-L"+libpl[0])

libpython = sysconfig.get_config_var('LIBPYTHON')
if libpython:
libs.append(libpython)
libs.extend(sysconfig.get_config_vars("LIBS", "SYSLIBS"))
print(' '.join(libs))
5 changes: 1 addition & 4 deletions include/libpy/to_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct to_object<std::filesystem::path> {
static py::owned_ref<> f(const std::filesystem::path& path) {
py::owned_ref path_str{
PyUnicode_FromStringAndSize(path.c_str(), path.native().length())};
#if PY_VERSION_HEX >= 0x03040000

py::owned_ref pathlib(PyImport_ImportModule("pathlib"));
if (!pathlib) {
throw py::exception();
Expand All @@ -158,9 +158,6 @@ struct to_object<std::filesystem::path> {
throw py::exception();
}
return path_obj;
#else
return path_str;
#endif
}
};

Expand Down
7 changes: 2 additions & 5 deletions tests/test_to_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,16 @@ TEST_F(to_object, filesystem_path) {
std::filesystem::path test_path = "/tmp/";
py::owned_ref ob = py::to_object(test_path);
ASSERT_TRUE(ob);
#if PY_VERSION_HEX >= 0x03040000

py::owned_ref ns = RUN_PYTHON(R"(
from pathlib import Path
py_path = Path("/tmp/")
)");
ASSERT_TRUE(ns);

py::owned_ref py_path_ob{PyDict_GetItemString(ns.get(), "py_path")};
py::borrowed_ref py_path_ob = PyDict_GetItemString(ns.get(), "py_path");
ASSERT_TRUE(py_path_ob);
#else
py::owned_ref py_path_ob = py::to_object("/tmp/");

#endif
int eq = PyObject_RichCompareBool(ob.get(), py_path_ob.get(), Py_EQ);
EXPECT_EQ(eq, 1);
}
Expand Down