Skip to content

Commit

Permalink
Uses pyproject instead of setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrn committed Jul 26, 2022
1 parent ee03358 commit 627489d
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 90 deletions.
7 changes: 0 additions & 7 deletions .black

This file was deleted.

54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[tool.black]
include = '\.pyi?$'
exclude = '''
/(
\.git
)/
'''

[build-system]
requires = ["setuptools>=40.8.0"]
build-backend = "setuptools.build_meta"

[project]
name="pydrs"
classifiers=[
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Operating System :: OS Independent"
]
description=""
dependencies = [
"matplotlib",
"numpy",
"pyserial==3.5"
]
license = {text = "MIT License"}
requires-python=">=3.6"
dynamic=["version", "readme"]

[tool.setuptools]
zip-safe=false
include-package-data=true

[tool.setuptools.dynamic]
version = {attr = "pydrs.__version__"}
readme = {file = ["README.md"]}

[tool.setuptools.packages.find]
where = ["src"]

[project.optional-dependencies]
dev = [
"bandit==1.7.0",
"black==21.10b0",
"flake8==4.0.1",
"flake8-bandit==2.1.2",
"flake8-bugbear==21.9.2",
"flake8-implicit-str-concat==0.2.0",
"mypy==0.812",
"mypy-extensions==0.4.3",
"pyflakes==2.3.1",
"types-setuptools"
]
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements_dev.txt

This file was deleted.

58 changes: 2 additions & 56 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
#!/usr/bin/env python3
import pkg_resources
from setuptools import find_packages, setup
from setuptools import setup

from src.pydrs import __author__, __version__


def get_abs_path(relative):
return pkg_resources.resource_filename(__name__, relative)


def get_long_description() -> str:
desc = ""
with open(get_abs_path("README.md"), "r") as _f:
desc += _f.read().strip()

desc += "\n\n"

with open(get_abs_path("CHANGES.md"), "r") as _f:
desc += _f.read().strip()

return desc


long_description = get_long_description()


with open(get_abs_path("requirements.txt"), "r") as _f:
_requirements = _f.read().strip().split("\n")

setup(
author=__author__,
classifiers=[
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Operating System :: OS Independent",
],
description="",
download_url="https://github.com/lnls-sirius/pydrs",
include_package_data=True,
install_requires=_requirements,
license="MIT License",
long_description=long_description,
long_description_content_type="text/markdown",
name="pydrs",
url="https://github.com/lnls-sirius/pydrs",
version=__version__,
packages=find_packages(
where="src",
include=["pydrs*"],
),
package_dir={"": "src"},
python_requires=">=3.6",
test_suite="tests",
zip_safe=False,
)
setup()
Empty file removed src/__init__.py
Empty file.
6 changes: 2 additions & 4 deletions src/pydrs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from .info import __author__, __date__, __version__
from .pydrs import SerialDRS

__all__ = ["__author__", "__version__", "__date__", "SerialDRS"]
__version__ = "1.2.1"
__date__ = "25/07/2022"
2 changes: 1 addition & 1 deletion src/pydrs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def save_param_bank(self, type_memory: int = 2) -> bytes:
+ index_to_hex(list_func.index("save_param_bank"))
+ hex_type
)

# User defined timeout is temporarily changed to a "safe" value to prevent lockups
old_timeout = self.timeout
self.timeout = 10
Expand Down
5 changes: 0 additions & 5 deletions src/pydrs/info.py

This file was deleted.

4 changes: 1 addition & 3 deletions src/pydrs/pydrs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import re
import socket
import struct
Expand Down Expand Up @@ -140,7 +138,7 @@ def timeout(self) -> float:

@timeout.setter
def timeout(self, new_timeout: float):
self._serial_timeout = new_timeout*1000
self._serial_timeout = new_timeout * 1000
self.socket.settimeout(new_timeout)

def is_open(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/pydrs/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SerialInvalidCmd(SerialError):
def validate(func):
def wrapper(*args, **kwargs):
reply = func(*args, **kwargs)
if len(reply) == 1 and reply[0] == ETH_ANSWER_NOQUEUE:
if len(reply) == 0 or (len(reply) == 1 and reply[0] == ETH_ANSWER_NOQUEUE):
args[0]._reset_input_buffer()
raise SerialErrPckgLen(
"Received empty response, check if the controller is on and connected"
Expand Down

0 comments on commit 627489d

Please sign in to comment.