Skip to content

Commit

Permalink
moving from poetry to simple pip
Browse files Browse the repository at this point in the history
  • Loading branch information
anikolaienko committed May 12, 2024
1 parent 775e360 commit 7877946
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 123 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 11 additions & 15 deletions .github/workflows/run_code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Run code checks
on:
push:
branches: [main]
tags:
pull_request:
branches:
- main
Expand All @@ -14,28 +13,25 @@ jobs:
runs-on: ubuntu-20.04
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@v3
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install tools
run: pip install -r dev-requirements.txt

- name: Poetry install
run: poetry install
- name: Install dev and test dependencies
run: |
pip install .[dev]
pip install .[test]
- name: Run code quality tools
run: poetry run pre-commit run --all-files

- name: Run unit tests
run: poetry run coverage run -m pytest tests/
run: pre-commit run --all-files

- name: Check unit test coverage
run: poetry run coverage report
- name: Run unit tests & code coverage checks
run: pytest
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ celerybeat.pid
*.sage.py

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

Expand All @@ -130,3 +126,6 @@ dmypy.json

# Coming in future, but not yet
sphinx-docs/

# VS Code IDE
.vscode
38 changes: 19 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
files: ".py$"
exclude: "sphinx-docs/"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
name: Check that merge conflicts are not being committed
- id: trailing-whitespace
name: Remove trailing whitespace at end of line
- id: mixed-line-ending
name: Detect if mixed line ending is used (\r vs. \r\n)
- id: end-of-file-fixer
name: Make sure that there is an empty line at the end
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 24.4.2
hooks:
- id: black
name: black
Expand All @@ -13,27 +24,16 @@ repos:
language: python
require_serial: true
types_or: [python, pyi]
args: [--config=code-checks/.black.cfg]
args: [--config=.code_quality/.black.cfg]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
name: Run isort to sort imports in Python files
files: \.py$|\.pyi$
args: [--settings-path=code-checks/.isort.cfg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
name: Check that merge conflicts are not being committed
- id: trailing-whitespace
name: Remove trailing whitespace at end of line
- id: mixed-line-ending
name: Detect if mixed line ending is used (\r vs. \r\n)
- id: end-of-file-fixer
name: Make sure that there is an empty line at the end
args: [--settings-path=.code_quality/.isort.cfg]
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 7.0.0
hooks:
- id: flake8
name: flake8
Expand All @@ -42,14 +42,14 @@ repos:
language: python
types: [python]
require_serial: true
args: [--config=code-checks/.flake8]
args: [--config=.code_quality/.flake8]
- repo: local
hooks:
- id: mypy
name: mypy
description: 'Optional static typing for Python (installed by Poetry)'
description: 'Optional static typing for Python (installed as [test] dependency)'
entry: mypy
language: python
require_serial: true
types_or: [python, pyi]
args: [--config-file=code-checks/.mypy.ini]
args: [--config-file=.code_quality/.mypy.ini]
26 changes: 12 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ Table of Contents:
- [Run tests](#run-tests)

# Dev environment
* Install prerequisites from `dev-requirements.txt`:
* Install all dependencies:
```bash
pip install -r dev-requirements.txt
```
* Install `py-automapper` dependencies with poetry:
```bash
poetry install
pip install .[dev]
pip install .[test]
```

# Pre-commit
Expand All @@ -23,18 +20,19 @@ pre-commit install
```
After this code checks will run on `git commit` command.

If some of the `pre-commit` dependencies are not found make sure to activate appropriate poetry virtualenv. To check path to virtual environment run:
```bash
poetry env info -p
```
If some of the `pre-commit` dependencies are not found make sure to activate appropriate virtual environment

Or run pre-commit manually:
```
poetry run pre-commit run --all-files
To run `pre-commit` manually use:
```bash
pre-commit run --all-files
```

# Run tests
To run unit tests use command:
```bash
make test
```
poetry run pytest tests/
or simply
```bash
pytest
```
51 changes: 14 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,53 +1,30 @@
checkfiles = automapper/ tests/
black_opts = -l 100 -t py37
py_warn = PYTHONDEVMODE=1

help:
@echo "Py-Automapper development makefile"
@echo
@echo "usage: make <target>"
@echo "Targets:"
@echo " update Updates dev/test dependencies"
@echo " clean Clean all the cache in repo directory"
@echo " install Ensure dev/test dependencies are installed"
@echo " style Auto-formats the code"
@echo " flake8 Runs linter on the code"
@echo " mypy Runs mypy on the code for type checks"
@echo " check Auto-fomats and then checks the code"
@echo " test Runs all tests"
@echo " verify Runs code style, check and runs all tests"
@echo " build Produces dist/ package folder"
@echo " publish Publishes package to repository"
@echo " docs [Not-Implemented] Builds the documentation"

@echo " test Run all tests"
@echo " docs [not-working] Builds the documentation"
@echo " build Build into a package (/dist folder)"
@echo " publish Publish the package to pypi.org"

update:
@poetry update
clean:
rm -rf build dist .mypy_cache .pytest_cache .coverage py_automapper.egg-info

install:
@poetry install

style: install
black $(black_opts) $(checkfiles)

flake8: install
flake8 $(checkfiles)

mypy: install
mypy $(checkfiles)

check: style flake8 mypy
pip install .[dev]
pip install .[test]

test:
@poetry run pytest

verify: check test
pytest

build: install
rm -fR dist/
@poetry build
build:
python -m build

publish: install
@poetry publish
publish:
twine publish

docs: install
rm -fR ./build
Expand Down
8 changes: 0 additions & 8 deletions code-checks/.flake8

This file was deleted.

3 changes: 0 additions & 3 deletions dev-requirements.txt

This file was deleted.

61 changes: 39 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
[tool.poetry]
[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "py-automapper"
version = "1.2.3"
description = "Library for automatically mapping one object to another"
authors = ["Andrii Nikolaienko <[email protected]>"]
license = "MIT"
authors = [
{name = "Andrii Nikolaienko", email = "[email protected]"}
]
maintainers = [
{name = "Andrii Nikolaienko", email = "[email protected]"}
]
requires-python = ">= 3.8"
license = {file = "LICENSE"}
readme = "README.md"
homepage = "https://github.com/anikolaienko/py-automapper"
repository = "https://github.com/anikolaienko/py-automapper.git"
keywords = ["utils", "dto", "object-mapper", "mapping", "development"]
packages = [
{ include = "automapper" }
]
include = ["CHANGELOG.md", "LICENSE", "README.md"]
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"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",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Build Tools",
]

[tool.poetry.dependencies]
python = "^3.7"
[project.urls]
Homepage = "https://github.com/anikolaienko/py-automapper"
Repository = "https://github.com/anikolaienko/py-automapper.git"
Issues = "https://github.com/anikolaienko/py-automapper/issues"
Changelog = "https://github.com/anikolaienko/py-automapper/blob/main/CHANGELOG.md"

[tool.poetry.dev-dependencies]
pytest = "7.1.3"
tortoise-orm = "^0.19.2"
pydantic = "^1.10.2"
coverage = "^6.5.0"
SQLAlchemy = {version = "^1.4.41", extras = ["mypy"]}
mypy = "^0.982"
[project.optional-dependencies]
dev = [
"tortoise-orm~=0.20.1",
"pydantic~=2.7.1",
"SQLAlchemy[mypy]~=2.0.30",
"twine~=5.0.0",
"Sphinx~=7.1.2"
]
test = [
"pre-commit~=3.5.0",
"pytest~=8.2.0",
"pytest-cov~=5.0.0",
"mypy~=1.10.0"
]

[build-system]
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.pytest.ini_options]
addopts = "--cov=automapper --cov-report html"
testpaths = [
"tests"
]

0 comments on commit 7877946

Please sign in to comment.