Skip to content

Commit 754b9a5

Browse files
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 <[email protected]> Co-authored-by: Peter Newman <[email protected]>
1 parent 3f06fb0 commit 754b9a5

File tree

8 files changed

+142
-74
lines changed

8 files changed

+142
-74
lines changed

.github/workflows/codespell-private.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# For general usage in your repo, see the example in codespell.yml
33
# https://github.com/codespell-project/codespell
44
# Concurrency cancels an action on a given PR once a new commit is pushed
5-
name: codespell Private Actions
5+
name: Test Codespell
66
concurrency:
77
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
88
cancel-in-progress: true
@@ -29,14 +29,15 @@ jobs:
2929
with:
3030
python-version: ${{ matrix.python-version }}
3131
- run: sudo apt-get install libaspell-dev aspell-en
32-
- run: |
32+
- name: Install dependencies
33+
run: |
3334
python --version # just to check
3435
pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
35-
pip install codecov chardet "setuptools!=47.2.0" docutils
36+
pip install --upgrade codecov chardet "setuptools!=47.2.0" docutils setuptools_scm[toml]
3637
pip install aspell-python-py3
3738
pip install -e ".[dev]" # install the codespell dev packages
38-
- run: python setup.py install
3939
- run: codespell --help
40+
- run: codespell --version
4041
- run: make check
4142
- 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/*"
4243
# this file has an error

.github/workflows/release.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Upload a Python Package using Twine when a release is created
2+
3+
name: Build
4+
on:
5+
release:
6+
types: [published]
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
package:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.10'
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install build twine
30+
- name: Build package
31+
run: python -m build
32+
- name: Check package
33+
run: twine check --strict dist/*
34+
- name: Check env vars
35+
run: |
36+
echo "Triggered by: ${{ github.event_name }}"
37+
38+
# PyPI on release
39+
pypi:
40+
needs: package
41+
runs-on: ubuntu-latest
42+
if: github.event_name == 'release'
43+
steps:
44+
- name: Publish to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
user: __token__
48+
password: ${{ secrets.PYPI_API_TOKEN }}
49+
50+
# TestPyPI on push
51+
test_pypi:
52+
needs: package
53+
runs-on: ubuntu-latest
54+
if: github.event_name == 'push'
55+
steps:
56+
- name: Publish to TestPyPI
57+
uses: pypa/gh-action-pypi-publish@release/v1
58+
with:
59+
user: __token__
60+
password: ${{ secrets.TESTPYPI_API_TOKEN }}
61+
repository_url: https://test.pypi.org/legacy

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ codespell.egg-info
77
*.orig
88
.cache/
99
.pytest_cache/
10+
codespell_lib/_version.py

Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trim-dictionaries:
4545
done
4646

4747
check-manifest:
48-
check-manifest
48+
check-manifest --no-build-isolation
4949

5050
check-distutils:
5151
python setup.py check --restructuredtext --strict
@@ -56,8 +56,5 @@ flake8:
5656
pytest:
5757
pytest codespell_lib
5858

59-
pypi:
60-
python setup.py sdist register upload
61-
6259
clean:
6360
rm -rf codespell.1

codespell_lib/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from ._codespell import main, _script_main, VERSION as __version__ # noqa
1+
from ._codespell import main, _script_main # noqa
2+
from ._version import __version__ # noqa

codespell_lib/_codespell.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import sys
2727
import textwrap
2828

29+
# autogenerated by setuptools_scm
30+
from ._version import __version__ as VERSION
31+
2932
word_regex_def = u"[\\w\\-'’`]+"
3033
# While we want to treat characters like ( or " as okay for a starting break,
3134
# these may occur unescaped in URIs, and so we are more restrictive on the
@@ -36,7 +39,6 @@
3639
USAGE = """
3740
\t%prog [OPTIONS] [file1 file2 ... fileN]
3841
"""
39-
VERSION = '2.3.0.dev0'
4042

4143
supported_languages_en = ('en', 'en_GB', 'en_US', 'en_CA', 'en_AU')
4244
supported_languages = supported_languages_en

pyproject.toml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
2+
3+
[project]
4+
name = "codespell"
5+
description = "Codespell"
6+
readme = { file = "README.rst", content-type = "text/x-rst" }
7+
requires-python = ">=3.7"
8+
license = {text = "GPL v2"}
9+
authors = [
10+
{name = "Lucas De Marchi", email = "[email protected]"},
11+
]
12+
classifiers = [
13+
"Intended Audience :: Developers",
14+
"License :: OSI Approved",
15+
"Programming Language :: Python",
16+
"Topic :: Software Development",
17+
"Operating System :: Microsoft :: Windows",
18+
"Operating System :: POSIX",
19+
"Operating System :: Unix",
20+
"Operating System :: MacOS"
21+
]
22+
dependencies = []
23+
dynamic = ["version"]
24+
25+
[project.optional-dependencies]
26+
dev = [
27+
"check-manifest",
28+
"flake8",
29+
"pytest",
30+
"pytest-cov",
31+
"pytest-dependency",
32+
"tomli"
33+
]
34+
hard-encoding-detection = [
35+
"chardet"
36+
]
37+
toml = [
38+
"tomli; python_version < '3.11'"
39+
]
40+
41+
[project.scripts]
42+
codespell = "codespell_lib:_script_main"
43+
44+
[project.urls]
45+
homepage = "https://github.com/codespell-project/codespell"
46+
repository = "https://github.com/codespell-project/codespell"
47+
48+
[build-system]
49+
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
50+
build-backend = "setuptools.build_meta"
51+
52+
[tool.setuptools_scm]
53+
write_to = "codespell_lib/_version.py"
54+
55+
[tool.setuptools.packages.find]
56+
exclude = [
57+
"snap",
58+
"dist"
59+
]
60+
61+
[tool.setuptools.package-data]
62+
codespell_lib = [
63+
"data/dictionary*.txt",
64+
"data/linux-kernel.exclude"
65+
]
66+
67+
[tool.check-manifest]
68+
ignore = ["codespell_lib/_version.py"]

setup.py

+1-64
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,6 @@
11
#! /usr/bin/env python
22

3-
# adapted from mne-python
4-
5-
import os
6-
73
from setuptools import setup
84

9-
from codespell_lib import __version__
10-
11-
DISTNAME = 'codespell'
12-
DESCRIPTION = """Codespell"""
13-
MAINTAINER = 'Lucas De Marchi'
14-
MAINTAINER_EMAIL = '[email protected]'
15-
URL = 'https://github.com/codespell-project/codespell/'
16-
LICENSE = 'GPL v2'
17-
DOWNLOAD_URL = 'https://github.com/codespell-project/codespell/'
18-
with open('README.rst', 'r') as f:
19-
LONG_DESCRIPTION = f.read()
20-
215
if __name__ == "__main__":
22-
if os.path.exists('MANIFEST'):
23-
os.remove('MANIFEST')
24-
25-
setup(name=DISTNAME,
26-
maintainer=MAINTAINER,
27-
include_package_data=True,
28-
maintainer_email=MAINTAINER_EMAIL,
29-
description=DESCRIPTION,
30-
license=LICENSE,
31-
url=URL,
32-
version=__version__,
33-
download_url=DOWNLOAD_URL,
34-
long_description=LONG_DESCRIPTION,
35-
long_description_content_type='text/x-rst',
36-
zip_safe=False,
37-
classifiers=['Intended Audience :: Developers',
38-
'License :: OSI Approved',
39-
'Programming Language :: Python',
40-
'Topic :: Software Development',
41-
'Operating System :: Microsoft :: Windows',
42-
'Operating System :: POSIX',
43-
'Operating System :: Unix',
44-
'Operating System :: MacOS'],
45-
platforms='any',
46-
python_requires='>=3.7',
47-
packages=[
48-
'codespell_lib',
49-
'codespell_lib.tests',
50-
'codespell_lib.data',
51-
],
52-
package_data={'codespell_lib': [
53-
os.path.join('data', 'dictionary*.txt'),
54-
os.path.join('data', 'linux-kernel.exclude'),
55-
]},
56-
entry_points={
57-
'console_scripts': [
58-
'codespell = codespell_lib:_script_main'
59-
],
60-
},
61-
# TODO: toml will need to be updated when 3.11 comes out as it's a
62-
# CPython module there
63-
extras_require={
64-
"dev": ["check-manifest", "flake8", "pytest", "pytest-cov",
65-
"pytest-dependency", "tomli"],
66-
"hard-encoding-detection": ["chardet"],
67-
"toml": ["tomli"],
68-
}
69-
)
6+
setup()

0 commit comments

Comments
 (0)