Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed Feb 22, 2024
1 parent 5f8c8b1 commit 6168808
Show file tree
Hide file tree
Showing 35 changed files with 1,160 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!python-versions.txt
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy

on:
release:
types: [published]

jobs:

deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test

on: [push]

jobs:
test:
runs-on: ubuntu-latest
name: Python ${{ matrix.python-version }} sample
strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9, 'pypy-3.6', 'pypy-3.7' ]
continue-on-error: false
services:
database:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DJANGO_DATABASE_HOST: localhost
DJANGO_DATABASE_USER: postgres
DJANGO_DATABASE_PASSWORD: postgres
DJANGO_DATABASE_NAME: postgres

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Depedencies
run: |
python -m pip install wheel
python -m pip install pytest pytest-django pytest-cov psycopg2-binary
python setup.py develop
- name: Run tests
run: >-
pytest -v -x
--cov=django_ltree
--junitxml=junit/test-results-${{ matrix.python-version }}.xml
tests/
- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
if: ${{ always() }}
110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# OS Stuff
.DS_Store
*.swp

.idea
56 changes: 56 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
sudo: false
language: python
cache: pip
python:
- 2.7
- 3.6
- 3.7
- 3.8

services:
- postgresql

install:
- pip install tox-travis
- pip install coverage codecov
- pip install wheel

script:
- tox

after_success:
- pip install codecov coveralls
- codecov --required -n "py${TRAVIS_PYTHON_VERSION}"
- "COVERALLS_PARALLEL=true coveralls"

notifications:
webhooks: https://coveralls.io/webhook

stages:
- test
- name: publish
if: tag IS present

jobs:
fast_finish: true
include:

- stage: test
python: 3.8

- stage: publish
python: 3.8
install: true
script: python setup.py sdist bdist_wheel
after_success: true
deploy:
edge: true
provider: releases
name: $TRAVIS_TAG
target_commitish: $TRAVIS_COMMIT
api_key: "$GITHUB_OAUTH_TOKEN"
skip_cleanup: true
file: dist/*
on:
branch: master
tags: true
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"M. César Señoranis" (github.com/mariocesar) mariocesar@humanzilla.com
"Borys Szefczyk" (github.com/boryszef) boryszef@gmail.com
"Thomas Stephenson" (github.com/ovangle) ovangle
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:18.04

ENV DEBIAN_FRONTEND=noninteractive \
LANG="en_US.UTF-8" \
LC_COLLATE="C" \
LC_ALL="en_US.UTF-8" \
PYENV_ROOT="/.pyenv" \
PATH="/.pyenv/bin:/.pyenv/shims:$PATH" \
TERM="xterm-256color"

RUN set -eux \
&& apt-get update \
# Common build deps
&& apt-get install -y --no-install-recommends locales git curl ca-certificates \
# Setup locales
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
# Get Pyenv installer
&& curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \
# Pyenv build dependencies
&& apt-get install -y --no-install-recommends \
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev libpq-dev \
# Cleanup
&& apt-get purge -y --auto-remove curl \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY python-versions.txt ./

RUN set -eux \
&& pyenv update \
&& xargs -n 1 pyenv install < python-versions.txt \
&& pyenv global $(pyenv versions --bare) \
&& mv -v -- /python-versions.txt $PYENV_ROOT/version

WORKDIR /app
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2018 Mario César
Copyright (c) 2019 Borys Szefczyk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

default:
pip install -e .[develop]

publish: clean
python setup.py sdist bdist_wheel
twine upload dist/*

clean:
rm -rf dist/
rm -rf build/

backend:
docker-compose run --rm --service-ports backend bash
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# django-ltree

A tree extension implementation to support hierarchical tree-like data in Django models,
using the native Postgres extension `ltree`.

Postgresql has already a optimized and very useful tree implementation for data.
The extension is [ltree](https://www.postgresql.org/docs/9.6/static/ltree.html)

This fork contains a backport to Django 1.11 and Python 3.6.

[![Test](https://github.com/mariocesar/django-ltree/actions/workflows/test.yml/badge.svg)](https://github.com/mariocesar/django-ltree/actions/workflows/test.yml)


## Links

- Pypi https://pypi.org/project/django-ltree/
- Source code https://github.com/mariocesar/django-ltree
- Bugs https://github.com/mariocesar/django-ltree/issues
- Contribute https://github.com/mariocesar/django-ltree/pulls
- Documentation `TODO`

## Install

```
pip install django-ltree
```

Then add `django_ltree` to `INSTALLED_APPS` in your Django project settings.

And make sure to run `django_ltree` migrations before you added the `PathField`

```
python manage.py migrate django_ltree
```

`django_ltree` migrations will install the `ltree` extension if not exist.

You can alternatively specify the `django_ltree` dependency in the migrations of
your applications that requires `PathField`, and run migrations smoothly.

```
class Migration(migrations.Migration):
dependencies = [
('django_ltree', '__latest__'),
]
```

## Requires

- Django 1.11 or superior
- Python 2

## Testing

Make sure you have Postgres installed. Then simply run `tox` in the root directory of the project.
1 change: 1 addition & 0 deletions django_ltree/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'django_ltree.apps.DjangoLtreeConfig'
Loading

0 comments on commit 6168808

Please sign in to comment.