Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: level up the packaging using hatchling #256

Merged
merged 2 commits into from
Apr 26, 2023
Merged
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: 3 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ jobs:
with:
python-version: "3.x"
cache: pip
cache-dependency-path: dev-requirements.txt
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -r dev-requirements.txt
python -m pip install -e '.[dev]'
- name: Tests
run: ./check.sh

Expand All @@ -34,11 +33,10 @@ jobs:
with:
python-version: "3.x"
cache: pip
cache-dependency-path: tests-requirements.txt
- name: Install test dependencies
run: |
python -m pip install -U pip
python -m pip install -r tests-requirements.txt
python -m pip install -e '.[test]'
- name: Tests
run: |
sphinx-build -d docs docs/source docs_out --color -W -bhtml
Expand Down Expand Up @@ -75,15 +73,11 @@ jobs:
with:
python-version: ${{ matrix.python.runs-on }}
cache: pip
cache-dependency-path: |
dev-requirements.txt
tests-requirements.txt
check-latest: true
- name: Install test dependencies
run: |
python -m pip install -U pip wheel
python -m pip install -r dev-requirements.txt
python -m pip install -r tests-requirements.txt
python -m pip install -e '.[dev,test]'
- name: Tests (GNU/Linux)
if: matrix.os.emoji == '🐧'
run: xvfb-run python -m pytest
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See Git checking messages for full history.

## 9.0.2 (2023/xx/xx)
-
- level up the packaging using `hatchling`
- :heart: contributors: @

## 9.0.1 (2023/04/20)
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

7 changes: 0 additions & 7 deletions dev-requirements.txt

This file was deleted.

14 changes: 12 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Lets prevent misses, and import the module to get the proper version.
# So that the version in only defined once across the whole code base:
# src/mss/__init__.py
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src"))

from mss import __version__ # noqa

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down Expand Up @@ -27,7 +37,7 @@
# built documents.
#
# The short X.Y version.
version = "9.0.2"
version = __version__

# The full version, including alpha/beta/rc tags.
release = "latest"
Expand Down Expand Up @@ -75,4 +85,4 @@
# ----------------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"https://docs.python.org/3/": None}
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
4 changes: 2 additions & 2 deletions docs/source/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You will need `pytest <https://pypi.org/project/pytest/>`_::
$ python -m venv venv
$ . venv/bin/activate
$ python -m pip install -U pip
$ python -m pip install -r tests-requirements.txt
$ python -m pip install -e '.[test]'


How to Test?
Expand All @@ -39,7 +39,7 @@ Code Quality

To ensure the code quality is correct enough::

$ python -m pip install -r dev-requirements.txt
$ python -m pip install -e '.[dev]'
$ ./check.sh


Expand Down
20 changes: 0 additions & 20 deletions mypy.ini

This file was deleted.

169 changes: 169 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "mss"
description = "An ultra fast cross-platform multiple screenshots module in pure python using ctypes."
readme = "README.md"
requires-python = ">= 3.8"
authors = [
{ name = "Mickaël 'Tiger-222' Schoentgen", email="[email protected]" },
]
maintainers = [
{ name = "Mickaël 'Tiger-222' Schoentgen", email="[email protected]" },
]
license = { file = "LICENSE.txt" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: MacOS X",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
"Topic :: Software Development :: Libraries",
]
keywords = [
"BitBlt",
"ctypes",
"EnumDisplayMonitors",
"CGGetActiveDisplayList",
"CGImageGetBitsPerPixel",
"monitor",
"screen",
"screenshot",
"screencapture",
"screengrab",
"XGetImage",
"XGetWindowAttributes",
"XRRGetScreenResourcesCurrent",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/BoboTiG/python-mss"
Documentation = "https://python-mss.readthedocs.io"
Changelog = "https://github.com/BoboTiG/python-mss/blob/main/CHANGELOG.md"
Source = "https://github.com/BoboTiG/python-mss"
Sponsor = "https://github.com/sponsors/BoboTiG"
Tracker = "https://github.com/BoboTiG/python-mss/issues"
"Released Versions" = "https://github.com/BoboTiG/python-mss/releases"

[project.scripts]
mss = "mss.__main__:main"

[project.optional-dependencies]
test = [
"numpy",
"pillow",
"pytest",
"pytest-cov",
"pytest-rerunfailures",
"pyvirtualdisplay; sys_platform == 'linux'",
"sphinx",
]
dev = [
"black",
"build",
"flake8-pyproject",
"mypy",
"pylint",
"twine",
"wheel",
]

[tool.hatch.version]
path = "src/mss/__init__.py"

[tool.hatch.build]
skip-excluded-dirs = true

[tool.hatch.build.targets.sdist]
only-include = [
"CHANGELOG.md",
"CHANGES.md",
"CONTRIBUTORS.md",
"docs/source",
"src",
]

[tool.hatch.build.targets.wheel]
packages = [
"src/mss",
]

[tool.black]
target-version = ["py38"]
line-length = 120
safe = true

[tool.flake8]
max-line-length = 120
ignore = [
"E203", # Whitespace before ':', but it's not PEP 8 compliant
"W503", # Line break before binary operator, but it's not PEP 8 compliant
]

[tool.isort]
py_version = 38
line_length = 120
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true

[tool.mypy]
# Ensure we know what we do
warn_redundant_casts = true
warn_unused_ignores = true
warn_unused_configs = true

# Imports management
ignore_missing_imports = true
follow_imports = "skip"

# Ensure full coverage
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_calls = true

# Restrict dynamic typing (a little)
# e.g. `x: List[Any]` or x: List`
# disallow_any_generics = true

strict_equality = true

[tool.pylint."MESSAGES CONTROL"]
disable = "locally-disabled,too-few-public-methods,too-many-instance-attributes,duplicate-code"

[tool.pylint.REPORTS]
max-line-length = 120
output-format = "colorized"
reports = "no"

[tool.pytest.ini_options]
pythonpath = "src"
addopts = """
--showlocals
--strict-markers
-r fE
-vvv
--cov=src/mss
--cov-report=term-missing
"""
Loading