Skip to content

Commit

Permalink
Reorganize the repo for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Oct 24, 2023
1 parent b6c4bcf commit 63effa2
Show file tree
Hide file tree
Showing 53 changed files with 1,670 additions and 193 deletions.
82 changes: 21 additions & 61 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,76 +1,36 @@
*node_modules/
*.sqlite3
.project
.pydevproject
.settings
.idea
coverage_html_report/
test_db
pyvenv.cfg
# virtualenv
.venv
/email
.pytest_cache
.pycheck.db
.ruff_cache
tasks.sqlite
tasks.sqlite-shm
tasks.sqlite-wal
centrifugo/centrifugo

# Packaging
build
dist
*.egg-info

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
!docsite/dist
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
bin/
*.egg-info/
.installed.cfg
*.egg
# Created by pycheck install
package.json
yarn.lock

# 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
.pytest_cache
nosetests.xml
coverage.xml
*,cover
.tox

# Django stuff:
*.log
# VS Code
.vscode

# Sphinx documentation
docs/_build/
# Mac Os
.DS_Store

# PyBuilder
# Temp files
*~
.~lock*

# Swap files
*.sw[po]

# Logging files
*.log
24 changes: 24 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Define proper build config
build:
os: "ubuntu-22.04"
tools:
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- method: pip
path: .
extra_requirements:
- doc
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

=========
Changelog
=========

Version 0.1.0 - Unreleased
**************************

* First commit.
21 changes: 21 additions & 0 deletions LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023, emencia

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.
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include MANIFEST.in
include LICENCE.txt
include README.rst

exclude sphinx_reload.py

recursive-exclude tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
175 changes: 175 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
PYTHON_INTERPRETER=python3
VENV_PATH=.venv

PYTHON_BIN=$(VENV_PATH)/bin/python
PIP_BIN=$(VENV_PATH)/bin/pip
FLAKE_BIN=$(VENV_PATH)/bin/flake8
PYTEST_BIN=$(VENV_PATH)/bin/pytest
SPHINX_RELOAD_BIN=$(PYTHON_BIN) docs/sphinx_reload.py
TOX_BIN=$(VENV_PATH)/bin/tox
TWINE_BIN=$(VENV_PATH)/bin/twine

PACKAGE_NAME=locallm
PACKAGE_SLUG=locallm
APPLICATION_NAME=locallm

# Formatting variables, FORMATRESET is always to be used last to close formatting
FORMATBLUE:=$(shell tput setab 4)
FORMATGREEN:=$(shell tput setab 2)
FORMATRED:=$(shell tput setab 1)
FORMATBOLD:=$(shell tput bold)
FORMATRESET:=$(shell tput sgr0)

help:
@echo "Please use 'make <target> [<target>...]' where <target> is one of"
@echo
@echo " Cleaning"
@echo " ========"
@echo
@echo " clean -- to clean EVERYTHING (Warning)"
@echo " clean-doc -- to remove documentation builds"
@echo " clean-install -- to clean Python side installation"
@echo " clean-pycache -- to recursively remove all Python cache files"
@echo
@echo " Documentation"
@echo " ============="
@echo
@echo " docs -- to build documentation"
@echo " livedocs -- to run a 'live reloaded' server for documentation"
@echo
@echo " Installation"
@echo " ============"
@echo
@echo " freeze-dependencies -- to write installed dependencies versions in frozen.txt"
@echo " install -- to install this project with virtualenv and Pip"
@echo
@echo " Quality"
@echo " ======="
@echo
@echo " check-release -- to check package release before uploading it to PyPi"
@echo " flake -- to launch Flake8 checking"
@echo " quality -- to launch run quality tasks and checks"
@echo " test -- to launch base test suite using Pytest"
@echo " tox -- to launch tests for every Tox environments"
@echo
@echo " Release"
@echo " ======="
@echo
@echo " release -- to release latest package version on PyPi"
@echo

clean-pycache:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear Python cache <---$(FORMATRESET)\n"
@echo ""
rm -Rf .pytest_cache
find . -type d -name "__pycache__"|xargs rm -Rf
find . -name "*\.pyc"|xargs rm -f
.PHONY: clean-pycache

clean-install:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear installation <---$(FORMATRESET)\n"
@echo ""
rm -Rf $(VENV_PATH)
rm -Rf $(PACKAGE_SLUG).egg-info
.PHONY: clean-install

clean-doc:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear documentation <---$(FORMATRESET)\n"
@echo ""
rm -Rf docs/_build
.PHONY: clean-doc

clean: clean-doc clean-install clean-pycache
.PHONY: clean

venv:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Install virtual environment <---$(FORMATRESET)\n"
@echo ""
virtualenv -p $(PYTHON_INTERPRETER) $(VENV_PATH)
# Uncomment these two lines if you want development install support on old
# distributions (<2020)
#$(PIP_BIN) install --upgrade pip
#$(PIP_BIN) install --upgrade setuptools
.PHONY: venv

install: venv
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Install everything for development <---$(FORMATRESET)\n"
@echo ""
$(PIP_BIN) install -e .[dev,quality,doc,doc-live]
.PHONY: install

docs:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Build documentation <---$(FORMATRESET)\n"
@echo ""
cd docs && make html
.PHONY: docs

livedocs:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Watching documentation sources <---$(FORMATRESET)\n"
@echo ""
$(SPHINX_RELOAD_BIN)
.PHONY: livedocs

flake:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Flake <---$(FORMATRESET)\n"
@echo ""
$(FLAKE_BIN) --statistics --show-source $(APPLICATION_NAME) tests
.PHONY: flake

test:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Tests <---$(FORMATRESET)\n"
@echo ""
$(PYTEST_BIN) -vv tests/
.PHONY: test

freeze-dependencies:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Freeze dependencies versions <---$(FORMATRESET)\n"
@echo ""
$(VENV_PATH)/bin/python freezer.py
.PHONY: freeze-dependencies

build-package:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Build package <---$(FORMATRESET)\n"
@echo ""
rm -Rf dist
$(VENV_PATH)/bin/python setup.py sdist
.PHONY: build-package

release: build-package
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Release package <---$(FORMATRESET)\n"
@echo ""
$(TWINE_BIN) upload dist/*
.PHONY: release

check-release: build-package
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Check package <---$(FORMATRESET)\n"
@echo ""
$(TWINE_BIN) check dist/*
.PHONY: check-release

tox:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Launch all Tox environments <---$(FORMATRESET)\n"
@echo ""
$(TOX_BIN)
.PHONY: tox

quality: test flake docs check-release freeze-dependencies
@echo ""
@printf "$(FORMATGREEN)$(FORMATBOLD) ♥ ♥ Everything should be fine ♥ ♥ $(FORMATRESET)\n"
@echo ""
@echo ""
.PHONY: quality
Loading

0 comments on commit 63effa2

Please sign in to comment.