Skip to content

Commit

Permalink
Configure setuptools using the declarative syntax in setup.cfg (#239)
Browse files Browse the repository at this point in the history
This approach avoids mixing code with configuration and therefore
requires less custom code at build-time and installation-time. Removing
this custom setup.py code reduces cross-project boilerplate.

https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html
  • Loading branch information
jdufresne committed Sep 6, 2021
1 parent 5c73bfc commit 49b8341
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 55 deletions.
41 changes: 41 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
[metadata]
name = chardet
version = attr: chardet.__version__
description = Universal encoding detector for Python 3
long_description = file: README.rst
author = Mark Pilgrim
author_email = mark@diveintomark.org
maintainer = Daniel Blanchard
maintainer_email = dan.blanchard@gmail.com
url = https://github.com/chardet/chardet
license = LGPL
keywords = encoding, i18n, xml
project_urls =
Documentation = https://chardet.readthedocs.io/
GitHub Project = https://github.com/chardet/chardet
Issue Tracker = https://github.com/chardet/chardet/issues
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Text Processing :: Linguistic

[options]
python_requires = >=3.6
packages = find:

[options.entry_points]
console_scripts =
chardetect = chardet.cli.chardetect:main

[tool:pytest]
addopts = -v
python_files = test.py
Expand Down
57 changes: 2 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,3 @@
from setuptools import find_packages, setup
from setuptools import setup


# Get version without importing, which avoids dependency issues
def get_version():
import re

with open("chardet/version.py") as version_file:
return re.search(
r"""__version__\s+=\s+(['"])(?P<version>.+?)\1""", version_file.read()
).group("version")


def readme():
with open("README.rst") as f:
return f.read()


setup(
name="chardet",
version=get_version(),
description="Universal encoding detector for Python 3",
long_description=readme(),
author="Mark Pilgrim",
author_email="mark@diveintomark.org",
maintainer="Daniel Blanchard",
maintainer_email="dan.blanchard@gmail.com",
url="https://github.com/chardet/chardet",
license="LGPL",
keywords=["encoding", "i18n", "xml"],
project_urls={
"Documentation": "https://chardet.readthedocs.io/",
"GitHub Project": "https://github.com/chardet/chardet",
"Issue Tracker": "https://github.com/chardet/chardet/issues",
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Linguistic",
],
packages=find_packages(),
python_requires=">=3.6",
entry_points={"console_scripts": ["chardetect = chardet.cli.chardetect:main"]},
)
setup()

0 comments on commit 49b8341

Please sign in to comment.