Skip to content

Commit

Permalink
Modernize build and test infra
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
  • Loading branch information
tiran committed Jul 13, 2022
1 parent 51f5bfe commit 6af717b
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 210 deletions.
4 changes: 4 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 Down
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: 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
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 = [email protected]
maintainer = Ilya Etingof
maintainer_email = [email protected]
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 <[email protected]>
# 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 <[email protected]>',
'author': 'Ilya Etingof',
'author_email': '[email protected]',
'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())
83 changes: 19 additions & 64 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,69 +1,21 @@
[tox]
minversion = 3.4.0
minversion = 3.5.0
envlist =
{py27, py35, py36, py37, py38, py39, py310, py311}-{unittest},
py27, py36, py37, py38, py39, py310, py311, pypy27, pypy37, pypy38, pypy39
cover, bandit, build
isolated_build = true
skip_missing_interpreters = true

[testenv]
usedevelop = True
setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
deps = pip >= 19.3.1
install_command =
pip install {opts} {packages}

[testenv:unittest]
deps =
{[testenv]deps}
discover
-r{toxinidir}/requirements.txt
commands =
discover -s examples/pyasn1_modules-example-switch/tests -s tests

[testenv:py27-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py35-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py36-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py37-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py38-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py39-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py310-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}

[testenv:py311-unittest]
deps = {[testenv:unittest]deps}
commands = {[testenv:unittest]commands}
{envpython} -m unittest discover -s tests
deps =
pyasn1>=0.4.6,<0.6.0

[testenv:cover]
basepython = python3
setenv =
{[testenv]setenv}
PYTHON=coverage run --parallel-mode
deps =
{[testenv:unittest]deps}
coverage
discover
commands = coverage erase
coverage run --source pyasn1_modules -m unittest discover {posargs}
coverage report --fail-under 93
Expand All @@ -73,22 +25,25 @@ skip_install = true
deps =
bandit
commands =
bandit -r pyasn1_modules -c .bandit.yml
bandit -r pyasn1 -c .bandit.yml

[testenv:build]
skip_install = true
deps =
wheel
setuptools
build
commands =
python setup.py -q sdist bdist_wheel
{envpython} -m build

[gh-actions]
python =
2.7: py27-unittest
3.6: py36-unittest
3.7: py37-unittest
3.8: py38-unittest
3.9: py39-unittest, bandit
3.10: py310-unittest, cover, build
3.11: py311-unittest
2.7: py27
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310, cover, build, bandit
3.11: py311
pypy-2.7: pypy27
pypy-3.7: pypy37
pypy-3.8: pypy38
pypy-3.9: pypy39

0 comments on commit 6af717b

Please sign in to comment.