From bdfc41beab1dc77f22944cd666bdc8c853d3493a Mon Sep 17 00:00:00 2001 From: Michael Overmeyer Date: Wed, 4 Oct 2023 11:45:40 -0400 Subject: [PATCH] Use pyproject.toml, tox, and pytest --- .github/dependabot.yml | 6 +++++ .github/workflows/test.yml | 38 ++++++++++++++++++++++++------ pyproject.toml | 32 +++++++++++++++++++++++++ setup.py | 36 ---------------------------- tests/{tests.py => test_basics.py} | 1 - tox.ini | 5 ++-- 6 files changed, 72 insertions(+), 46 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 pyproject.toml rename tests/{tests.py => test_basics.py} (99%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7871a0d..b533220 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -24,10 +24,35 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install tox + run: pip install tox + - name: Run tests - run: STRICT_WARNINGS=1 python setup.py test + run: tox build-old: + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ["3.6"] + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + # tox doesn't support these versions of Python anymore + - name: Install tox + run: pip install 'tox < 3' + + - name: Run tests + run: tox + + + build-even-older: runs-on: ubuntu-18.04 strategy: matrix: @@ -41,10 +66,9 @@ jobs: with: python-version: ${{ matrix.python-version }} - # Requires explicit pytz installation - - run: pip install pytz - - - run: pip install pytz + # tox doesn't support these versions of Python anymore + - name: Install tox + run: pip install 'tox < 3' - name: Run tests - run: STRICT_WARNINGS=1 python setup.py test + run: tox diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4468123 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,32 @@ +[project] +name = "backports-datetime-fromisoformat" +version = "2.0.0" +authors = [ + { name="Michael Overmeyer", email="backports@movermeyer.com" }, +] +description = "Backport of Python 3.11's datetime.fromisoformat" +readme = "README.rst" +requires-python = ">3" +license = {file = "LICENSE"} +classifiers = [ + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + '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', +] + +[project.urls] +Homepage = "https://github.com/movermeyer/backports.datetime_fromisoformat" +Documentation = "https://github.com/movermeyer/backports.datetime_fromisoformat" +Repository = "https://github.com/movermeyer/backports.datetime_fromisoformat" +"Bug Tracker" = "https://github.com/movermeyer/backports.datetime_fromisoformat/issues" +Changelog = "https://github.com/movermeyer/backports.datetime_fromisoformat/CHANGELOG.md" diff --git a/setup.py b/setup.py index ee24d9e..1cdbcca 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,6 @@ import os from setuptools import setup, Extension -# workaround for open() with encoding='' python2/3 compatibility -from io import open - -with open('README.rst', encoding='utf-8') as file: - long_description = file.read() # We want to force all warnings to be considered errors. That way we get to catch potential issues during # development and at PR review time. @@ -30,18 +25,7 @@ os.environ["_CL_"] = "" os.environ["_CL_"] += " /WX" -VERSION = "2.0.0" - setup( - name="backports-datetime-fromisoformat", - version=VERSION, - description="Backport of Python 3.11's datetime.fromisoformat", - long_description=long_description, - license="MIT", - author="Michael Overmeyer", - author_email="backports@movermeyer.com", - url="https://github.com/movermeyer/backports.datetime_fromisoformat", - packages=["backports", "backports.datetime_fromisoformat"], ext_modules=[Extension("backports._datetime_fromisoformat", [ @@ -49,24 +33,4 @@ os.path.join("backports", "datetime_fromisoformat", "_datetimemodule.c"), os.path.join("backports", "datetime_fromisoformat", "timezone.c") ])], - - test_suite='tests', - tests_require=[ - 'pytz' - ], - classifiers=[ - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - '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' - ] ) diff --git a/tests/tests.py b/tests/test_basics.py similarity index 99% rename from tests/tests.py rename to tests/test_basics.py index 05fff51..9581f02 100644 --- a/tests/tests.py +++ b/tests/test_basics.py @@ -626,6 +626,5 @@ def test_basic_pickle_and_copy(self): dt3 = copy.deepcopy(dt) self.assertEqual(dt, dt3) - if __name__ == '__main__': unittest.main() diff --git a/tox.ini b/tox.ini index aac5878..e269b1e 100644 --- a/tox.ini +++ b/tox.ini @@ -2,9 +2,10 @@ envlist = py311,py310,py39,py38,py37,py36,py35,py34 [testenv] +package = sdist setenv = STRICT_WARNINGS = 1 deps= + pytest pytz - nose -commands=nosetests +commands = pytest tests