Skip to content

Commit

Permalink
Use hatchling for build
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Oct 22, 2022
1 parent 8d6c1e5 commit 8f3aaea
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 109 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
if: "!endsWith(matrix.python-version, '-dev')"
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up development Python ${{ matrix.python-version }}
Expand All @@ -47,7 +47,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox coverage codecov
python -m pip install --upgrade pip build tox coverage codecov
- name: Test
run: |
python -m tox
Expand All @@ -74,12 +74,12 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox
python -m pip install --upgrade pip build tox
- name: Lint
run: |
python -m tox
Expand All @@ -98,12 +98,12 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox
python -m pip install --upgrade pip build tox
- name: Install Aspell
run: |
sudo apt-get install aspell aspell-en
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ on:

jobs:
pypi:
strategy:
matrix:
distribution: [bdist_wheel, sdist]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Package
run: |
pip install --upgrade setuptools wheel
python setup.py ${{ matrix.distribution }}
pip install --upgrade build
python -m build -s -w
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.0.0a0
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
15 changes: 0 additions & 15 deletions MANIFEST.in

This file was deleted.

51 changes: 51 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""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, "materialx", "__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",
]
49 changes: 46 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,50 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
"hatchling>=0.21.1",
]
build-backend = "hatchling.build"

build-backend = "setuptools.build_meta"
[project]
name = "mkdocs-material-extensions"
description = "Extension pack for Python Markdown and MkDocs Material."
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/mkdocs-material-extensions'"

[tool.hatch.version]
source = "code"
path = "materialx/__meta__.py"

[tool.hatch.build.targets.sdist]
include = [
"/requirements/*.txt",
"/materialx/**/*.py",
"/tests/**/*.py",
"/.pyspelling.yml",
"/.coveragerc",
"/tox.ini",
"/LICENSE.md",
"/changelog.md"
]

[tool.hatch.build.targets.wheel]
include = [
"/materialx",
]

[tool.hatch.metadata.hooks.custom]
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

74 changes: 0 additions & 74 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
{py36,py37,py38,py39}, lint, documents
{py37,py38,py39,py310}, lint, documents

[testenv]
passenv = LANG
Expand Down

0 comments on commit 8f3aaea

Please sign in to comment.