Skip to content

Commit

Permalink
Modernize build and test infra (#2)
Browse files Browse the repository at this point in the history
- move ``setup.py`` infos to ``setup.cfg``
- use ``build`` to build sdist and wheel
- simplify ``tox.ini``
- drop Python 3.5
- use ``unittest discover`` to discover tests
- https://github.com/etingof -> https://github.com/pyasn1
- drop TravisCI
- test sdist, add dev1 version suffix
- change maintainer contact, validate metadata
  • Loading branch information
tiran committed Jul 14, 2022
1 parent 51f5bfe commit 7d8e520
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 214 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
- "3.9"
- "3.10"
- "3.11-dev"
- "pypy-2.7"
- "pypy-3.7"
- "pypy-3.8"
- "pypy-3.9"
steps:
- uses: "actions/checkout@v3"
- uses: "actions/setup-python@v4"
Expand All @@ -40,3 +44,34 @@ jobs:
run: python -m pip install --upgrade tox tox-gh-actions
- name: "Run tox for ${{ matrix.python-version }}"
run: "python -m tox"

sdist:
name: "Build sdist and wheel"
runs-on: "ubuntu-latest"
needs: tests
steps:
- uses: "actions/checkout@v3"
- uses: "actions/setup-python@v4"
with:
python-version: "3.10"
cache: "pip"
- name: "Update pip"
run: python -m pip install --upgrade pip setuptools wheel
- name: "Install 'build'"
run: python -m pip install --upgrade build
- name: "Run 'build'"
run: "python -m build"
- name: "Upload sdist artifact"
uses: actions/upload-artifact@v2
with:
name: sdist
path: |
dist/pyasn1*.tar.gz
if-no-files-found: error
- name: "Upload wheel artifact"
uses: actions/upload-artifact@v2
with:
name: wheel
path: |
dist/pyasn1*.whl
if-no-files-found: error
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.pyc
__pycache__
.tox
.coverage

# vim swapfiles
*.sw?
Expand Down
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

10 changes: 7 additions & 3 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

Revision 0.3.0, released XX-03-2020
Revision 0.3.0, released XX-08-2028
-----------------------------------

- Added support for Python 3.8.
- Added support for Python 3.8, 3.9, 3.10, 3.11
- Removed support for EOL Pythons 2.4, 2.5, 2.6, 3.2, 3.3, 3.4, 3.5
- Added support for PyPy 3.7, 3.8, 3.9
- Modernized packaging and testing. pyasn1-modules now uses ``setup.cfg``,
``pyproject.toml``, [build](https://pypi.org/project/build/), and
GitHub Actions.
- Added tox runner with a handful of basic jobs
- Add RFC3125 providing Electronic Signature Policies
- Add RFC5126 providing CMS Advanced Electronic Signatures (CAdES)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ ASN.1 modules for Python
------------------------
[![PyPI](https://img.shields.io/pypi/v/pyasn1-modules.svg?maxAge=2592000)](https://pypi.org/project/pyasn1-modules)
[![Python Versions](https://img.shields.io/pypi/pyversions/pyasn1-modules.svg)](https://pypi.org/project/pyasn1-modules/)
[![Build status](https://travis-ci.org/etingof/pyasn1-modules.svg?branch=master)](https://travis-ci.org/etingof/pyasn1-modules)
[![Coverage Status](https://img.shields.io/codecov/c/github/etingof/pyasn1-modules.svg)](https://codecov.io/github/etingof/pyasn1-modules/)
[![GitHub license](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/etingof/pyasn1-modules/master/LICENSE.txt)
[![Build status](https://github.com/pyasn1/pyasn1-modules/actions/workflows/main.yml/badge.svg)](https://github.com/pyasn1/pyasn1-modules/actions/workflows/main.yml)
[![Coverage Status](https://img.shields.io/codecov/c/github/pyasn1/pyasn1-modules.svg)](https://codecov.io/github/pyasn1/pyasn1-modules)
[![GitHub license](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/pyasn1/pyasn1-modules/master/LICENSE.txt)

The `pyasn1-modules` package contains a collection of
[ASN.1](https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.208-198811-W!!PDF-E&type=items)
data structures expressed as Python classes based on [pyasn1](https://github.com/etingof/pyasn1)
data structures expressed as Python classes based on [pyasn1](https://github.com/pyasn1/pyasn1)
data model.

If ASN.1 module you need is not present in this collection, try using
Expand All @@ -20,7 +20,7 @@ Feedback
--------

If something does not work as expected,
[open an issue](https://github.com/etingof/pyasn1-modules/issues) at GitHub
[open an issue](https://github.com/pyasn1/pyasn1-modules/issues) at GitHub
or post your question [on Stack Overflow](https://stackoverflow.com/questions/ask)

New modules contributions are welcome via GitHub pull requests.
Expand Down
2 changes: 1 addition & 1 deletion pyasn1_modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# http://www.python.org/dev/peps/pep-0396/
__version__ = '0.3.0'
__version__ = '0.3.0.dev1'
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build-system]
requires = [
"setuptools"
]
build-backend = "setuptools.build_meta"
55 changes: 52 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
[bdist_wheel]
universal = 1

[metadata]
name = pyasn1_modules
version = attr: pyasn1_modules.__version__
description = A collection of ASN.1-based protocols modules
long_description = file: README.md
long_description_content_type = text/markdown
license = BSD
license_file = LICENSE.txt
url = https://github.com/pyasn1/pyasn1-modules
author = Ilya Etingof
author_email = etingof@gmail.com
maintainer = pyasn1 maintenance organization
maintainer_email = Christian Heimes <christian@python.org>
project_urls =
Source=https://github.com/pyasn1/pyasn1-modules
Issues=https://github.com/pyasn1/pyasn1-modules/issues
Changelog=https://github.com/pyasn1/pyasn1-modules/blob/master/CHANGES.txt
platforms = any
classifiers =
Development Status :: 5 - Production/Stable
Environment :: Console
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: Information Technology
Intended Audience :: System Administrators
Intended Audience :: Telecommunications Industry
License :: OSI Approved :: BSD License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
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
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Communications
Topic :: Software Development :: Libraries :: Python Modules

[options]
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
zip_safe = True
setup_requires = setuptools
install_requires =
pyasn1>=0.4.6,<0.6.0
packages =
pyasn1_modules

[bdist_wheel]
universal = 1
119 changes: 2 additions & 117 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,121 +5,6 @@
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
import unittest
from setuptools import setup


doclines = """A collection of ASN.1-based protocols modules.
A collection of ASN.1 modules expressed in form of pyasn1 classes.
Includes protocols PDUs definition (SNMP, LDAP etc.) and various
data structures (X.509, PKCS etc.).
"""

doclines = [x.strip() for x in doclines.split('\n') if x]


classifiers = """\
Development Status :: 5 - Production/Stable
Environment :: Console
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: Information Technology
Intended Audience :: System Administrators
Intended Audience :: Telecommunications Industry
License :: OSI Approved :: BSD License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
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
Programming Language :: Python :: 3.11
Topic :: Communications
Topic :: System :: Monitoring
Topic :: System :: Networking :: Monitoring
Topic :: Software Development :: Libraries :: Python Modules
"""


def howto_install_setuptools():
print("""
Error: You need setuptools Python package!
It's very easy to install it, just type (as root on Linux):
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
python ez_setup.py
Then you could make eggs from this package.
""")


if sys.version_info[:2] < (2, 7):
print("ERROR: this package requires Python 2.7 or later!")
sys.exit(1)

try:
from setuptools import setup, Command

params = {
'zip_safe': True,
'install_requires': ['pyasn1>=0.4.6,<0.6.0']
}

except ImportError:
for arg in sys.argv:
if 'egg' in arg:
howto_install_setuptools()
sys.exit(1)

from distutils.core import setup, Command

params = {
'requires': ['pyasn1(>=0.4.6,<0.6.0)']
}

params.update(
{'name': 'pyasn1-modules',
'version': open('pyasn1_modules/__init__.py').read().split('\'')[1],
'description': doclines[0],
'long_description': ' '.join(doclines[1:]),
'maintainer': 'Ilya Etingof <etingof@gmail.com>',
'author': 'Ilya Etingof',
'author_email': 'etingof@gmail.com',
'url': 'https://github.com/etingof/pyasn1-modules',
'platforms': ['any'],
'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
'classifiers': [x for x in classifiers.split('\n') if x],
'license': 'BSD-2-Clause',
'packages': ['pyasn1_modules'],
'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*'})


class PyTest(Command):
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
suite = unittest.TestLoader().loadTestsFromNames(
['tests.__main__.suite']
)

unittest.TextTestRunner(verbosity=2).run(suite)

params['cmdclass'] = {
'test': PyTest,
'tests': PyTest
}

setup(**params)
setup()
18 changes: 18 additions & 0 deletions tests/test_missing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# This file is part of pyasn1-modules software.
#
import sys
import unittest

# modules without tests
from pyasn1_modules import (
rfc1155, rfc1157, rfc1901, rfc3412, rfc3414
)

suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])

if __name__ == '__main__':
import sys

result = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(not result.wasSuccessful())

0 comments on commit 7d8e520

Please sign in to comment.