From 1340c7abcc791797f03eba78b0a288adaea20ff8 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sun, 20 Mar 2022 00:53:20 -0400 Subject: [PATCH 1/2] Update package metadata --- .gitignore | 6 ++-- MANIFEST.in | 17 ------------ hatch_build.py | 52 +++++++++++++++++++++++++++++++++++ pyproject.toml | 49 +++++++++++++++++++++++++++++++-- setup.cfg | 2 -- setup.py | 74 -------------------------------------------------- tox.ini | 1 + 7 files changed, 102 insertions(+), 99 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 hatch_build.py delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 497d09cec..cb6bfa6a1 100644 --- a/.gitignore +++ b/.gitignore @@ -58,13 +58,13 @@ target/ tools/emoji.md -site/* +site/ -tools/tags/* +tools/tags/ tmp* -node_modules/* +node_modules/ manifest*.json *.dic diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index b8640124e..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,17 +0,0 @@ -recursive-include pymdownx *.py -recursive-include tests *.txt *.html *.yml *.py *.css -recursive-include docs/src/markdown *.md *.png *.gif *.html -recursive-include docs/theme *.js *.css *.html *.svg *.txt -recursive-include requirements *.txt -recursive-exclude site * -include .dictionary -include mkdocs.yml -include setup.py -include setup.cfg -include run_tests.py -include tox.ini -include .coveragerc -include LICENSE.md -include README.md -include MANIFEST.in -include pyproject.toml diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 000000000..a55213ccb --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,52 @@ +"""Dynamically define some metadata.""" +import os + +from hatchling.metadata.plugin.interface import MetadataHookInterface + + +def get_version_dev_status(root): + """Get version_info without importing the entire module.""" + + import importlib.util + + path = os.path.join(root, "pymdownx", "__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): + """Load list of dependencies.""" + + install_requires = [] + with open(os.path.join(root, "requirements", "project.txt")) as f: + for line in f: + if not line.startswith("#"): + install_requires.append(line.strip()) + return install_requires + + +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) + 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 :: Internet :: WWW/HTTP :: Dynamic Content", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: Filters", + "Topic :: Text Processing :: Markup :: HTML", + ] diff --git a/pyproject.toml b/pyproject.toml index 285367ae3..3d72cb7ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,50 @@ [build-system] requires = [ - "setuptools>=42", - "wheel" + "hatchling>=0.21.0", ] +build-backend = "hatchling.build" -build-backend = "setuptools.build_meta" +[project] +name = "pymdown-extensions" +description = "Extension pack for Python Markdown." +readme = "README.md" +license = "MIT" +requires-python = ">=3.7" +authors = [ + { name = "Isaac Muse", email = "Isaac.Muse@gmail.com" }, +] +keywords = [ + "extensions", + "markdown", +] +dynamic = [ + "classifiers", + "dependencies", + "version", +] + +[project.urls] +Homepage = "https://github.com/facelessuser/pymdown-extensions" + +[tool.hatch.version] +source = "code" +path = "pymdownx/__meta__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/docs/src/markdown", + "/docs/theme", + "/requirements/*.txt", + "/pymdownx", + "/tests", + "/.coveragerc", + "/.dictionary", + "/mkdocs.yml", + "/run_tests.py", + "/tox.ini", +] + +[tool.hatch.build.targets.wheel] +include = [ + "/pymdownx", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 21934a22d..000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -license_file = LICENSE.md diff --git a/setup.py b/setup.py deleted file mode 100644 index fb128e383..000000000 --- a/setup.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -"""Setup pymdown-extensions.""" - -from setuptools import setup, find_packages -import os - - -def get_version(): - """Get version and version_info without importing the entire module.""" - - import importlib.util - - path = os.path.join(os.path.dirname(__file__), 'pymdownx', '__meta__.py') - spec = importlib.util.spec_from_file_location("__meta__", path) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - vi = module.__version_info__ - return vi._get_canonical(), vi._get_dev_status() - - -def get_requirements(req): - """Load list of dependencies.""" - - install_requires = [] - with open(req) as f: - for line in f: - if not line.startswith("#"): - install_requires.append(line.strip()) - return install_requires - - -def get_description(): - """Get long description.""" - - with open("README.md", 'r') as f: - desc = f.read() - return desc - - -VER, DEVSTATUS = get_version() - - -setup( - name='pymdown-extensions', - version=VER, - keywords='markdown extensions', - description='Extension pack for Python Markdown.', - long_description=get_description(), - long_description_content_type='text/markdown', - author='Isaac Muse', - author_email='Isaac.Muse@gmail.com', - python_requires='>=3.7', - url='https://github.com/facelessuser/pymdown-extensions', - packages=find_packages(exclude=['tools', 'test*']), - install_requires=get_requirements("requirements/project.txt"), - license='MIT License', - classifiers=[ - 'Development Status :: %s' % DEVSTATUS, - '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 :: Internet :: WWW/HTTP :: Dynamic Content', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Text Processing :: Filters', - 'Topic :: Text Processing :: Markup :: HTML', - ] -) diff --git a/tox.ini b/tox.ini index 4027aa6ee..45b1a203a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +isolated_build = true envlist = {py37,py38,py39,py310}, lint, documents From 2a72771dcf8755a07985c681b20699cb40dd12c4 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sun, 20 Mar 2022 15:19:08 -0400 Subject: [PATCH 2/2] address --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3d72cb7ff..481a38a76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,3 +48,5 @@ include = [ include = [ "/pymdownx", ] + +[tool.hatch.metadata.hooks.custom]