Skip to content

Commit

Permalink
Use pyproject.toml, tox, and pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
movermeyer committed Oct 4, 2023
1 parent ce46bff commit bdfc41b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
38 changes: 31 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[project]
name = "backports-datetime-fromisoformat"
version = "2.0.0"
authors = [
{ name="Michael Overmeyer", email="[email protected]" },
]
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"
36 changes: 0 additions & 36 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -30,43 +25,12 @@
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="[email protected]",
url="https://github.com/movermeyer/backports.datetime_fromisoformat",

packages=["backports", "backports.datetime_fromisoformat"],

ext_modules=[Extension("backports._datetime_fromisoformat", [
os.path.join("backports", "datetime_fromisoformat", "module.c"),
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'
]
)
1 change: 0 additions & 1 deletion tests/tests.py → tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,5 @@ def test_basic_pickle_and_copy(self):
dt3 = copy.deepcopy(dt)
self.assertEqual(dt, dt3)


if __name__ == '__main__':
unittest.main()
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bdfc41b

Please sign in to comment.