Skip to content

Commit

Permalink
Started migration to pyproject.toml, working on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoRoos committed Sep 23, 2024
1 parent 904bc39 commit 8d00fbd
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 142 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
max-line-length = 88
ignore = F401, W503
# flake8 cannot be configured through pyproject.toml
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

12 changes: 0 additions & 12 deletions PKG-INFO

This file was deleted.

83 changes: 73 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,72 @@
[project]
name = "pyads"
description = "Python wrapper for TwinCAT ADS library"
authors = [
{ name = "Stefan Lehmann", email = "[email protected]" },
]
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Libraries",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
]
license = { text = "MIT" }
dynamic = ["version"]

[project.urls]
Repository = "https://github.com/MrLeeh/pyads"
Documentation = "https://pyads.readthedocs.io"

[build-system]
requires = ["setuptools >= 61.0", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["pyads", "pyads.testserver"]

[tool.setuptools.package-data]
pyads = [
"adslib.so",
"adslib/"
]

[tool.setuptools.dynamic]
version = {attr = "pyads.__version__"}

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37, py38, py39, py310
[testenv]
commands = discover
deps = discover
changedir = tests
whitelist_externals=*
passenv = TWINCAT3DIR
[pytest]
testpaths = tests
"""

[tool.black]
line-length = 88
target-version = ['py37', 'py38', 'py39', 'py310']
include = '\.pyi?$'
exclude = '''
target-version = ["py37", "py38", "py39", "py310"]
include = ".pyi?$"
exclude = """
(
/(
\.eggs
| \.git
| \.mypy_cache
| \.tox
| \.venv
.eggs
| .git
| .mypy_cache
| .tox
| .venv
| _build
| buck-out
| build
Expand All @@ -20,4 +76,11 @@ exclude = '''
)/
| pyads/__init__.py
)
'''
"""

[tool.pydocstyle]
ignore = ["D105", "D213", "D203", "D107"]

[tool.coverage.run]
include = ["pyads/*"]
omit = ["pyads/testserver/__main__.py"]
15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

85 changes: 0 additions & 85 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,24 @@
#! /usr/bin/env python
# -*-coding: utf-8 -*-
import io
import glob
import os
import re
import sys
import shutil
import subprocess
import functools
import operator
from setuptools import setup
from setuptools.command.test import test as TestCommand
from setuptools.command.install import install as _install
from distutils.command.build import build as _build
from distutils.command.clean import clean as _clean
from distutils.command.sdist import sdist as _sdist


def read(*names, **kwargs):
try:
with io.open(
os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8")
) as fp:
return fp.read()
except IOError:
return ''


def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


def platform_is_linux():
return sys.platform.startswith('linux') or \
sys.platform.startswith('darwin')


def get_files_rec(directory):
res = []
for (path, directory, filenames) in os.walk(directory):
files = [os.path.join(path, fn) for fn in filenames]
res.append((path, files))
return res


data_files = get_files_rec('adslib')


def create_binaries():
subprocess.call(['make', '-C', 'adslib'])

Expand Down Expand Up @@ -118,65 +84,14 @@ def run(self):
_install.run(self)


class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ['--cov-report', 'html', '--cov-report', 'term',
'--cov=pyads']

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)


cmdclass = {
'test': PyTest,
'build': build,
'clean': clean,
'sdist': sdist,
'install': install,
}


long_description = read('README.md')


setup(
name="pyads",
version=find_version('pyads', '__init__.py'),
description="Python wrapper for TwinCAT ADS library",
long_description=long_description,
long_description_content_type='text/markdown',
author="Stefan Lehmann",
author_email="[email protected]",
packages=["pyads", "pyads.testserver"],
package_data={'pyads': ['adslib.so']},
requires=[],
install_requires=[],
provides=['pyads'],
url='https://github.com/MrLeeh/pyads',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Software Development :: Libraries',
'Operating System :: Microsoft :: Windows',
'Operating System :: Microsoft :: Windows :: Windows 7',
'Operating System :: POSIX :: Linux',
],
cmdclass=cmdclass,
data_files=data_files,
tests_require=['pytest', 'pytest-cov'],
has_ext_modules=lambda: True,
)
17 changes: 0 additions & 17 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py37, py38, py39, py310

[testenv]
commands = discover
deps = discover
changedir = tests
whitelist_externals=*
passenv = TWINCAT3DIR

[pytest]
testpaths = tests

0 comments on commit 8d00fbd

Please sign in to comment.