Skip to content

Commit

Permalink
Merge branch '27-switch-from-setup-py-to-pyproject-toml'
Browse files Browse the repository at this point in the history
Closes: #27
  • Loading branch information
c0r0n3r committed Jan 5, 2025
2 parents 4d1298a + a4b8903 commit 5fcfe30
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 167 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

*.pyc

*.egg-info

/.coverage

/*.egg-info
/.eggs
/.tox
/Pipfile
Expand Down
9 changes: 6 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stages:
- deploy

before_script:
- pip install -r dev-requirements.txt
- pip install tox .[tests]

pylint:
image: python:3.12-slim
Expand Down Expand Up @@ -63,15 +63,18 @@ coveralls:
stage: deploy
script:
- pip install coveralls
- pip install -r requirements.txt
- pip install .
- pip install .[tests]
- coverage run -m unittest -v -f
- coveralls
only:
refs:
- master

obs:
image: coroner/python_obs
image:
name: coroner/python_obs
pull_policy: always
stage: deploy
variables:
GIT_SUBMODULE_STRATEGY: recursive
Expand Down
13 changes: 9 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[BASIC]
[MAIN]

good-names = e,i
jobs=0

[MASTER]

load-plugins = pylint.extensions.no_self_use

[FORMAT]

max-line-length = 120
max-line-length=120

[MESSAGES CONTROL]

disable = missing-docstring,too-few-public-methods,too-many-function-args
disable=
missing-docstring,
too-few-public-methods,
too-many-function-args,
6 changes: 4 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ build:

python:
install:
- requirements: docs-requirements.txt
- requirements: requirements.txt
- method: pip
path: .
extra_requirements:
- docs
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ hosted at Bitbucket, self-hosted, or etc.)
3. `cd theproject`
4. [Create and activate a virtual
environment](https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments).
5. Install the development requirements: `pip install -r dev-requirements.txt`.
5. Install the development requirements: `pip install .[tests]`.
6. Create a branch: `git checkout -b foo-the-bars 1.3`.

#### Making your Changes
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include *.rst
include requirements.txt
16 changes: 10 additions & 6 deletions cryptodatahub/__setup__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-

__title__ = 'CryptoDataHub'
import importlib.metadata

metadata = importlib.metadata.metadata('cryptodatahub')

__title__ = metadata['Name']
__technical_name__ = __title__.lower()
__version__ = '0.12.6'
__description__ = 'Repository of cryptography-related data'
__author__ = 'Szilárd Pfeiffer'
__author_email__ = '[email protected]'
__version__ = metadata['Version']
__description__ = metadata['Summary']
__author__ = metadata['Author']
__author_email__ = metadata['Author-email']
__url__ = 'https://gitlab.com/coroner/' + __technical_name__
__license__ = 'MPL-2.0'
__license__ = metadata['License']
3 changes: 2 additions & 1 deletion cryptodatahub/common/stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class CertificateTransparencyOperator(CryptoDataParamsBase):


class CertificateTransparencyLogDateTimeBase(CryptoDataParamsBase):
def _asdict_serializer(self, _, __, value):
@classmethod
def _asdict_serializer(cls, _, __, value):
if isinstance(value, datetime.datetime):
return value.strftime("%Y-%m-%dT%H:%M:%SZ")

Expand Down
6 changes: 4 additions & 2 deletions cryptodatahub/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ def get_init_attribute_names(cls):
if attribute.init
]

def _asdict_filter(self, attribute, value):
@staticmethod
def _asdict_filter(attribute, value):
if attribute.name.startswith('_'):
return False

Expand All @@ -365,7 +366,8 @@ def _asdict_filter(self, attribute, value):

return True

def _asdict_serializer(self, _, __, value):
@classmethod
def _asdict_serializer(cls, _, __, value):
if hasattr(value, '_asdict'):
return getattr(value, '_asdict')()
if isinstance(value, enum.Enum):
Expand Down
4 changes: 0 additions & 4 deletions dev-requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions docs-requirements.txt

This file was deleted.

110 changes: 110 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[build-system]
requires = ['setuptools', 'setuptools-scm']
build-backend = 'setuptools.build_meta'

[project]
name = 'CryptoDataHub'
version = '0.12.6'
description = 'Repository of cryptography-related data'
authors = [
{name = 'Szilárd Pfeiffer', email = '[email protected]'}
]
maintainers = [
{name = 'Szilárd Pfeiffer', email = '[email protected]'}
]
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Framework :: tox',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python',
'Topic :: Internet',
'Topic :: Security',
'Topic :: Security :: Cryptography',
'Topic :: Software Development :: Libraries :: Python Modules',
]

keywords=['ssl', 'tls', 'ssh', 'dns', 'dnssec']
readme = {file = 'README.rst', content-type = 'text/x-rst'}
license = {text = 'MPL-2.0'}

dependencies = [
'asn1crypto',
'attrs',
'python-dateutil',
'urllib3',
]

[project.optional-dependencies]
tests = [
'pyfakefs',
'beautifulsoup4',
]
docs = [
'sphinx',
'sphinx-sitemap',
]

[project.urls]
Homepage = 'https://gitlab.com/coroner/cryptodatahub'
Changelog = 'https://cryptodatahub.readthedocs.io/en/latest/changelog'
Documentation = 'https://cryptodatahub.readthedocs.io/en/latest/'
Issues = 'https://gitlab.com/coroner/cryptodatahub/-/issues'
Source = 'https://gitlab.com/coroner/cryptodatahub'

[tool.variables]
technical_name = 'cryptodatahub'

[tool.setuptools]
license-files = ['LICENSE.txt']

[tool.setuptools.packages.find]
exclude = ['updaters']

[tool.setuptools.package-data]
cryptodatahub = [
'*/*.json'
]

[tool.tox]
envlist = [
'pep8',
'pylint',
'pypy3',
'py39',
'py310',
'py311',
'py312',
'py313',
'pythonrc',
]

[tool.tox.env_run_base]
deps = ['coverage', '.[tests]']
commands = [
['coverage', 'erase'],
['coverage', 'run', '-m', 'unittest', 'discover', '-v'],
['coverage', 'report']
]

[tool.tox.env.pep8]
deps = ['flake8']
commands = [['flake8', 'cryptodatahub', 'docs', 'updaters', 'test']]

[tool.tox.env.pylint]
deps = ['pylint', '.[tests]']
commands = [['pylint', '--rcfile', '.pylintrc', 'cryptodatahub', 'docs', 'updaters', 'test']]
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

96 changes: 2 additions & 94 deletions setup.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,97 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import codecs
import os
import unittest
import setuptools

from setuptools import setup

from cryptodatahub import __setup__


this_directory = os.getenv('REQUIREMENTS_DIR', '')
with open(os.path.join(this_directory, 'requirements.txt')) as f:
install_requirements = f.read().splitlines()
this_directory = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(this_directory, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()


def test_discover():
test_loader = unittest.TestLoader()
test_suite = test_loader.discover('test', pattern='test_*.py')
return test_suite


setup(
name=__setup__.__title__,
version=__setup__.__version__,
description=__setup__.__description__,
long_description=long_description,
long_description_content_type='text/x-rst',
author=__setup__.__author__,
author_email=__setup__.__author_email__,
maintainer=__setup__.__author__,
maintainer_email=__setup__.__author_email__,
license=__setup__.__license__,
license_files=['LICENSE.txt', ],
project_urls={
'Homepage': __setup__.__url__,
'Changelog': 'https://' + __setup__.__technical_name__ + '.readthedocs.io/en/latest/changelog',
'Documentation': 'https://' + __setup__.__technical_name__ + '.readthedocs.io/en/latest/',
'Issues': __setup__.__url__ + '/-/issues',
'Source': __setup__.__url__,
},
keywords='ssl tls ssh dns',

install_requires=install_requirements,
extras_require={
"test": ["coverage", ],
"pep8": ["flake8", ],
"pylint": ["pylint", ],
},

packages=[
'cryptodatahub',
'cryptodatahub.common',
'cryptodatahub.dnsrec',
'cryptodatahub.ssh',
'cryptodatahub.tls',
],

package_data={
'cryptodatahub.common': ['*.json'],
'cryptodatahub.dnsrec': ['*.json'],
'cryptodatahub.ssh': ['*.json'],
'cryptodatahub.tls': ['*.json'],
},

test_suite='setup.test_discover',

classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Framework :: tox',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python',
'Topic :: Internet',
'Topic :: Security',
'Topic :: Security :: Cryptography',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)
setuptools.setup()
Loading

0 comments on commit 5fcfe30

Please sign in to comment.