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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- uses: actions/setup-python@v2
with:
Expand All @@ -47,13 +48,13 @@ jobs:
run: |
brew install ninja

- name: Prepare compiler environment for ${{ matrix.os }}
- name: Prepare build environment for ${{ matrix.os }}
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Set have package true for ${{ matrix.os }}
- name: Set GITHUB_ENV vars for ${{ matrix.os }}
if: runner.os == 'Linux'
run: |
echo "HAVE_LIBDATRIE_PKG=TRUE" >> $GITHUB_ENV
Expand All @@ -67,8 +68,6 @@ jobs:
packages: libdatrie-dev pybind11-dev ninja-build

- name: Test in place
# windows does not like build_ext -i or removing previous build
if: runner.os != 'Windows'
run: |
tox -e py

Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Conda

on:
workflow_dispatch:
#pull_request:
#push:
# branches:
# - master

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-2016, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

runs-on: ${{ matrix.platform }}

# The setup-miniconda action needs this to activate miniconda
defaults:
run:
shell: "bash -l {0}"

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Cache conda
uses: actions/cache@v1
with:
path: ~/conda_pkgs_dir
key: ${{matrix.os}}-conda-pkgs-${{hashFiles('**/conda.recipe/meta.yaml')}}

- name: Get conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: strict
use-only-tar-bz2: true
auto-activate-base: true

- name: Prepare
run: conda install conda-build conda-verify pytest hypothesis

- name: Build
run: conda build conda.recipe

- name: Install
run: conda install -c ${CONDA_PREFIX}/conda-bld/ datrie

- name: Test
run: pytest -v
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- uses: actions/setup-python@v2
name: Install Python
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- uses: actions/setup-python@v2
name: Install Python
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libdatrie"]
path = libdatrie
url = https://github.com/tlwg/libdatrie.git
30 changes: 20 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.15...3.18)

option(PY_DEBUG "Set if python being linked is a Py_DEBUG build" OFF)
option(GIT_SUBMODULE "Check submodules during build" ON)
option(USE_LIBDATRIE_PKG "Use OS-provided libdatrie package")
if(DEFINED ENV{HAVE_LIBDATRIE_PKG})
set(USE_LIBDATRIE_PKG "$ENV{HAVE_LIBDATRIE_PKG}")
Expand Down Expand Up @@ -30,17 +31,26 @@ if(USE_LIBDATRIE_PKG AND NOT Datrie_FOUND)
endif()

if(NOT USE_LIBDATRIE_PKG)
message(STATUS "Fetching libdatrie from github")
# Fetch libdatrie
include(FetchContent)
message(STATUS "Trying libdatrie submodule")
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
if(GIT_SUBMODULE)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/libdatrie/datrie-0.2.pc.in")
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
endif()

FetchContent_Declare(
libdatrie
GIT_REPOSITORY https://github.com/tlwg/libdatrie
GIT_TAG v0.2.13
)
FetchContent_MakeAvailable(libdatrie)
# this gets us the package source directory
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/libdatrie/datrie-0.2.pc.in")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
endif()

find_package(pybind11 CONFIG)
Expand Down
52 changes: 52 additions & 0 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% set name = "datrie" %}
{% set version = "0.8.3.dev0" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
path: ..

build:
number: 0
script: {{ PYTHON }} -m pip install . -vv

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
host:
- python
- cmake >=3.15
- pybind11
- ninja
- cython
- pip

run:
- python

test:
requires:
- pytest
- hypothesis
imports:
- datrie
source_files:
- tests
commands:
- python -m pytest

about:
home: "https://github.com/pytries"
license: LGPL-2.0-or-later
license_family: LGPL
license_file: COPYING
summary: "Fast, efficiently stored Trie for Python. Uses libdatrie."
doc_url: "https://github.com/pytries/datrie/blob/master/README.rst"
dev_url: "https://github.com/pytries/datrie"

extra:
recipe-maintainers:
- sarnold
1 change: 1 addition & 0 deletions libdatrie
Submodule libdatrie added at d1dfdb
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ add_custom_command(OUTPUT ${cython_output}
COMMENT "Cythonizing extension ${cython_src}")

if(NOT USE_LIBDATRIE_PKG)
# use the locally cloned source from FetchContent
set(DATRIE_INCLUDE_DIR "${libdatrie_SOURCE_DIR}")
# use the local git submodule
set(DATRIE_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/libdatrie")
file(GLOB_RECURSE DATRIE_SOURCES
LIST_DIRECTORIES true
"${libdatrie_SOURCE_DIR}/datrie/*.c")
"${DATRIE_INCLUDE_DIR}/datrie/*.c")
list(APPEND cython_output ${DATRIE_SOURCES})
include_directories(${DATRIE_INCLUDE_DIR})
endif()
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ passenv =
PIP_DOWNLOAD_CACHE

setenv =
PYTHONPATH=.
PYTHONPATH = {toxinidir}
#PYTHONPATH = {env:PYTHONPATH}{:}{toxinidir}

deps =
pip>=20.0.1
cython>=0.20
path
pytest
hypothesis

commands =
python setup.py build_ext --inplace
python -m pytest []
python -c "import path; path.Path('build').rmtree_p()"

[testenv:dev]
skip_install = true
Expand All @@ -56,6 +55,7 @@ deps =
path

commands=
# this command breaks on windows (permission error)
python -c "import path; path.Path('build').rmtree_p()"
pip install -e .[test]
flake8 src/
Expand Down