-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from facelessuser/chore/hatch
Use hatchling backend
- Loading branch information
Showing
19 changed files
with
210 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,9 @@ | |
Licensed under MIT | ||
Copyright (c) 2015 - 2020 Isaac Muse <[email protected]> | ||
""" | ||
import sys | ||
import warnings | ||
from typing import Tuple, Any, List, Callable, AnyStr | ||
|
||
PY37 = (3, 7) <= sys.version_info | ||
|
||
FMT_FIELD = 0 | ||
FMT_INDEX = 1 | ||
FMT_ATTR = 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ Sep | |
Tox | ||
Twemoji | ||
accessor | ||
backend | ||
boolean | ||
decrement | ||
deprecations | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
"""Dynamically define some metadata.""" | ||
import os | ||
import sys | ||
import importlib.util | ||
from hatchling.metadata.plugin.interface import MetadataHookInterface | ||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
|
||
|
||
def get_version_dev_status(root): | ||
"""Get version_info without importing the entire module.""" | ||
|
||
path = os.path.join(root, "backrefs", "__meta__.py") | ||
spec = importlib.util.spec_from_file_location("__meta__", path) | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
return module.__version_info__._get_dev_status() | ||
|
||
|
||
def get_requirements(root, requirements): | ||
"""Load list of dependencies.""" | ||
|
||
install_requires = [] | ||
with open(os.path.join(root, requirements)) as f: | ||
for line in f: | ||
if not line.startswith("#"): | ||
install_requires.append(line.strip()) | ||
return install_requires | ||
|
||
|
||
def get_unicodedata(): | ||
"""Download the `unicodedata` version for the given Python version.""" | ||
|
||
import unicodedata | ||
|
||
uver = unicodedata.unidata_version | ||
path = os.path.join(os.path.dirname(__file__), 'tools', 'unidatadownload.py') | ||
spec = importlib.util.spec_from_file_location("unidatadownload", path) | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
module.get_unicodedata(uver, no_zip=True) | ||
return uver | ||
|
||
|
||
def generate_unicode_table(): | ||
"""Generate the Unicode table for the given Python version.""" | ||
|
||
uver = get_unicodedata() | ||
path = os.path.join(os.path.dirname(__file__), 'tools', 'unipropgen.py') | ||
spec = importlib.util.spec_from_file_location("unipropgen", path) | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
|
||
module.build_tables( | ||
os.path.join( | ||
os.path.dirname(__file__), | ||
'backrefs', 'uniprops', 'unidata' | ||
), | ||
uver | ||
) | ||
|
||
|
||
class CustomBuildHook(BuildHookInterface): | ||
"""Build hook.""" | ||
|
||
def initialize(self, version, build_data): | ||
"""Setup the build tag.""" | ||
|
||
if self.target_name != 'wheel': | ||
return | ||
|
||
build_data['tag'] = f'py{"".join([str(x) for x in sys.version_info[:2]])}-none-any' | ||
generate_unicode_table() | ||
|
||
|
||
class CustomMetadataHook(MetadataHookInterface): | ||
"""Our metadata hook.""" | ||
|
||
def update(self, metadata): | ||
"""See https://ofek.dev/hatch/latest/plugins/metadata-hook/ for more information.""" | ||
|
||
metadata["dependencies"] = get_requirements(self.root, 'requirements/project.txt') | ||
metadata['optional-dependencies'] = {'extras': get_requirements(self.root, "requirements/extras.txt")} | ||
metadata["classifiers"] = [ | ||
f"Development Status :: {get_version_dev_status(self.root)}", | ||
'Environment :: Console', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
'Typing :: Typed' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,74 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel" | ||
"hatchling>=0.21.1", | ||
] | ||
build-backend = "hatchling.build" | ||
|
||
build-backend = "setuptools.build_meta" | ||
[project] | ||
name = "backrefs" | ||
description = "A wrapper around re and regex that adds additional back references.'" | ||
readme = "README.md" | ||
license = "MIT" | ||
requires-python = ">=3.7" | ||
authors = [ | ||
{ name = "Isaac Muse", email = "[email protected]" }, | ||
] | ||
keywords = [ | ||
"regex", | ||
"re" | ||
] | ||
dynamic = [ | ||
"classifiers", | ||
"dependencies", | ||
"version", | ||
"optional-dependencies" | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/facelessuser/backrefs" | ||
|
||
[tool.hatch.version] | ||
source = "code" | ||
path = "backrefs/__meta__.py" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = [ | ||
"/docs/src/markdown/**/*.md", | ||
"/docs/src/markdown/**/*.gif", | ||
"/docs/src/markdown/**/*.png", | ||
"/docs/src/markdown/dictionary/*.txt", | ||
"/docs/theme/**/*.css", | ||
"/docs/theme/**/*.js", | ||
"/docs/theme/**/*.html", | ||
"/requirements/*.txt", | ||
"/backrefs/**/*.py", | ||
"/backrefs/py.typed", | ||
"/tests/**/*.py", | ||
"/tools/**/*.py", | ||
"/tools/unicodedata/*.zip", | ||
"/tools/unicodedata/LICENSE", | ||
"/.pyspelling.yml", | ||
"/.coveragerc", | ||
"/mkdocs.yml", | ||
"/tox.ini", | ||
] | ||
|
||
exclude = [ | ||
"backrefs/uniprops/unidata/*" | ||
] | ||
|
||
[tool.hatch.build.targets.wheel] | ||
ignore-vcs = true | ||
include = [ | ||
"/backrefs" | ||
] | ||
|
||
[tool.hatch.build.hooks.custom] | ||
[tool.hatch.metadata.hooks.custom] | ||
|
||
[tool.mypy] | ||
files = [ | ||
"backrefs/*.py" | ||
"backrefs" | ||
] | ||
strict = true | ||
show_error_codes = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mkdocs_pymdownx_material_extras==1.5.4 | ||
mkdocs_pymdownx_material_extras>=2.0 | ||
mkdocs-git-revision-date-localized-plugin | ||
mkdocs-minify-plugin | ||
pyspelling |
Oops, something went wrong.