[build-system]
requires = ["setuptools >= 61.0", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "fontbakery"
dynamic = ["version"]
description = "A font quality assurance tool for everyone"
requires-python = ">=3.8"
readme = { file = "README.md", content-type = "text/markdown" }
authors = [
	{ name = "Chris Simpkins", email = "csimpkins@google.com" },
	{ name = "Dave Crossland", email = "dcrossland@google.com" },
	{ name = "Felipe Sanches", email = "juca@members.fsf.org" },
	{ name = "Jens Kutilek" },
	{ name = "Lasse Fister" },
	{ name = "Marc Foley" },
	{ name = "Miguel Sousa" },
    { name = "Nikolaus Waxweiler" },
    { name = "Rosalie Wagner" },
    { name = "Simon Cozens" },
    { name = "Vitaly Volkov" },
    { name = "Viviana Monsalve" },
    { name = "Yanone" },
]
maintainers = [
	{ name = "Felipe Sanches", email = "juca@members.fsf.org" }
]

dependencies = [
	"fontTools >= 4.46.0",
	"freetype-py < 2.4.0",
	"opentypespec",
	"opentype-sanitizer >= 9.1.0, == 9.*",
	"munkres",
	"PyYAML",
	"toml",
	"cmarkgfm >= 0.4",
	"rich",
	"Jinja2",
	"packaging",
	"pip-api",
	"requests",
	"beziers >= 0.5.0, == 0.5.*",
	"uharfbuzz",
	"vharfbuzz >= 0.2.0, == 0.2.*",
  "typing_extensions ; python_version < '3.11'",
]

[project.optional-dependencies]

# Note: These dependencies are meant to be private (not used explicitly by users)
#       and are used just to facilitate maintainance of versioning
#       dependencies that are shared by multiple vendor-profiles.
#       (this way, the maintainer only needs to edit a single entry)

beautifulsoup4 = [
    "beautifulsoup4 >= 4.7.1"
    # For parsing registered vendor IDs
    # com.google.fonts/check/vendor_id produces an ERROR if Beautiful Soup 4
    # version 4.0.1 to 4.6.1 or 4.7.0 is installed because of bugs in Beautiful Soup
    # (see https://github.com/fonttools/fontbakery/issues/4270)
]

shaperglot = [
    "shaperglot >= 0.3.0, < 0.6.0",
    # versions prior to v0.3.0 had too stric dependency rules
    # for other deps such as protobuf, making it harder satisfy all dependencies.
]

ufo2ft = [
    "ufo2ft >= 2.25.2"
    # 2.25.2 updated the script lists for Unicode 14.0
]

# These Google Fonts profile dependencies contain data that is critical to
# always be up-to-date, so we treat any update to these deps the same way we would
# deal with API-breaking updates. Only the latest released version is acceptable:
googlefontsalwayslatest = [
	"axisregistry >= 0.4.9, == 0.4.*",
	"gflanguages >= 0.5.17, == 0.5.*",
	"gfsubsets >= 2024.2.5",
	"glyphsets == 0.6.14",  #  "glyphsets >= 0.6.14, == 0.6.*",
    # (see https://github.com/googlefonts/glyphsets/commit/bfd0bb637)
	"shaperglot >= 0.5.0, == 0.5.*",
]


# Profile-specific dependencies:

adobefonts = [
    # The Adobe Fonts profile currently depends only on the base-install of
    # fontbakery dependencies. But we keep here a place-holder "extra" for
    # consistency (all vendor-specific profiles have the same install instructions)
    # And at some point in the future there may be actual dependencies listed
    # here for this profile.
]

fontval = [
    "lxml",
]

fontwerk = [
    "fontbakery[googlefonts]"
]

googlefonts = [
    "dehinter >= 3.1.0",
    # 3.1.0 added dehinter.font.hint function

    "fonttools[lxml,unicode]",
    # (see https://github.com/googlefonts/gflanguages/pull/7)

    "protobuf >= 3.7.0, < 4",
    # 3.7.0 fixed a bug on parsing some METADATA.pb files.
    # We cannot use v4 because our protobuf files have been compiled with v3.
    # (see https://github.com/fonttools/fontbakery/issues/2200)

    "unicodedata2",

    "fontbakery[beautifulsoup4]",
    "fontbakery[googlefontsalwayslatest]",
    "fontbakery[shaping]",
    "fontbakery[ufo]",
]

iso15008 = []

notofonts = [
    "fontbakery[googlefonts]"
]

# FIXME: This is not a vendor-specific profile!
shaping = [
    "collidoscope >= 0.5.2",
    # 0.5.2 added Python 3.11 wheels
    # (see https://github.com/fonttools/fontbakery/issues/3970)

    "stringbrewer",

    "fontbakery[ufo2ft]",
    "fontbakery[shaperglot]",
]

typenetwork = [
    "unicodedata2",

    "fontbakery[beautifulsoup4]",
    "fontbakery[ufo2ft]",
    "fontbakery[shaperglot]",
    "fontbakery[fontval]",
]

# FIXME: This is not a vendor-specific profile!
ufo = [
    "defcon",
    "fonttools[ufo]",
    "ufolint",

    "fontbakery[ufo2ft]",
]


# Dependencies for building our documentation:

docs = [
	"myst-parser >= 2.0.0, == 2.*",
	"sphinx >= 7.1.2, == 7.1.*",
	"sphinx_rtd_theme >= 2.0.0, == 2.*",
	"m2r >= 0.3.1, == 0.3.*",
]


# Some users may want a full install of all profiles:

all = [
    "fontbakery[docs]",
    "fontbakery[adobefonts]",
    "fontbakery[fontval]",
    "fontbakery[fontwerk]",
    "fontbakery[googlefonts]",
    "fontbakery[iso15008]",
    "fontbakery[notofonts]",
    "fontbakery[shaping]",
    "fontbakery[typenetwork]",
    "fontbakery[ufo]",
]


# Requirements for running code-tests:

tests = [
	"black == 23.12.1",
    "pylint == 3.0.3",
	"pytest-cov == 4.1.0",
	"pytest-xdist == 3.5.0",

	"fontbakery[all]",
]

[project.scripts]
fontbakery = "fontbakery.cli:main"

[tool.setuptools.packages.find]
where =["Lib"]

[tool.setuptools_scm]
write_to = "Lib/fontbakery/_version.py"

# ============================================================================
[tool.black]
line-length = 88
target-version = ["py310"]
# 'extend-exclude' excludes files or directories in addition to the defaults
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project. Separate regexes with | .
(
  .*_pb2.py  # exclude autogenerated Protocol Buffer files anywhere in the project
)
'''

# ============================================================================
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
addopts = "--color=yes  --verbose"
filterwarnings = [
	"ignore:pkg_resources is deprecated as an API:DeprecationWarning",
	"ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning",
]

# ============================================================================
[tool.pylint.master]
ignore-patterns = ".*_pb2.py"
jobs = 0                                                     # Specifying 0 will auto-detect the number of processors available to use
logging-format-style = "new"
msg-template = "{msg_id} ({symbol}) {path} @ {line} — {msg}"
output-format = "colorized"
score = "n"

[tool.pylint.'MESSAGES CONTROL']
disable = [
	# Error
	"no-member",
	"no-name-in-module",
	"used-before-assignment",

	# Warning
	"broad-exception-caught",
	"broad-exception-raised",
	"cell-var-from-loop",
	"fixme",
	"keyword-arg-before-vararg",
	"protected-access",
	"raise-missing-from",
	"redefined-outer-name",
	"subprocess-run-check",
	"superfluous-parens",
	"undefined-loop-variable",
	"unnecessary-pass",
	"unused-argument",
	"unused-variable",

	# Convention
	"consider-iterating-dictionary",
	"consider-using-dict-items",
	"consider-using-enumerate",
	"consider-using-f-string",
	"import-outside-toplevel",
	"invalid-name",
	"missing-docstring",
	"too-many-lines",

	# Refactor
	"chained-comparison",
	"consider-using-with",
	"duplicate-code",
	"inconsistent-return-statements",
	"no-else-raise",
	"no-else-return",
	"too-few-public-methods",
	"too-many-arguments",
	"too-many-boolean-expressions",
	"too-many-branches",
	"too-many-instance-attributes",
	"too-many-locals",
	"too-many-nested-blocks",
	"too-many-public-methods",
	"too-many-return-statements",
	"too-many-statements",
	"unnecessary-dict-index-lookup",
	"use-a-generator",

	# Information
	"c-extension-no-member",

	# FIXME on Sphinx code,
	"abstract-method",
	"unexpected-keyword-arg",
	"logging-too-many-args",
	"attribute-defined-outside-init",
]

[tool.pytype]
inputs = ["Lib"]
exclude = ["Lib/fontbakery/*_pb2.py", "Lib/fontbakery/sphinx_extensions"]
