Skip to content

poetry: Switch from using pipenv to poetry #81

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev
poetry install

- name: Run linters
run: |
pipenv run mypy ./src
make lint

- name: Run tests
run: |
pipenv run python setup.py install
pipenv run pytest
make test
9 changes: 5 additions & 4 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev
poetry install

- name: Build package
run: |
pipenv run python -m build --no-isolation
make build

- name: Publish package
if: startsWith(github.ref, 'refs/tags')
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ cython_debug/
# VS Code
.history
.vscode

#pyenv
.python-version
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
.DEFAULT_GOAL := help
.PHONY: help build test

build: ## Build an application
@pipenv run python -m build --no-isolation
PYPI_PASSWORD := $(shell echo ${PYPI_PASSWORD})
PYPI_TEST_PASSWORD := $(shell echo ${PYPI_TEST_PASSWORD})

publish-test: ## Upload package to test PyPI
@pipenv run twine upload --repository testpypi dist/*

publish: build ## Upload package to PyPI
@pipenv run twine upload dist/*
@make clean
build: ## Build an application
@poetry build

configure_pypi_publishing: ## Configure publishing to PyPI (for publish-test)
@if [ -z "${PYPI_PASSWORD}" ] ; then echo "you need to export PYPI_PASSWORD before running this command" ; false ; fi
@if [ -z "${PYPI_TEST_PASSWORD}" ] ; then echo "you need to export PYPI_TEST_PASSWORD before running this command" ; false ; fi
@poetry config repositories.test-pypi https://test.pypi.org/legacy/
@poetry config pypi-token.test-pypi $(PYPI_TEST_TOKEN)
@poetry config pypi-token.pypi $(PYPI_TOKEN)

install: build ## Install application to Pip environment
@pipenv run python -m pip install
publish-test: ## Upload package to test PyPI
@poetry publish -r test-pypi

install-dev: ## Install application to Pip development environment
@pipenv run python -m pip install -e
@make clean
install: build ## Install application to Poetry environment
@poetry install

clean: ## Remove build files
@rm -Rf build/ dist/ *.egg-info .pytest_cache/ .mypy_cache/ .pytype/ .eggs/ src/*.egg-info
@echo "Temporary files were clear"

test: ## Run code tests
@pipenv run python -m pytest -q

sync: ## Sync with Pipfile packages list
@pipenv sync
@poetry run pytest

lint: ## Run code linters
@echo "Run code linters..."
@pipenv run mypy ./src
@poetry run mypy ./src

help: ## Show this message
@echo "Application management"
@echo
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

918 changes: 0 additions & 918 deletions Pipfile.lock

This file was deleted.

894 changes: 894 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[tool.poetry]
name = "openapi3-parser"
version = "1.1.16"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there might be slight issue with this version, previously it was set in __init__.py file that is used during publishing process to increment the package version on pypi. If poetry uses this version for a new package for upload, then we should remove redundant package metadata from init file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the version being bumped now? Is that part of gh-action-pypi-publish or manual?

Should for sure only have one source of truth. If automated, could replace with: https://py-pkgs.org/07-releasing-versioning.html#automatic-version-bumping

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, it's a manual thing, I have planned to automate it in the future (#33) and might follow your suggestion. Currently, the publishing process uses the version defined in setup.py, which comes from the init file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, poetry requires a version so I'll circle back when I can convert setup.py

description = "OpenAPI 3 parser to use a specification inside of the code in your projects"
authors = ["Artem Manchenkov <artem@manchenkoff.me>"]
license = "MIT"
readme = "README.md"
packages = [{ include = "openapi_parser", from = "src" }]

[tool.poetry.dependencies]
python = "^3.9"
prance = ">=0.20.2"
openapi-spec-validator = "==0.6.0"


[tool.poetry.group.dev.dependencies]
wheel = ">=0.35.1"
mypy = ">=0.800"
pytest = ">=6.2.2"
build = "*"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.pytest.ini_options]
testpaths = [
"tests",
]
pythonpath = [
"./src"
]