From aac1adf29638e483d46bcfe311ca66678b03c84b Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 16:44:31 -0700 Subject: [PATCH 1/4] Use poetry for dependency management --- .github/workflows/tests.yml | 22 +++++++++++--------- .gitignore | 1 + mf2py/version.py | 4 +++- pyproject.toml | 27 ++++++++++++++++++++++++ requirements.txt | 8 -------- setup.py | 41 ------------------------------------- 6 files changed, 43 insertions(+), 60 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a84132b..6647c24 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,8 +11,8 @@ jobs: build: strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] - runs-on: ubuntu-20.04 + python-version: ["3.7", "3.8", "3.9", "3.10", "pypy3.8", "pypy3.9"] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: @@ -25,12 +25,14 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.2.2 + virtualenvs-in-project: true - name: Install dependencies - run: | - python -m venv env - source env/bin/activate - pip install -r requirements.txt - - name: Run tests with pytest - run: | - source env/bin/activate - pytest \ No newline at end of file + run: poetry install --no-interaction --no-root + - name: Install library + run: poetry install --no-interaction + - name: Run tests + run: poetry run pytest \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7f90a96..717d41c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ mf2py.egg-info/ nbproject/ venv/ *~ +poetry.lock \ No newline at end of file diff --git a/mf2py/version.py b/mf2py/version.py index c382fd6..ea79e13 100644 --- a/mf2py/version.py +++ b/mf2py/version.py @@ -2,4 +2,6 @@ # the value without loading mf2py (loading mf2py is bad if its dependencies # haven't been installed yet, which is common during setup) -__version__ = '2.0.0' +import importlib.metadata + +__version__ = importlib.metadata.metadata("microformats")["Version"] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cc2436c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,27 @@ +[tool.poetry] +name = "mf2py" +version = "1.1.3" +description = "Microformats parser" +authors = ["Tom Morris "] +license = "MIT" +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Topic :: Text Processing :: Markup :: HTML" +] + +[tool.poetry.dependencies] +python = ">=3.7" +html5lib = "^1.1" +requests = "^2.28.2" +beautifulsoup4 = "^4.11.1" + +[tool.poetry.group.dev.dependencies] +lxml = "^4.9.2" +mock = "^5.0.1" +pytest = "^7.2.1" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 0b576ea..0000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Keep in sync with setup.py's install_requires! -html5lib==1.1 -pytest==7.2.1 -mock==2.0.0 -lxml==4.9.1 -requests==2.31.0 -BeautifulSoup4==4.6.3 --e . diff --git a/setup.py b/setup.py deleted file mode 100644 index 0373389..0000000 --- a/setup.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup -import os.path - -ns = {} -with open(os.path.join(os.path.dirname(__file__), 'mf2py/version.py'))\ - as version_file: - exec(version_file.read(), ns) - - -setup(name='mf2py', - version=ns['__version__'], - description='Python Microformats2 parser', - long_description=open('README.md').read(), - long_description_content_type='text/markdown', - author='Tom Morris', - author_email='tom@tommorris.org', - url='http://microformats.org/wiki/mf2py', - python_requires='>=2.7', - install_requires=[ - # Keep in sync with requirements.txt! - 'html5lib>=1.1', - 'requests>=2.18.4', - 'BeautifulSoup4>=4.6.0', - ], - tests_require=[ - 'lxml', - 'mock', - 'pytest', - ], - packages=['mf2py'], - package_data={'mf2py': ['backcompat-rules/*.json']}, - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Topic :: Text Processing :: Markup :: HTML' - ]) From 34fbf8a40d989470283d2e486ad10b2797fb82ca Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 16:48:39 -0700 Subject: [PATCH 2/4] Fix typo in version.py --- mf2py/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mf2py/version.py b/mf2py/version.py index ea79e13..4adb557 100644 --- a/mf2py/version.py +++ b/mf2py/version.py @@ -4,4 +4,4 @@ import importlib.metadata -__version__ = importlib.metadata.metadata("microformats")["Version"] \ No newline at end of file +__version__ = importlib.metadata.metadata("mf2py")["Version"] From 5fb5b491d1e79004cb6bd3c03884e47167d33610 Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 18:01:43 -0700 Subject: [PATCH 3/4] Drop 3.7 as `importlib.metadata` appears in 3.8 Python 3.7 hit EOL yesterday (2023-06-27). --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6647c24..f07171d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: build: strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "pypy3.8", "pypy3.9"] + python-version: ["3.8", "3.9", "3.10", "pypy3.8", "pypy3.9"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -35,4 +35,4 @@ jobs: - name: Install library run: poetry install --no-interaction - name: Run tests - run: poetry run pytest \ No newline at end of file + run: poetry run pytest From b8fbad3d058852d7d1672e4d11768fc246944688 Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 18:08:20 -0700 Subject: [PATCH 4/4] Update pyproject.toml Increase python version requirement. --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cc2436c..0febd7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ classifiers = [ ] [tool.poetry.dependencies] -python = ">=3.7" +python = ">=3.8" html5lib = "^1.1" requests = "^2.28.2" beautifulsoup4 = "^4.11.1" @@ -24,4 +24,4 @@ pytest = "^7.2.1" [build-system] requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file +build-backend = "poetry.core.masonry.api"