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

Use hatchling for build #20

Merged
merged 2 commits into from Oct 22, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
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
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.

1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -3,6 +3,7 @@
## 1.1.0

- **NEW**: Drop Python 3.6 and officially support 3.10.
- **NEW**: Cache emoji table to reduce build times.

## 1.0.3

Expand Down
51 changes: 51 additions & 0 deletions hatch_build.py
@@ -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",
]
19 changes: 11 additions & 8 deletions materialx/__meta__.py
Expand Up @@ -69,9 +69,9 @@ class Version(namedtuple("Version", ["major", "minor", "micro", "release", "pre"
Version(1, 0, 0, "final") 1.0
Version(1, 2, 0, "final") 1.2
Version(1, 2, 3, "final") 1.2.3
Version(1, 2, 0, ".dev-alpha", pre=4) 1.2a4
Version(1, 2, 0, ".dev-beta", pre=4) 1.2b4
Version(1, 2, 0, ".dev-candidate", pre=4) 1.2rc4
Version(1, 2, 0, "alpha", pre=4) 1.2a4
Version(1, 2, 0, "beta", pre=4) 1.2b4
Version(1, 2, 0, "candidate", pre=4) 1.2rc4
Version(1, 2, 0, "final", post=1) 1.2.post1
Version(1, 2, 3, ".dev") 1.2.3.dev0
Version(1, 2, 3, ".dev", dev=1) 1.2.3.dev1
Expand Down Expand Up @@ -113,12 +113,12 @@ def __new__(cls, major, minor, micro, release="final", pre=0, post=0, dev=0):
elif dev:
raise ValueError("Version is not a development release.")

return super(Version, cls).__new__(cls, major, minor, micro, release, pre, post, dev)
return super().__new__(cls, major, minor, micro, release, pre, post, dev)

def _is_pre(self):
"""Is prerelease."""

return self.pre > 0
return bool(self.pre > 0)

def _is_dev(self):
"""Is development."""
Expand All @@ -128,7 +128,7 @@ def _is_dev(self):
def _is_post(self):
"""Is post."""

return self.post > 0
return bool(self.post > 0)

def _get_dev_status(self): # pragma: no cover
"""Get development status string."""
Expand All @@ -139,7 +139,7 @@ def _get_canonical(self):
"""Get the canonical output string."""

# Assemble major, minor, micro version and append `pre`, `post`, or `dev` if needed..
if self.micro == 0:
if self.micro == 0 and self.major != 0:
ver = "{}.{}".format(self.major, self.minor)
else:
ver = "{}.{}.{}".format(self.major, self.minor, self.micro)
Expand All @@ -153,11 +153,14 @@ def _get_canonical(self):
return ver


def parse_version(ver, pre=False):
def parse_version(ver):
"""Parse version into a comparable Version tuple."""

m = RE_VER.match(ver)

if m is None:
raise ValueError("'{}' is not a valid version".format(ver))

# Handle major, minor, micro
major = int(m.group('major'))
minor = int(m.group('minor')) if m.group('minor') else 0
Expand Down
49 changes: 46 additions & 3 deletions pyproject.toml
@@ -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.

3 changes: 2 additions & 1 deletion tox.ini
@@ -1,6 +1,7 @@
[tox]
isolated_build = true
envlist =
{py36,py37,py38,py39}, lint, documents
{py37,py38,py39,py310}, lint, documents

[testenv]
passenv = LANG
Expand Down