Skip to content

Commit

Permalink
Merge pull request #270 from chris48s/flit
Browse files Browse the repository at this point in the history
poetry --> flit
  • Loading branch information
chris48s authored Oct 22, 2023
2 parents 508bc1c + ade2a42 commit 2d818a0
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 1,158 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
ignore = E501
exclude = geometry_to_spatialite/__init__.py
ignore = E501, W503
exclude = .venv, geometry_to_spatialite/__init__.py
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Install dependencies
run: |
pip install poetry
pip install flit
make install
- name: Build docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
sudo apt-get -qq update
sudo apt-get install -y libgeos-dev
pip install poetry
pip install flit
make install
- name: Deploy docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -20,4 +20,4 @@ jobs:
uses: chris48s/python-package-shared@main
with:
python-version: ${{ matrix.python-version }}
pre-install: poetry
pre-install: flit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
__pycache__/
*.pyc

# venv
.venv

# build artifacts
build/
dist/
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This project uses:

* [poetry](https://poetry.eustace.io/) for dependency management
* [flit](https://flit.pypa.io/en/stable/) for packaging
* [flake8](https://pypi.org/project/flake8/) for linting and
* [black](https://github.com/psf/black) for code formatting
* [isort](https://github.com/timothycrosley/isort) for import sorting
Expand All @@ -15,3 +15,8 @@ Development Tasks:
* Auto-format: `make format`
* Build the docs: `make build-docs`
* Deploy the docs: `make deploy-docs`

Virtual Env Management:

* `source .venv/bin/activate`
* `deactivate`
File renamed without changes.
38 changes: 25 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
SHELL := /bin/bash
.PHONY: help build-docs deploy-docs format install lint test build release
.PHONY: help build-docs deploy-docs build format install lint test release venv

help:
@grep '^\.PHONY' Makefile | cut -d' ' -f2- | tr ' ' '\n'

venv:
python3 -m venv .venv

build-docs:
cd docs && poetry run make clean html
source .venv/bin/activate && \
cd docs && make clean html

deploy-docs:
make build-docs
poetry run ghp-import -n -p docs/build/html/
source .venv/bin/activate && \
make build-docs &&
ghp-import -n -p docs/build/html/

format:
poetry run isort .
poetry run black .
source .venv/bin/activate && \
isort . && \
black .

install:
poetry install
python3 -m venv .venv
source .venv/bin/activate && \
pip install -e .[dev]

lint:
poetry run isort -c --diff .
poetry run black --check .
poetry run flake8 .
source .venv/bin/activate && \
isort -c --diff . && \
black --check . && \
flake8 .

test:
poetry run coverage run --source=geometry_to_spatialite ./run_tests.py
poetry run coverage xml
source .venv/bin/activate && \
coverage run --source=geometry_to_spatialite ./run_tests.py && \
coverage xml

build:
poetry build
source .venv/bin/activate && \
flit build

release:
# usage: `make release version=0.0.0`
make test
@echo ""
make lint
@echo ""
source .venv/bin/activate && \
./release.sh "$(version)"
1 change: 1 addition & 0 deletions geometry_to_spatialite/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.4.0"
1,105 changes: 0 additions & 1,105 deletions poetry.lock

This file was deleted.

69 changes: 44 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
[tool.poetry]
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "geometry-to-spatialite"
version = "0.4.0"
authors = [{name = "chris48s"}]
description = "Import geographic and spatial data from files into a SpatiaLite DB"
authors = ["chris48s"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/chris48s/geometry-to-spatialite"
homepage = "https://github.com/chris48s/geometry-to-spatialite"
documentation = "https://chris48s.github.io/geometry-to-spatialite"
license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
requires-python = ">=3.8"
dependencies = [
"sqlite-utils>=2.1,<4.0",
"Shapely>=1.6.4,<3.0.0",
"pyshp>=2.1.0,<3.0.0"
]

[tool.poetry.dependencies]
python = ">=3.8"
sqlite-utils = ">=2.1,<4.0"
Shapely = ">=1.6.4,<3.0.0"
pyshp = "^2.1.0"
[project.optional-dependencies]
dev = [
"flit==3.9.0",
"isort==5.12.0",
"flake8==6.1.0",
"black==23.9.1",
"coverage==7.3.1",
"sphinx==7.1.2",
"sphinx_rtd_theme==1.3.0",
"myst-parser==2.0.0",
"ghp-import==2.1.0"
]

[tool.poetry.dev-dependencies]
isort = "^5.12"
flake8 = "^5.0.4"
black = "==23.9.1"
coverage = "^7.3"
sphinx = "^7.1.2"
sphinx_rtd_theme = "^1.3.0"
myst-parser = "^2.0.0"
ghp-import = "^2.1.0"
[project.urls]
Home = "https://github.com/chris48s/geometry-to-spatialite"
Source = "https://github.com/chris48s/geometry-to-spatialite"
Documentation = "https://chris48s.github.io/geometry-to-spatialite"

[tool.poetry.scripts]
[tool.flit.module]
name = "geometry_to_spatialite"

[project.scripts]
geojson-to-spatialite = 'geometry_to_spatialite.geojson:main'
shapefile-to-spatialite = 'geometry_to_spatialite.shapefile:main'
[build-system]
requires = ["poetry>=1.0.2"]
build-backend = "poetry.masonry.api"
18 changes: 10 additions & 8 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

# read version + ensure non-empty
VERSION="$1"
[ -z "$VERSION" ] && echo "Error: No version specified" && exit 1
[ -z "$VERSION" ] && echo "Error: No version specified" && exit 1

# ensure work tree is clean (aside from CHANGELOG.md)
if [[ ! $(git status --porcelain | grep -vc "CHANGELOG.md") -eq 0 ]]; then
Expand All @@ -25,8 +25,14 @@ then
exit 1
fi

if ! type "flit" > /dev/null;
then
echo "Flit is not installed"
exit 1
fi

# confirm
read -r -p "Bump version from $(poetry version --short) to $VERSION. Are you sure? [y/n] " response
read -r -p "Bump version from $(cut -d '"' -f2 < geometry_to_spatialite/__version__.py) to $VERSION. Are you sure? [y/n] " response
response=${response,,} # tolower
if [[ ! "$response" =~ ^(yes|y)$ ]]; then
exit 1
Expand All @@ -35,21 +41,17 @@ fi
# checks done, now publish the release...

# bump version
poetry version "$VERSION"
echo '__version__ = "'"$VERSION"'"' > geometry_to_spatialite/__version__.py

# commit
git add geometry_to_spatialite/__version__.py
git add pyproject.toml
git add CHANGELOG.md
git commit -m "version $VERSION"

# tag
git tag "$VERSION"

# build and push to PyPI
poetry install
poetry build
poetry publish

# push to GitHub
git push origin "$(git branch --show-current)" --tags

Expand Down

0 comments on commit 2d818a0

Please sign in to comment.