Browse Source

Merge pull request #156 from hugovk/master

Use stdlib tomllib for Python 3.11+
master
Marius Gedminas 2 months ago committed by GitHub
parent
commit
6f728807a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      .github/workflows/build.yml
  2. 11
      check_manifest.py
  3. 2
      setup.py
  4. 2
      tox.ini

14
.github/workflows/build.yml

@ -18,12 +18,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11-dev"
- "pypy-3.7"
vcs:
- bzr
@ -39,15 +41,15 @@ jobs:
# ubuntu-18.04 and ubuntu20.04.
- name: Git clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: "${{ matrix.python-version }}"
- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
@ -95,15 +97,15 @@ jobs:
steps:
- name: Git clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ env.default_python || '3.9' }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: "${{ env.default_python || '3.9' }}"
- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('tox.ini', 'setup.py') }}

11
check_manifest.py

@ -34,7 +34,12 @@ from contextlib import contextmanager
from typing import List, Optional, Union
from xml.etree import ElementTree as ET
import tomli
if sys.version_info >= (3, 11):
import tomllib # pragma: nocover
else:
import tomli as tomllib # pragma: nocover
from setuptools.command.egg_info import translate_pattern
@ -698,7 +703,7 @@ def _load_config():
"""
if os.path.exists("pyproject.toml"):
with open('pyproject.toml', 'rb') as f:
config = tomli.load(f)
config = tomllib.load(f)
if CFG_SECTION_CHECK_MANIFEST in config.get("tool", {}):
return config["tool"][CFG_SECTION_CHECK_MANIFEST]
@ -890,7 +895,7 @@ def should_use_pep_517():
if not os.path.exists('pyproject.toml'):
return False
with open('pyproject.toml', 'rb') as f:
config = tomli.load(f)
config = tomllib.load(f)
if "build-system" not in config:
return False
if "build-backend" not in config["build-system"]:

2
setup.py

@ -60,7 +60,7 @@ setup(
install_requires=[
'build>=0.1',
'setuptools',
'tomli',
'tomli;python_version < "3.11"',
],
extras_require={
'test': [

2
tox.ini

@ -1,6 +1,6 @@
[tox]
envlist =
py37,py38,py39,py310,pypy3,flake8
py37,py38,py39,py310,py311,pypy3,flake8
[testenv]
passenv = LANG LC_CTYPE LC_ALL MSYSTEM

Loading…
Cancel
Save