Skip to content

Commit

Permalink
build: Migrate to setup.cfg (#979)
Browse files Browse the repository at this point in the history
* build: Migrate to setup.cfg

* chore: Clean up dependencies

* build: Use requirements.txt in setup.cfg

* ci: Use build package instead of setup.py

* build: Include data files
  • Loading branch information
kesara authored Apr 11, 2023
1 parent 5f90492 commit 2b112e2
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 99 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ include tests/valid/*
include tox.ini
include requirements.txt
include xml2rfc/data/*
include xml2rfc/templates/*
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions docker/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
47 changes: 46 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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

85 changes: 0 additions & 85 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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.
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

[tox]
envlist = py{37,38,39,310,311}-{linux,macos,windows}
isolated_build = True

[gh-actions]
python =
Expand All @@ -29,7 +30,6 @@ allowlist_externals =
make

deps =
-rrequirements.txt
pyflakes
decorator
dict2xml
Expand Down

0 comments on commit 2b112e2

Please sign in to comment.