diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1de947d..3242eaf5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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 @@ -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 run: | pip install sphinx sphinx_rtd_theme breathe ipython diff --git a/MANIFEST.in b/MANIFEST.in index e403c0d0..ac2509f0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/Makefile b/Makefile index 839b3bb8..09e6e39e 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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 diff --git a/README.rst b/README.rst index 6fa83036..93a1ae06 100644 --- a/README.rst +++ b/README.rst @@ -25,7 +25,7 @@ libpy supports: libpy requires: -- gcc>=8 or clang>=10 +- gcc>=9 or clang>=10 - numpy>=1.11.3 Optional Requirements diff --git a/docs/source/install.rst b/docs/source/install.rst index 0381e361..78ae57b6 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -11,7 +11,7 @@ lipy supports: lipy requires: -- gcc>=8 or clang>=10 +- gcc>=9 or clang>=10 - numpy>=1.11.3 Optional Requirements diff --git a/etc/Makefile.buildkite b/etc/Makefile.buildkite deleted file mode 100644 index 2184ab17..00000000 --- a/etc/Makefile.buildkite +++ /dev/null @@ -1,7 +0,0 @@ -CXX := g++-8 -CC := gcc-8 -GCOV := gcov-8 -AR := gcc-ar-8 -ASAN_SYMBOLIZER_PATH := llvm-symbolizer-6 -CLANG_TIDY := clang-tidy-6 -CLANG_FORMAT := clang-format-6 diff --git a/etc/ld_flags.py b/etc/ld_flags.py new file mode 100644 index 00000000..d2687b28 --- /dev/null +++ b/etc/ld_flags.py @@ -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)) diff --git a/include/libpy/to_object.h b/include/libpy/to_object.h index d9be3b28..61e526c8 100644 --- a/include/libpy/to_object.h +++ b/include/libpy/to_object.h @@ -142,7 +142,7 @@ struct to_object { 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(); @@ -158,9 +158,6 @@ struct to_object { throw py::exception(); } return path_obj; -#else - return path_str; -#endif } }; diff --git a/tests/test_to_object.cc b/tests/test_to_object.cc index 388a7972..4257b991 100644 --- a/tests/test_to_object.cc +++ b/tests/test_to_object.cc @@ -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); }