Skip to content

Commit

Permalink
chore: minor cleanups from pypa#361
Browse files Browse the repository at this point in the history
Co-authored-by: layday <layday@protonmail.com>
  • Loading branch information
henryiii and layday committed May 12, 2022
1 parent 05f8df0 commit 6782164
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
- name: Setup run environment
run: tox -vv --notest -e docs

- name: Run check for type
- name: Run check for docs
run: tox -e docs --skip-pkg-install
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: '3.10'

python:
version: 3.8
install:
- method: pip
path: .
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test =
typing =
importlib-metadata>=4.6.4
mypy==0.942
typing-extensions>=3.7.4.3
typing-extensions>=3.7.4.3;python_version < "3.8"
virtualenv =
virtualenv>=20.0.35

Expand Down
29 changes: 18 additions & 11 deletions src/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
build - A simple, correct PEP 517 build frontend
"""

__version__ = '0.7.0'

import contextlib
Expand All @@ -24,6 +25,7 @@
Callable,
Dict,
Iterator,
List,
Mapping,
MutableMapping,
Optional,
Expand Down Expand Up @@ -71,18 +73,18 @@
}


_logger = logging.getLogger('build')
_logger = logging.getLogger(__name__)


class BuildException(Exception):
"""
Exception raised by ProjectBuilder
Exception raised by :class:`ProjectBuilder`
"""


class BuildBackendException(Exception):
"""
Exception raised when the backend fails
Exception raised when a backend operation fails
"""

def __init__(
Expand Down Expand Up @@ -131,7 +133,7 @@ def __str__(self) -> str:

class TypoWarning(Warning):
"""
Warning raised when a potential typo is found
Warning raised when a possible typo is found
"""


Expand Down Expand Up @@ -428,12 +430,13 @@ def build(

def metadata_path(self, output_directory: PathType) -> str:
"""
Generates the metadata directory of a distribution and returns its path.
Generate the metadata directory of a distribution and return its path.
If the backend does not support the ``prepare_metadata_for_build_wheel``
hook, a wheel will be built and the metadata extracted.
hook, a wheel will be built and the metadata will be extracted from it.
:param output_directory: Directory to put the metadata distribution in
:returns: The path of the metadata directory
"""
# prepare_metadata hook
metadata = self.prepare('wheel', output_directory)
Expand Down Expand Up @@ -491,20 +494,20 @@ def _handle_backend(self, hook: str) -> Iterator[None]:
@staticmethod
def log(message: str) -> None:
"""
Prints message
Log a message.
The default implementation uses the logging module but this function can be
overwritten by users to have a different implementation.
overridden by users to have a different implementation.
:param msg: Message to output
:param message: Message to output
"""
if sys.version_info >= (3, 8):
_logger.log(logging.INFO, message, stacklevel=2)
else:
_logger.log(logging.INFO, message)


__all__ = (
__all__ = [
'__version__',
'BuildBackendException',
'BuildException',
Expand All @@ -514,4 +517,8 @@ def log(message: str) -> None:
'RunnerType',
'TypoWarning',
'check_dependency',
)
]


def __dir__() -> List[str]:
return __all__
4 changes: 2 additions & 2 deletions src/build/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def _error(msg: str, code: int = 1) -> NoReturn: # pragma: no cover
:param msg: Error message
:param code: Error code
"""
print('{red}ERROR{reset} {}'.format(msg, **_STYLES))
exit(code)
print('{red}ERROR{reset} {}'.format(msg, **_STYLES), file=sys.stderr)
raise SystemExit(code)


class _ProjectBuilder(ProjectBuilder):
Expand Down

0 comments on commit 6782164

Please sign in to comment.