-
Notifications
You must be signed in to change notification settings - Fork 483
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
MAINT: Use pyproject and setuptools_scm #2523
Changes from all commits
3733b5d
e0ad022
caefe3c
75c96be
77d54db
809885f
9ccac8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ codespell.egg-info | |
*.orig | ||
.cache/ | ||
.pytest_cache/ | ||
codespell_lib/_version.py |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ trim-dictionaries: | |
done | ||
|
||
check-manifest: | ||
check-manifest | ||
check-manifest --no-build-isolation | ||
|
||
check-distutils: | ||
python setup.py check --restructuredtext --strict | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to work fine, I get the same
|
||
|
@@ -56,8 +56,5 @@ flake8: | |
pytest: | ||
pytest codespell_lib | ||
|
||
pypi: | ||
python setup.py sdist register upload | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could definitely do with a note telling you to just release on GitHub or something.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it would make sense to add a note here, as I don't think the Makefile is a common place to look for "how to make a release" information. We could add it to the readme, but not many people actually need to know. So I created this: https://github.com/codespell-project/codespell/wiki/How-to-make-a-release |
||
|
||
clean: | ||
rm -rf codespell.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "[email protected]"}, | ||
] | ||
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"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,6 @@ | ||
#! /usr/bin/env python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My sense is that everything will work as expected if this file is deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept it for legacy purposes / compat with existing calls like https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html |
||
|
||
# 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 = '[email protected]' | ||
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want releases here too, so TestPyPI is always equal to, or ahead of, the live one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
TestPyPI
is really only meant to be there so that when this is merged we can see if it works at all and then iterate until it does so that eventually theRelease
step actually works. Once it works, I'd rather just delete this altogether,codespell
is a small project and installing the "latest and greatest" is already nearly trivial withpip
. I think it's actually easier/more common for people to know the command for "install the latest from GitHub source" than it is "add and use this separate TestPyPI repository index" 🤷