From 3ac4c2683d1b7df87e0940235e90dbce947a9e5b Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Sun, 27 Aug 2023 22:14:49 +0900 Subject: [PATCH 1/2] migrate to pyproject.toml --- pyproject.toml | 52 ++++++++++++++++++++++++++++++++++++++++++++ setup.py | 59 -------------------------------------------------- 2 files changed, 52 insertions(+), 59 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..70f29f3a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,52 @@ +[project] +name = "autopep8" +description = "A tool that automatically formats Python code to conform to the PEP 8 style guide" +license = {file = "LICENSE.rst"} +authors = [ + {name = "Hideo Hattori", email = "hhatto.jp@gmail.com"}, +] +readme = "README.rst" +keywords = [ + "automation", + "pep8", + "format", + "pycodestyle", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Quality Assurance", +] +requires-python = ">=3.6" +dependencies = [ + "pycodestyle >= 2.10.0", + "tomli; python_version < '3.11'", +] +dynamic = ["version"] + +[project.urls] +Repository = "https://github.com/hhatto/autopep8" + +[project.scripts] +autopep8 = "autopep8:main" + +[tool.setuptools] +py-modules = ["autopep8"] + +[tool.setuptools.dynamic] +version = {attr = "autopep8.__version__"} + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py deleted file mode 100644 index 9e48162e..00000000 --- a/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""Setup for autopep8.""" - -import ast -import io - -from setuptools import setup - - -INSTALL_REQUIRES = ( - ['pycodestyle >= 2.10.0', 'tomli; python_version < "3.11"'] -) - - -def version(): - """Return version string.""" - with io.open('autopep8.py') as input_file: - for line in input_file: - if line.startswith('__version__'): - return ast.parse(line).body[0].value.s - - -with io.open('README.rst') as readme: - setup( - name='autopep8', - version=version(), - description='A tool that automatically formats Python code to conform ' - 'to the PEP 8 style guide', - long_description=readme.read(), - license='Expat License', - author='Hideo Hattori', - author_email='hhatto.jp@gmail.com', - url='https://github.com/hhatto/autopep8', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - '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', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Quality Assurance', - ], - keywords='automation, pep8, format, pycodestyle', - install_requires=INSTALL_REQUIRES, - python_requires=">=3.6", - test_suite='test.test_autopep8', - py_modules=['autopep8'], - zip_safe=False, - entry_points={'console_scripts': ['autopep8 = autopep8:main']}, - ) From 8bf787ebff747450f9e893fb5093e1a769a32ea3 Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Sun, 27 Aug 2023 22:55:00 +0900 Subject: [PATCH 2/2] fix unit tests --- test/test_autopep8.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_autopep8.py b/test/test_autopep8.py index c6319cfa..d58cd9c3 100755 --- a/test/test_autopep8.py +++ b/test/test_autopep8.py @@ -88,7 +88,7 @@ def test_detect_encoding(self): self.assertEqual( 'utf-8', autopep8.detect_encoding( - os.path.join(ROOT_DIR, 'setup.py'))) + os.path.join(ROOT_DIR, 'test', 'test_autopep8.py'))) def test_detect_encoding_with_cookie(self): self.assertEqual( @@ -5959,6 +5959,7 @@ def test_pyproject_toml_config_local_int_value(self): with temporary_file_context('[tool.autopep8]\naggressive=2\n') as filename: args = autopep8.parse_args( [os.path.join(FAKE_CONFIGURATION, 'foo.py'), + '--ignore-local-config', '--global-config={}'.format(filename)], apply_config=True) self.assertEqual(args.aggressive, 2)