mirror of
https://github.com/codespell-project/codespell.git
synced 2025-05-17 23:46:43 +08:00
MAINT: Use pyproject and setuptools_scm (#2523)
* MAINT: Use pyproject and setuptools_scm * FIX: Name * FIX: Better * FIX: Better * FIX: Better * FIX: Ver * Update .github/workflows/codespell-private.yml Co-authored-by: Peter Newman <peternewman@users.noreply.github.com> Co-authored-by: Peter Newman <peternewman@users.noreply.github.com>
This commit is contained in:
9
.github/workflows/codespell-private.yml
vendored
9
.github/workflows/codespell-private.yml
vendored
@ -2,7 +2,7 @@
|
||||
# For general usage in your repo, see the example in codespell.yml
|
||||
# https://github.com/codespell-project/codespell
|
||||
# Concurrency cancels an action on a given PR once a new commit is pushed
|
||||
name: codespell Private Actions
|
||||
name: Test Codespell
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
|
||||
cancel-in-progress: true
|
||||
@ -29,14 +29,15 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- run: sudo apt-get install libaspell-dev aspell-en
|
||||
- run: |
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python --version # just to check
|
||||
pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
|
||||
pip install codecov chardet "setuptools!=47.2.0" docutils
|
||||
pip install --upgrade codecov chardet "setuptools!=47.2.0" docutils setuptools_scm[toml]
|
||||
pip install aspell-python-py3
|
||||
pip install -e ".[dev]" # install the codespell dev packages
|
||||
- run: python setup.py install
|
||||
- run: codespell --help
|
||||
- run: codespell --version
|
||||
- run: make check
|
||||
- run: codespell --check-filenames --skip="./.git/*,*.pyc,./codespell_lib/tests/test_basic.py,./codespell_lib/data/*,./example/code.c,./build/lib/codespell_lib/tests/test_basic.py,./build/lib/codespell_lib/data/*,README.rst,*.egg-info/*"
|
||||
# this file has an error
|
||||
|
61
.github/workflows/release.yml
vendored
Normal file
61
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
# Upload a Python Package using Twine when a release is created
|
||||
|
||||
name: Build
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install build twine
|
||||
- name: Build package
|
||||
run: python -m build
|
||||
- name: Check package
|
||||
run: twine check --strict dist/*
|
||||
- name: Check env vars
|
||||
run: |
|
||||
echo "Triggered by: ${{ github.event_name }}"
|
||||
|
||||
# PyPI on release
|
||||
pypi:
|
||||
needs: package
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'release'
|
||||
steps:
|
||||
- name: Publish to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
# TestPyPI on push
|
||||
test_pypi:
|
||||
needs: package
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
steps:
|
||||
- name: Publish to TestPyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.TESTPYPI_API_TOKEN }}
|
||||
repository_url: https://test.pypi.org/legacy
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ codespell.egg-info
|
||||
*.orig
|
||||
.cache/
|
||||
.pytest_cache/
|
||||
codespell_lib/_version.py
|
||||
|
5
Makefile
5
Makefile
@ -45,7 +45,7 @@ trim-dictionaries:
|
||||
done
|
||||
|
||||
check-manifest:
|
||||
check-manifest
|
||||
check-manifest --no-build-isolation
|
||||
|
||||
check-distutils:
|
||||
python setup.py check --restructuredtext --strict
|
||||
@ -56,8 +56,5 @@ flake8:
|
||||
pytest:
|
||||
pytest codespell_lib
|
||||
|
||||
pypi:
|
||||
python setup.py sdist register upload
|
||||
|
||||
clean:
|
||||
rm -rf codespell.1
|
||||
|
@ -1 +1,2 @@
|
||||
from ._codespell import main, _script_main, VERSION as __version__ # noqa
|
||||
from ._codespell import main, _script_main # noqa
|
||||
from ._version import __version__ # noqa
|
||||
|
@ -26,6 +26,9 @@ import re
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
# autogenerated by setuptools_scm
|
||||
from ._version import __version__ as VERSION
|
||||
|
||||
word_regex_def = u"[\\w\\-'’`]+"
|
||||
# While we want to treat characters like ( or " as okay for a starting break,
|
||||
# these may occur unescaped in URIs, and so we are more restrictive on the
|
||||
@ -36,7 +39,6 @@ encodings = ('utf-8', 'iso-8859-1')
|
||||
USAGE = """
|
||||
\t%prog [OPTIONS] [file1 file2 ... fileN]
|
||||
"""
|
||||
VERSION = '2.3.0.dev0'
|
||||
|
||||
supported_languages_en = ('en', 'en_GB', 'en_US', 'en_CA', 'en_AU')
|
||||
supported_languages = supported_languages_en
|
||||
|
68
pyproject.toml
Normal file
68
pyproject.toml
Normal file
@ -0,0 +1,68 @@
|
||||
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
|
||||
|
||||
[project]
|
||||
name = "codespell"
|
||||
description = "Codespell"
|
||||
readme = { file = "README.rst", content-type = "text/x-rst" }
|
||||
requires-python = ">=3.7"
|
||||
license = {text = "GPL v2"}
|
||||
authors = [
|
||||
{name = "Lucas De Marchi", email = "lucas.de.marchi@gmail.com"},
|
||||
]
|
||||
classifiers = [
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved",
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Software Development",
|
||||
"Operating System :: Microsoft :: Windows",
|
||||
"Operating System :: POSIX",
|
||||
"Operating System :: Unix",
|
||||
"Operating System :: MacOS"
|
||||
]
|
||||
dependencies = []
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"check-manifest",
|
||||
"flake8",
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
"pytest-dependency",
|
||||
"tomli"
|
||||
]
|
||||
hard-encoding-detection = [
|
||||
"chardet"
|
||||
]
|
||||
toml = [
|
||||
"tomli; python_version < '3.11'"
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
codespell = "codespell_lib:_script_main"
|
||||
|
||||
[project.urls]
|
||||
homepage = "https://github.com/codespell-project/codespell"
|
||||
repository = "https://github.com/codespell-project/codespell"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools_scm]
|
||||
write_to = "codespell_lib/_version.py"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
exclude = [
|
||||
"snap",
|
||||
"dist"
|
||||
]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
codespell_lib = [
|
||||
"data/dictionary*.txt",
|
||||
"data/linux-kernel.exclude"
|
||||
]
|
||||
|
||||
[tool.check-manifest]
|
||||
ignore = ["codespell_lib/_version.py"]
|
65
setup.py
65
setup.py
@ -1,69 +1,6 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# adapted from mne-python
|
||||
|
||||
import os
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
from codespell_lib import __version__
|
||||
|
||||
DISTNAME = 'codespell'
|
||||
DESCRIPTION = """Codespell"""
|
||||
MAINTAINER = 'Lucas De Marchi'
|
||||
MAINTAINER_EMAIL = 'lucas.de.marchi@gmail.com'
|
||||
URL = 'https://github.com/codespell-project/codespell/'
|
||||
LICENSE = 'GPL v2'
|
||||
DOWNLOAD_URL = 'https://github.com/codespell-project/codespell/'
|
||||
with open('README.rst', 'r') as f:
|
||||
LONG_DESCRIPTION = f.read()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.exists('MANIFEST'):
|
||||
os.remove('MANIFEST')
|
||||
|
||||
setup(name=DISTNAME,
|
||||
maintainer=MAINTAINER,
|
||||
include_package_data=True,
|
||||
maintainer_email=MAINTAINER_EMAIL,
|
||||
description=DESCRIPTION,
|
||||
license=LICENSE,
|
||||
url=URL,
|
||||
version=__version__,
|
||||
download_url=DOWNLOAD_URL,
|
||||
long_description=LONG_DESCRIPTION,
|
||||
long_description_content_type='text/x-rst',
|
||||
zip_safe=False,
|
||||
classifiers=['Intended Audience :: Developers',
|
||||
'License :: OSI Approved',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Software Development',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: Unix',
|
||||
'Operating System :: MacOS'],
|
||||
platforms='any',
|
||||
python_requires='>=3.7',
|
||||
packages=[
|
||||
'codespell_lib',
|
||||
'codespell_lib.tests',
|
||||
'codespell_lib.data',
|
||||
],
|
||||
package_data={'codespell_lib': [
|
||||
os.path.join('data', 'dictionary*.txt'),
|
||||
os.path.join('data', 'linux-kernel.exclude'),
|
||||
]},
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'codespell = codespell_lib:_script_main'
|
||||
],
|
||||
},
|
||||
# TODO: toml will need to be updated when 3.11 comes out as it's a
|
||||
# CPython module there
|
||||
extras_require={
|
||||
"dev": ["check-manifest", "flake8", "pytest", "pytest-cov",
|
||||
"pytest-dependency", "tomli"],
|
||||
"hard-encoding-detection": ["chardet"],
|
||||
"toml": ["tomli"],
|
||||
}
|
||||
)
|
||||
setup()
|
||||
|
Reference in New Issue
Block a user