diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 5e8a06d2..7991f032 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -88,17 +88,16 @@ jobs: run: | python -m venv venv source venv/bin/activate - python -m pip install --upgrade pip setuptools wheel twine - pip install build + python -m pip install --upgrade pip setuptools wheel twine build sudo apt update sudo apt install -y twine - name: Build Python package run: | + source venv/bin/activate echo "Using version $PKG_VERSION_STRICT" sed -i -r -e "s/^__version__ += '.*'$/__version__ = '$PKG_VERSION_STRICT'/" xml2rfc/__init__.py - python ./setup.py setopt --command=metadata --option=version --set-value=$PKG_VERSION_STRICT - python ./setup.py sdist --dist-dir dist + python -m build --sdist - name: Publish to Test PyPI if: env.SHOULD_DEPLOY != 'true' diff --git a/MANIFEST.in b/MANIFEST.in index d6b458cc..ede0827c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,3 +9,4 @@ include tests/valid/* include tox.ini include requirements.txt include xml2rfc/data/* +include xml2rfc/templates/* diff --git a/Makefile b/Makefile index 1dabbd52..439d1002 100644 --- a/Makefile +++ b/Makefile @@ -73,16 +73,18 @@ env/bin/python: .PHONY: install install: python3 --version - python3 setup.py --quiet install - python3 configtest.py + python3 -m pip install . --quiet rm -rf xml2rfc.egg-info/ -test: install flaketest xml2rfc/data/v3.rng pytests +test: install flaketest xml2rfc/data/v3.rng pytests configtest flaketest: pyflakes xml2rfc @[ -d tests/failed/ ] && rm -f tests/failed/* +configtest: + python3 configtest.py + pytests: python3 test.py --verbose diff --git a/docker/base.Dockerfile b/docker/base.Dockerfile index b5101232..da8ba667 100644 --- a/docker/base.Dockerfile +++ b/docker/base.Dockerfile @@ -48,7 +48,14 @@ RUN mkdir -p ~/.fonts/opentype && \ fc-cache -f # Copy everything required to build xml2rfc -COPY requirements.txt setup.py README.md LICENSE Makefile configtest.py . +COPY requirements.txt setup.py setup.cfg pyproject.toml README.md LICENSE Makefile configtest.py . + + +# Install & update build tools +RUN pip3 install --upgrade \ + pip \ + setuptools \ + wheel # Install Python dependencies RUN pip3 install -r requirements.txt \ @@ -57,11 +64,10 @@ RUN pip3 install -r requirements.txt \ dict2xml \ "pypdf>=3.2.1" - COPY xml2rfc ./xml2rfc # Build xml2rfc & finalize RUN make install && \ pip3 uninstall -y decorator dict2xml pypdf && \ rm setup.py Makefile configtest.py requirements.txt && \ - rm -r xml2rfc build dist + rm -r xml2rfc build diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9787c3bd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index 5736a736..08b1bd83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,8 @@ appdirs>=1.4.4 configargparse>=1.2.3 google-i18n-address>=2.3.2 -html5lib>=1.0.1 intervaltree>=3.1.0 jinja2>=3.1.2 -markupsafe>=2.1.1 lxml>=4.9.0 pycountry>=22.3.5 pyyaml>=5.3.1 diff --git a/setup.cfg b/setup.cfg index c198c7c2..419394b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,51 @@ [metadata] +name = xml2rfc version = 3.17.0 +description = xml2rfc generates RFCs and IETF drafts from document source in XML according to the IETF xml2rfc v2 and v3 vocabularies. +long_description = file: README.md +long_description_content_type = text/markdown +keywords = ietf, rfc, id, internet-draft, xml, xml2rfc +author = Henrik Levkowetz +author_email = tools-discuss@ietf.org +maintainer = Kesara Rathnayake +maintainer_email = kesara@staff.ietf.org +url = /~https://github.com/ietf-tools/xml2rfc +download_url = /~https://github.com/ietf-tools/xml2rfc/releases +license = Revised BSD License +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + Operating System :: MacOS :: MacOS X + Operating System :: Microsoft :: Windows + Operating System :: POSIX :: Linux + Programming Language :: Python + Topic :: Text Processing + Topic :: Text Processing :: Markup :: XML + License :: OSI Approved :: BSD License + 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 + +[options] +packages = xml2rfc, xml2rfc/writers, xml2rfc/util, xml2rfc/uniscripts, xml2rfc/data, xml2rfc/templates +zip_safe = False +include_package_data = True +install_requires = file: requirements.txt + +[options.package_data] +* = + data/* + templates/* + +[options.entry_points] +console_scripts = + xml2rfc = xml2rfc.run:main + +[options.extras_require] +pdf = weasyprint>=53.0,!=57.0 [bdist_wheel] universal = 1 - diff --git a/setup.py b/setup.py index 13d34a30..b9b7f675 100644 --- a/setup.py +++ b/setup.py @@ -1,90 +1,5 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------- -# Copyright The IETF Trust 2011-2022, All Rights Reserved -# ------------------------------------------------------- - -import os -from codecs import open from setuptools import setup -import sys -# This workaround is necessary to make setup.py upload work with non-ascii -# arguments to setup(). -try: - reload(sys).setdefaultencoding("UTF-8") -except NameError: - pass - -description = "Xml2rfc generates RFCs and IETF drafts from document source in XML according to the IETF xml2rfc v2 and v3 vocabularies." - -here = os.path.abspath(os.path.dirname(__file__)) - -# Get the long description from the README file -with open(os.path.join(here, 'README.md'), encoding='utf-8') as file: - long_description = file.read() - -# Get the requirements from the local requirements.txt file -with open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as file: - requirements = file.read().splitlines() - setup( - # Package metadata name='xml2rfc', - author='Henrik Levkowetz', - author_email='tools-discuss@ietf.org', - maintainer = "Kesara Rathnayake", - maintainer_email = "kesara@staff.ietf.org", - url='/~https://github.com/ietf-tools/xml2rfc', - description=description, - long_description=long_description, - long_description_content_type="text/markdown", - download_url = "/~https://github.com/ietf-tools/xml2rfc/releases", - classifiers= [ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python', - 'Topic :: Text Processing', - 'Topic :: Text Processing :: Markup :: XML', - 'License :: OSI Approved :: BSD License', - - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. - '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', - ], - license="BSD-3-Clause", - - # Program data - #scripts=['scripts/xml2rfc'], - entry_points = { - 'console_scripts' : [ - 'xml2rfc = xml2rfc.run:main', - ], - }, - - packages=['xml2rfc', 'xml2rfc/writers', 'xml2rfc/util', 'xml2rfc/uniscripts', ], - package_data={'xml2rfc': [ - 'templates/*', - 'data/*', - ]}, - - install_requires = requirements, - tests_require = [ - 'decorator', - 'dict2xml', - 'pycairo', - 'pypdf', - 'tox', - 'weasyprint', - ], - - zip_safe = False, # We're reading templates from a package directory. ) diff --git a/tox.ini b/tox.ini index 55a14dd3..3ad68919 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ [tox] envlist = py{37,38,39,310,311}-{linux,macos,windows} +isolated_build = True [gh-actions] python = @@ -29,7 +30,6 @@ allowlist_externals = make deps = - -rrequirements.txt pyflakes decorator dict2xml