Skip to content

Commit

Permalink
Merge pull request #24 from Ledger-Donjon/22-use-poetry-for-packaging
Browse files Browse the repository at this point in the history
Use and configure Poetry for packaging
  • Loading branch information
mmouchous-ledger authored Nov 27, 2024
2 parents f681e8a + cd49250 commit 848e41b
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 87 deletions.
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,60 @@ and randomly go through these zones, by controlling motion devices.

Laser Studio works on Python 3.9+.

It requires following packages to run:
It can be installed through PyPI with:

```shell
pip install laserstudio
```

Otherwise, you can clone and install the project with:

```shell
git clone https://github.com/Ledger-Donjon/laserstudio.git
pip install ./laserstudio
```

### Package depedencies

It depends following packages to run:

- [PyQt6]
- [pystages]
- [Pillow]
- [opencv-python]
- [pystages]
- [pyusb]
- [PyYAML]
- [shapely]
- [triangle]
- [requests]
- [numpy]
- [pypdm]
- [flask]
- [flask-restx]
- [hidapi]

After cloning the repository, you can install those by using the `requirements.txt` file.
Additionally, on Linux systems, the [pyNIT] package can be installed
to support NIT cameras.

```shell
git clone https://github.com/Ledger-Donjon/laserstudio.git
python3 -m pip install --upgrade -r requirements.txt
pip install git+https://github.com/Ledger-Donjon/pynit.git
```

On Mac with Apple Silicon chips, the [triangle] package fails to install with `pip`.
Workaround is to install it from source before installing `laserstudio`:

```shell
pip install git+https://github.com/drufat/triangle.git
```

## Usage

To run Laser Studio, tune your configuration file `config.yaml` with appropriate
information about your hardware instruments, then a terminal and run Laser Studio as a module.
information about your hardware instruments, then a terminal and run Laser Studio in the
directory containing that `config.yaml`.

```shell
python3 -m laserstudio
laserstudio
```

# Documentation
Expand All @@ -52,4 +82,11 @@ LaserStudio is released under GNU Lesser General Public License version 3 (LGPLv
[pystages]: https://github.com/Ledger-Donjon/pystages
[shapely]: https://shapely.readthedocs.io/en/stable/manual.html
[triangle]: https://rufat.be/triangle/
[pyusb]: https://pypi.org/project/pyusb/
[requests]: https://pypi.org/project/requests/
[numpy]: https://pypi.org/project/numpy
[pypdm]: https://pypi.org/project/pypdm
[flask]: https://pypi.org/project/flask
[flask-restx]: https://pypi.org/project/flask-restx
[hidapi]: https://pipy.org/project/hidapi
[Read the Docs]: https://laserstudio.readthedocs.io/
2 changes: 1 addition & 1 deletion laserstudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
Hardware evaluation tool developed by the Donjon
"""

__version__ = "1.0.0dev3"
__version__ = "0.0.0"
__author__ = "Olivier Hériveaux, Michaël Mouchous"
9 changes: 7 additions & 2 deletions laserstudio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from .utils.util import resource_path
from .utils.colors import LedgerColors

if __name__ == "__main__":

def main():
app = QApplication(sys.argv)

parser = argparse.ArgumentParser(prog="laserstudio")
Expand Down Expand Up @@ -75,4 +76,8 @@
win = LaserStudio(yaml_config)
win.setWindowTitle(app.applicationDisplayName())
win.show()
sys.exit(app.exec())
return app.exec()


if __name__ == "__main__":
sys.exit(main())
8 changes: 7 additions & 1 deletion laserstudio/instruments/camera_nit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ class CameraNITInstrument(CameraInstrument):

def __init__(self, config: dict):
super().__init__(config)
from pynit import PyNIT # Lazy load the module
try:
from pynit import PyNIT # Lazy load the module
except ImportError:
raise ImportError(
"""The pynit module is required to use the NIT.
Please install it using 'pip install git+https://github.com/Ledger-Donjon/pynit.git'."""
)

self.pynit = PyNIT(
nuc_filepath=config.get(
Expand Down
5 changes: 5 additions & 0 deletions laserstudio/instruments/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .pdm import PDMInstrument
from .probe import ProbeInstrument
from typing import Optional, cast, Any
import sys
import logging


Expand Down Expand Up @@ -50,6 +51,10 @@ def __init__(self, config: dict):
camera_config
)
elif device_type == "NIT":
if sys.platform != "linux" and sys.platform != "win32":
raise Exception(
"The NIT camera is not supported on other platforms than Linux or Windows."
)
self.camera: Optional[CameraInstrument] = CameraNITInstrument(
camera_config
)
Expand Down
6 changes: 5 additions & 1 deletion laserstudio/instruments/list_serials.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ def get_serial_device(config: Union[str, dict]):
raise ValueError("Invalid dev value")


if __name__ == "__main__":
def list_devices():
for p in serial.tools.list_ports.comports():
print(p)
print(f" | sn: {p.serial_number}\n | info: {p.usb_info()}\n | path: {p.device}")


if __name__ == "__main__":
list_devices()
73 changes: 73 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[tool.poetry]
name = "laserstudio"
version = "0.0.0"
description = "Python3 software for hardware evaluation"
authors = [
"Olivier Hériveaux <[email protected]>",
"Michaël Mouchous <[email protected]>",
]
license = "LGPL-3.0-or-later"
readme = "README.md"
documentation = "https://laserstudio.readthedocs.org/"
classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 4 - Beta",
# Indicate who your project is intended for
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
]
[tool.poetry.scripts]
laserstudio = 'laserstudio.__main__:main'
laserstudio_listdevices = 'laserstudio.instruments.list_serials:list_devices'

[tool.poetry.dependencies]
python = ">=3.9 <3.11"
pyqt6 = ">=6.0"
pystages = "1.2"
pillow = "10.4.0"
opencv-python = "4.9.0.80"
pyusb = "1.2.1"
pyyaml = "6.0.1"
shapely = "^2.0.5"
triangle = "20230923"
requests = "^2.32.3"
numpy = "1.26.4"
pypdm = "1.1"
flask = "3.0.3"
flask-restx = "1.3.0"
hidapi = "^0.14.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.0.0"

[tool.poetry.group.nit]
optional = true

[tool.poetry.group.nit.dependencies]
pynit = { git = "https://github.com/Ledger-Donjon/pynit.git" }

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = "*"
sphinx-rtd-theme = "*"
myst_parser = "*"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"

[tool.poetry-dynamic-versioning.substitution]
files = ["laserstudio/__init__.py"]

[tool.poetry-dynamic-versioning.files."laserstudio/__init__.py"]
persistent-substitution = true

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"
75 changes: 0 additions & 75 deletions setup.py

This file was deleted.

0 comments on commit 848e41b

Please sign in to comment.