diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d77f53d..4359bdc 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -58,17 +58,17 @@ jobs: - name: Install dependencies in GHA run: | python -m pip install --upgrade pip - pipenv install --deploy --dev + pip install -e ".[dev]" - name: Lint with pylint run: | - pipenv run flake8 src/k2hr3client - pipenv run mypy src/k2hr3client - pipenv run pylint src/k2hr3client - pipenv run python3 setup.py checkdocs + flake8 src/k2hr3client + mypy src/k2hr3client + pylint src/k2hr3client + python3 setup.py checkdocs shell: sh - name: Test with unittest run: | - pipenv run python3 -m unittest discover src + python3 -m unittest discover src shell: sh - name: Install dependencies for upload pypi package if: startsWith(github.ref, 'refs/tags') diff --git a/Makefile b/Makefile index 4c5aa04..293704c 100644 --- a/Makefile +++ b/Makefile @@ -49,11 +49,9 @@ BROWSER := python3 -c "$$BROWSER_PYSCRIPT" help: @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) -init: - python3 -m pip install pipenv - pipenv install --skip-lock - pipenv graph - pipenv install --dev +init: ## Install dependencies and development dependencies + python3 -m pip install -e . + python3 -m pip install -e ".[dev]" clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 7bb7e7c..0000000 --- a/Pipfile +++ /dev/null @@ -1,30 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -coverage = "*" -flake8 = "*" -flake8-docstrings = "*" -pep8-naming = "*" -pycodestyle = "*" -mccabe = "*" -sphinx-autoapi = "*" -sphinx-intl = "*" -sphinx-rtd-theme = "*" -sphinx = "*" -watchdog = "*" -wheel = "*" -twine = "*" -pylint = "*" -astroid = "*" -mypy = "*" -"collective.checkdocs" = "*" -tomli = "*" -dill = "*" - -[packages] -requests = "*" -urllib3 = "*" -setuptools = "*" diff --git a/README.rst b/README.rst index 76ed7b9..38641fa 100644 --- a/README.rst +++ b/README.rst @@ -133,7 +133,6 @@ Development Clone this repository and go into the directory, then run the following command:: $ make init - $ pipenv shell $ make lint test docs build diff --git a/pyproject.toml b/pyproject.toml index 354d21a..cd5a9d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "k2hr3client" -dynamic = ["version"] +version = "1.1.3" requires-python = ">=3.9" authors = [ {name = "Hirotaka Wakabayashi", email = "hiwakaba@lycorp.co.jp"}, @@ -29,6 +29,34 @@ classifiers = [ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.9', ] +dependencies = [ + "requests", + "urllib3", + "setuptools", +] + +[project.optional-dependencies] +dev = [ + "coverage", + "flake8", + "flake8-docstrings", + "pep8-naming", + "pycodestyle", + "mccabe", + "sphinx-autoapi", + "sphinx-intl", + "sphinx-rtd-theme", + "sphinx", + "watchdog", + "wheel", + "twine", + "pylint", + "astroid", + "mypy", + "collective.checkdocs", + "tomli", + "dill", +] [project.urls] Homepage = "https://github.com/yahoojapan/k2hr3client_python" diff --git a/setup.py b/setup.py index 17cfe50..9130726 100644 --- a/setup.py +++ b/setup.py @@ -52,28 +52,8 @@ # Always prefer setuptools over distutils from setuptools import setup - -def get_version(): - """Returns the package version from __ini__.py.""" - from pathlib import Path - from os import path, sep - import re - - here = path.abspath(path.dirname(__file__)) - init_py = Path(sep.join([here, 'src', 'k2hr3client', '__init__.py'])).resolve() - - with init_py.open() as fp: - for line in fp: - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - line.strip(), re.M) - if version_match: - return version_match.group(1) - raise RuntimeError('version expected, but no version found.') - - -setup( - version=get_version(), -) +# All configuration is now in pyproject.toml +setup() # # Local variables: diff --git a/src/k2hr3client/__init__.py b/src/k2hr3client/__init__.py index 129cfba..680518d 100644 --- a/src/k2hr3client/__init__.py +++ b/src/k2hr3client/__init__.py @@ -22,14 +22,23 @@ """K2HR3 Python Client of Token API.""" __author__ = 'Hirotaka Wakabayashi ' -__version__ = '1.1.3' import configparser import logging -from logging.handlers import TimedRotatingFileHandler +import sys +from importlib.metadata import PackageNotFoundError, \ + version as get_version_info from logging import StreamHandler +from logging.handlers import TimedRotatingFileHandler from pathlib import Path -import sys + +from k2hr3client import version # noqa: F401 + + +try: + __version__ = get_version_info("k2hr3client") +except PackageNotFoundError: + __version__ = "unknown" LOG = logging.getLogger(__name__)