Skip to content

Commit 848e41b

Browse files
Merge pull request #24 from Ledger-Donjon/22-use-poetry-for-packaging
Use and configure Poetry for packaging
2 parents f681e8a + cd49250 commit 848e41b

File tree

8 files changed

+142
-87
lines changed

8 files changed

+142
-87
lines changed

README.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,60 @@ and randomly go through these zones, by controlling motion devices.
1111

1212
Laser Studio works on Python 3.9+.
1313

14-
It requires following packages to run:
14+
It can be installed through PyPI with:
15+
16+
```shell
17+
pip install laserstudio
18+
```
19+
20+
Otherwise, you can clone and install the project with:
21+
22+
```shell
23+
git clone https://github.com/Ledger-Donjon/laserstudio.git
24+
pip install ./laserstudio
25+
```
26+
27+
### Package depedencies
28+
29+
It depends following packages to run:
1530

1631
- [PyQt6]
32+
- [pystages]
1733
- [Pillow]
1834
- [opencv-python]
19-
- [pystages]
35+
- [pyusb]
2036
- [PyYAML]
2137
- [shapely]
2238
- [triangle]
39+
- [requests]
40+
- [numpy]
41+
- [pypdm]
42+
- [flask]
43+
- [flask-restx]
44+
- [hidapi]
2345

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

2649
```shell
27-
git clone https://github.com/Ledger-Donjon/laserstudio.git
28-
python3 -m pip install --upgrade -r requirements.txt
50+
pip install git+https://github.com/Ledger-Donjon/pynit.git
51+
```
52+
53+
On Mac with Apple Silicon chips, the [triangle] package fails to install with `pip`.
54+
Workaround is to install it from source before installing `laserstudio`:
55+
56+
```shell
57+
pip install git+https://github.com/drufat/triangle.git
2958
```
3059

3160
## Usage
3261

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

3666
```shell
37-
python3 -m laserstudio
67+
laserstudio
3868
```
3969

4070
# Documentation
@@ -52,4 +82,11 @@ LaserStudio is released under GNU Lesser General Public License version 3 (LGPLv
5282
[pystages]: https://github.com/Ledger-Donjon/pystages
5383
[shapely]: https://shapely.readthedocs.io/en/stable/manual.html
5484
[triangle]: https://rufat.be/triangle/
85+
[pyusb]: https://pypi.org/project/pyusb/
86+
[requests]: https://pypi.org/project/requests/
87+
[numpy]: https://pypi.org/project/numpy
88+
[pypdm]: https://pypi.org/project/pypdm
89+
[flask]: https://pypi.org/project/flask
90+
[flask-restx]: https://pypi.org/project/flask-restx
91+
[hidapi]: https://pipy.org/project/hidapi
5592
[Read the Docs]: https://laserstudio.readthedocs.io/

laserstudio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
Hardware evaluation tool developed by the Donjon
55
"""
66

7-
__version__ = "1.0.0dev3"
7+
__version__ = "0.0.0"
88
__author__ = "Olivier Hériveaux, Michaël Mouchous"

laserstudio/__main__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from .utils.util import resource_path
1212
from .utils.colors import LedgerColors
1313

14-
if __name__ == "__main__":
14+
15+
def main():
1516
app = QApplication(sys.argv)
1617

1718
parser = argparse.ArgumentParser(prog="laserstudio")
@@ -75,4 +76,8 @@
7576
win = LaserStudio(yaml_config)
7677
win.setWindowTitle(app.applicationDisplayName())
7778
win.show()
78-
sys.exit(app.exec())
79+
return app.exec()
80+
81+
82+
if __name__ == "__main__":
83+
sys.exit(main())

laserstudio/instruments/camera_nit.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ class CameraNITInstrument(CameraInstrument):
77

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

1218
self.pynit = PyNIT(
1319
nuc_filepath=config.get(

laserstudio/instruments/instruments.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .pdm import PDMInstrument
1010
from .probe import ProbeInstrument
1111
from typing import Optional, cast, Any
12+
import sys
1213
import logging
1314

1415

@@ -50,6 +51,10 @@ def __init__(self, config: dict):
5051
camera_config
5152
)
5253
elif device_type == "NIT":
54+
if sys.platform != "linux" and sys.platform != "win32":
55+
raise Exception(
56+
"The NIT camera is not supported on other platforms than Linux or Windows."
57+
)
5358
self.camera: Optional[CameraInstrument] = CameraNITInstrument(
5459
camera_config
5560
)

laserstudio/instruments/list_serials.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def get_serial_device(config: Union[str, dict]):
7373
raise ValueError("Invalid dev value")
7474

7575

76-
if __name__ == "__main__":
76+
def list_devices():
7777
for p in serial.tools.list_ports.comports():
7878
print(p)
7979
print(f" | sn: {p.serial_number}\n | info: {p.usb_info()}\n | path: {p.device}")
80+
81+
82+
if __name__ == "__main__":
83+
list_devices()

pyproject.toml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[tool.poetry]
2+
name = "laserstudio"
3+
version = "0.0.0"
4+
description = "Python3 software for hardware evaluation"
5+
authors = [
6+
"Olivier Hériveaux <olivier.heriveaux@ledger.fr>",
7+
"Michaël Mouchous <michael.mouchous@ledger.fr>",
8+
]
9+
license = "LGPL-3.0-or-later"
10+
readme = "README.md"
11+
documentation = "https://laserstudio.readthedocs.org/"
12+
classifiers = [
13+
# How mature is this project? Common values are
14+
# 3 - Alpha
15+
# 4 - Beta
16+
# 5 - Production/Stable
17+
"Development Status :: 4 - Beta",
18+
# Indicate who your project is intended for
19+
"Intended Audience :: Developers",
20+
"Topic :: Software Development :: Build Tools",
21+
]
22+
[tool.poetry.scripts]
23+
laserstudio = 'laserstudio.__main__:main'
24+
laserstudio_listdevices = 'laserstudio.instruments.list_serials:list_devices'
25+
26+
[tool.poetry.dependencies]
27+
python = ">=3.9 <3.11"
28+
pyqt6 = ">=6.0"
29+
pystages = "1.2"
30+
pillow = "10.4.0"
31+
opencv-python = "4.9.0.80"
32+
pyusb = "1.2.1"
33+
pyyaml = "6.0.1"
34+
shapely = "^2.0.5"
35+
triangle = "20230923"
36+
requests = "^2.32.3"
37+
numpy = "1.26.4"
38+
pypdm = "1.1"
39+
flask = "3.0.3"
40+
flask-restx = "1.3.0"
41+
hidapi = "^0.14.0"
42+
43+
[tool.poetry.group.dev.dependencies]
44+
pytest = "^7.0.0"
45+
46+
[tool.poetry.group.nit]
47+
optional = true
48+
49+
[tool.poetry.group.nit.dependencies]
50+
pynit = { git = "https://github.com/Ledger-Donjon/pynit.git" }
51+
52+
[tool.poetry.group.docs]
53+
optional = true
54+
55+
[tool.poetry.group.docs.dependencies]
56+
sphinx = "*"
57+
sphinx-rtd-theme = "*"
58+
myst_parser = "*"
59+
60+
[tool.poetry-dynamic-versioning]
61+
enable = true
62+
vcs = "git"
63+
style = "semver"
64+
65+
[tool.poetry-dynamic-versioning.substitution]
66+
files = ["laserstudio/__init__.py"]
67+
68+
[tool.poetry-dynamic-versioning.files."laserstudio/__init__.py"]
69+
persistent-substitution = true
70+
71+
[build-system]
72+
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
73+
build-backend = "poetry_dynamic_versioning.backend"

setup.py

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)