Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cwichel committed Nov 29, 2021
2 parents ca73e94 + 76bb2e4 commit 83b7c27
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 27 deletions.
49 changes: 48 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
toml==0.10.2
alabaster==0.7.12
astroid==2.9.0
atomicwrites==1.4.0
attrs==21.2.0
babel==2.9.1
certifi==2021.10.8
charset-normalizer==2.0.8
colorama==0.4.4
coverage==6.2
docutils==0.17.1
idna==3.3
imagesize==1.3.0
importlib-metadata==4.8.2
iniconfig==1.1.1
intelhex==2.3.0
isort==5.10.1
jinja2==3.0.3
lazy-object-proxy==1.6.0
markupsafe==2.0.1
mccabe==0.6.1
mypy-extensions==0.4.3
mypy==0.910
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
py==1.11.0
pygments==2.10.0
pylint==2.12.1
pyparsing==3.0.6
pyserial==3.5
pytest==6.2.5
pytz==2021.3
requests==2.26.0
snowballstemmer==2.2.0
sphinx-rtd-theme==1.0.0
sphinx==4.3.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
typed-ast==1.4.3
typing-extensions==4.0.0
urllib3==1.26.7
wrapt==1.13.3
zipp==3.6.0
2 changes: 1 addition & 1 deletion embutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.0'
__version__ = '0.7.1'
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
version = "0.7.0"
version = "0.7.1"
name = "embutils"
license = "MIT"
readme = "README.md"
Expand All @@ -20,19 +20,19 @@ classifiers = [
]

[tool.poetry.scripts]
version = 'scripts.poetry:run_version'
test = 'scripts.poetry:run_test'
docs = 'scripts.poetry:run_docs'
html = 'scripts.poetry:run_html'
test = 'scripts.poetry:run_test'
version = 'scripts.poetry:run_version'
check_coverage = 'scripts.poetry:run_check_coverage'
check_linter = 'scripts.poetry:run_check_linter'
check_types = 'scripts.poetry:run_check_types'


[tool.poetry.dependencies]
python = "^3.7"
pyserial = "^3.5"
intelhex = "^2.3.0"
attrs = "^21.2.0"

[tool.poetry.dev-dependencies]
pytest = "^6.0.0"
Expand Down
73 changes: 52 additions & 21 deletions scripts/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import shutil
import sys
import toml
import typing as tp

from embutils.utils import Path, execute

Expand All @@ -39,27 +40,6 @@


# -->> API <<------------------------------------------------------------------
def run_version() -> None:
"""
This script update the toml and init file version strings.
"""
# Parse arguments
parser = ap.ArgumentParser()
parser.add_argument("version", type=str)
args = parser.parse_args(args=sys.argv[1:])

# Run
_version_update(ver=args.version.lower())


def run_test() -> None:
"""
Run the project tests.
"""
path = PATH_ROOT / "tests"
execute(cmd=f"pytest {path}")


def run_docs() -> None:
"""
Run the documentation build process.
Expand All @@ -70,6 +50,12 @@ def run_docs() -> None:
path_build = path_docs / "_build/html"
docs_make = path_docs / "make"

# Update the requirements
req_file = path_docs / "requirements.txt"
req_data = _requirements_get(inc_dev=True)
with req_file.open(mode="w", encoding="utf-8") as file:
file.write("\n".join(req_data))

# Generate documentation sources
if path_source.exists():
shutil.rmtree(path=path_source)
Expand Down Expand Up @@ -97,6 +83,27 @@ def run_html() -> None:
execute(cmd=f"python -m http.server -d {PATH_ROOT / target}")


def run_test() -> None:
"""
Run the project tests.
"""
path = PATH_ROOT / "tests"
execute(cmd=f"pytest {path}")


def run_version() -> None:
"""
This script update the toml and init file version strings.
"""
# Parse arguments
parser = ap.ArgumentParser()
parser.add_argument("version", type=str)
args = parser.parse_args(args=sys.argv[1:])

# Run
_version_update(ver=args.version.lower())


def run_check_coverage() -> None:
"""
Runs coverage over project tests.
Expand Down Expand Up @@ -125,6 +132,30 @@ def run_check_types() -> None:
execute(cmd=f"mypy {PROJ_NAME}")


def _requirements_get(inc_dev: bool = False, inc_extra: str = None) -> tp.List[str]:
"""
Extract requirements from poetry.
:param bool inc_dev: Enable the export of development requirements.
:param str inc_extra: Enable the export of one or more extra requirements.
:return: Requirements list.
:rtype: tp.List[str]
"""
# Prepare command
cmd = "poetry export --without-hashes"
cmd += " --dev" if inc_dev else ""
cmd += f" --extras \"{inc_extra}\"" if inc_extra else ""

# Get requirements
ret = execute(cmd=cmd, pipe=False)
if ret.returncode != 0:
raise ValueError(ret.stderr)

# Parse and return
return [line.split(";")[0] for line in ret.stdout.strip().split("\r\n")]


def _version_get() -> str:
"""
Returns the version string from the poetry project file.
Expand Down

0 comments on commit 83b7c27

Please sign in to comment.