Skip to content

Commit

Permalink
build: replace dephell setuppy coverts due bug
Browse files Browse the repository at this point in the history
  • Loading branch information
spumer committed Dec 24, 2021
1 parent 380b58a commit f165f18
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
25 changes: 11 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PYTHON_INSTALL := $(shell python3 -c 'import sys;print(sys.executable)')
BIN ?= $(shell [ -e .venv/bin ] && echo `pwd`/'.venv/bin' || dirname $(PYTHON_INSTALL))/

CODE = .
CODE = sqredirect

help: ## This help dialog.
@IFS=$$'\n' ; \
Expand All @@ -27,18 +27,15 @@ init:
python3 -m venv .venv
poetry install

test: ## Tests
$(BIN)python -m pytest $(CODE) $(args)

cov: ## Tests (with coverage)
test: ## Запуск тестов
$(BIN)python -m pytest --cov=$(CODE) $(args)

lint: ## QA (linting)
lint: ## Проверка кода (linting)
$(BIN)flake8 --jobs 4 --statistics --show-source $(CODE) tests
$(BIN)black --target-version=py37 --skip-string-normalization --line-length=120 --check $(CODE) tests
#$(BIN)python -m pytest --dead-fixtures --dup-fixtures # disabled due _old_style_conf_d_globals detected as unused

pretty: ## Autoformat respecting code-style
pretty: ## Автоформатирование согласно code-style
$(BIN)isort $(CODE) tests
$(BIN)black --target-version=py37 --skip-string-normalization --line-length=120 $(CODE) tests
$(BIN)unify --in-place --recursive $(CODE) tests
Expand All @@ -48,24 +45,24 @@ precommit_install: ## Установка pre-commit хука с проверк
echo "exec make lint test BIN=$(BIN)" >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

bump_major: ## Bump major version
bump_major:
$(BIN)bumpversion major
dephell convert deps
$(BIN)python3 update_setup.py
git add setup.py
git commit --amend --no-edit

bump_minor: ## Bump minor version
bump_minor:
$(BIN)bumpversion minor
dephell convert deps
$(BIN)python3 update_setup.py
git add setup.py
git commit --amend --no-edit

bump_patch: ## Bump patch version
bump_patch:
$(BIN)bumpversion patch
dephell convert deps
$(BIN)python3 update_setup.py
git add setup.py
git commit --amend --no-edit


publish: ## Push to repo with tags
publish:
git push origin master --tags
28 changes: 28 additions & 0 deletions update_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Замена оригинальной команде `dephell convert deps`
тк иногда с ней бывают проблемы и она падает с TypeError
"""
import pathlib

from dephell import converters
from dephell.controllers import Graph
from dephell.models import Requirement

BASEDIR = pathlib.Path(__file__).parent

if __name__ == '__main__':
pc = converters.PoetryConverter()
spc = converters.SetupPyConverter()

root = pc.load(BASEDIR.joinpath('pyproject.toml'))
if root.readme.markup == 'md':
# SetupPyConverter принудительно конвертирует README в rst
# чтобы этого не допустить - обманываем его
root.readme.markup = 'rst'

reqs = Requirement.from_graph(graph=Graph(root), lock=False)
content = spc.dumps(reqs, project=root)

BASEDIR.joinpath('setup.py').write_text(content)

print('setup.py was updated successfully')

0 comments on commit f165f18

Please sign in to comment.