spyrrow 0.2.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spyrrow might be problematic. Click here for more details.

@@ -0,0 +1,18 @@
1
+ # https://docs.readthedocs.io/en/stable/config-file/v2.html#supported-settings
2
+
3
+ version: 2
4
+
5
+ sphinx:
6
+ builder: html
7
+ configuration: docs/conf.py
8
+
9
+ build:
10
+ os: "ubuntu-22.04"
11
+ tools:
12
+ python: "3.11"
13
+ rust: "1.86"
14
+
15
+ python:
16
+ install:
17
+ - method: pip
18
+ path: .
@@ -256,7 +256,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
256
256
  [[package]]
257
257
  name = "jagua-rs"
258
258
  version = "0.5.1"
259
- source = "git+https://github.com/JeroenGar/jagua-rs.git?rev=06152d8654d8b9b0652c14ccd1f5d693b703b5de#06152d8654d8b9b0652c14ccd1f5d693b703b5de"
259
+ source = "git+https://github.com/JeroenGar/jagua-rs.git?rev=3d36f849653e3e2273be9f6a7fd24da51ded585d#3d36f849653e3e2273be9f6a7fd24da51ded585d"
260
260
  dependencies = [
261
261
  "anyhow",
262
262
  "document-features",
@@ -680,7 +680,7 @@ dependencies = [
680
680
  [[package]]
681
681
  name = "sparrow"
682
682
  version = "0.1.0"
683
- source = "git+https://github.com/JeroenGar/sparrow.git?rev=cb456fe41443c6c3153141aa8e945fedba78e60b#cb456fe41443c6c3153141aa8e945fedba78e60b"
683
+ source = "git+https://github.com/JeroenGar/sparrow.git?rev=3adafa222a260dc3f83a15a899541d2c51fae5d6#3adafa222a260dc3f83a15a899541d2c51fae5d6"
684
684
  dependencies = [
685
685
  "anyhow",
686
686
  "clap",
@@ -707,11 +707,13 @@ dependencies = [
707
707
 
708
708
  [[package]]
709
709
  name = "spyrrow"
710
- version = "0.2.0"
710
+ version = "0.4.0"
711
711
  dependencies = [
712
712
  "jagua-rs",
713
713
  "pyo3",
714
714
  "rand",
715
+ "serde",
716
+ "serde_json",
715
717
  "sparrow",
716
718
  ]
717
719
 
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  name = "spyrrow"
3
- version = "0.2.0"
4
- edition = "2021"
3
+ version = "0.4.0"
4
+ edition = "2024"
5
5
  license = "MIT"
6
6
 
7
7
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -10,7 +10,9 @@ name = "spyrrow"
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- jagua-rs = { git = "https://github.com/JeroenGar/jagua-rs.git", rev="06152d8654d8b9b0652c14ccd1f5d693b703b5de", features = ["spp"], default-features = false}
13
+ jagua-rs = { git = "https://github.com/JeroenGar/jagua-rs.git", rev="3d36f849653e3e2273be9f6a7fd24da51ded585d", features = ["spp"], default-features = false}
14
14
  pyo3 = "0.24.0"
15
15
  rand = { version = "0.9.0", features = ["small_rng"] }
16
- sparrow = { git = "https://github.com/JeroenGar/sparrow.git",rev="cb456fe41443c6c3153141aa8e945fedba78e60b",features = ["only_final_svg"], default-features = false}
16
+ serde = {version = "1.0.219", features = ["derive"]}
17
+ serde_json = "1.0.140"
18
+ sparrow = { git = "https://github.com/JeroenGar/sparrow.git",rev="3adafa222a260dc3f83a15a899541d2c51fae5d6",features = ["only_final_svg"], default-features = false}
spyrrow-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: spyrrow
3
+ Version: 0.4.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ License-File: LICENSE.txt
8
+ Author-email: Paul Durand-Lupinski <paul.durand-lupinski@reeverse-systems.com>
9
+ License: MIT
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
+ Project-URL: documentation, https://spyrrow.readthedocs.io/
13
+ Project-URL: source, https://github.com/PaulDL-RS/spyrrow
14
+
15
+ # Spyrrow
16
+
17
+ `spyrrow` is a Python wrapper on the Rust project [`sparrow`](https://github.com/JeroenGar/sparrow).
18
+ It enables to solve 2D [Strip packing problems](https://en.wikipedia.org/wiki/Strip_packing_problem).
19
+
20
+ The documentation is hosted [here](https://spyrrow.readthedocs.io/).
21
+
22
+ ## Installation
23
+
24
+ Spyrrow is hosted on [PyPI](https://pypi.org/project/spyrrow/).
25
+
26
+ You can install with the package manager of your choice, using the PyPI package index.
27
+
28
+ For example, with `pip`, the default Python package:
29
+ ```bash
30
+ pip install spyrrow
31
+ ```
32
+
33
+ ## Examples
34
+ ```python
35
+ import spyrrow
36
+
37
+ rectangle1 = spyrrow.Item(
38
+ 0, [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)], demand=4, allowed_orientations=[0]
39
+ )
40
+ triangle1 = spyrrow.Item(
41
+ 1,
42
+ [(0, 0), (1, 0), (1, 1), (0, 0)],
43
+ demand=6,
44
+ allowed_orientations=[0, 90, 180, -90],
45
+ )
46
+
47
+ instance = spyrrow.StripPackingInstance("test", strip_height=2.001, items=[rectangle1,triangle1])
48
+ sol:spyrrow.StripPackingSolution = instance.solve(30)
49
+ print(sol.width)
50
+ print(sol.density)
51
+ print("\n")
52
+ for pi in sol.placed_items:
53
+ print(pi.id)
54
+ print(pi.rotation)
55
+ print(pi.translation)
56
+ print("\n")
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ Spyrrow is open to contributions.
62
+ The first target should be to reach Python open sources packages standards and practices.
63
+ Second, a easier integration with the package `shapely` is envsionned.
64
+
65
+ Please use GitHub issues to request features.
66
+ They will be considered relative to what is already implemented in the parent library `sparrow`.
67
+ If necessary, they can be forwarded to it.
68
+
@@ -0,0 +1,53 @@
1
+ # Spyrrow
2
+
3
+ `spyrrow` is a Python wrapper on the Rust project [`sparrow`](https://github.com/JeroenGar/sparrow).
4
+ It enables to solve 2D [Strip packing problems](https://en.wikipedia.org/wiki/Strip_packing_problem).
5
+
6
+ The documentation is hosted [here](https://spyrrow.readthedocs.io/).
7
+
8
+ ## Installation
9
+
10
+ Spyrrow is hosted on [PyPI](https://pypi.org/project/spyrrow/).
11
+
12
+ You can install with the package manager of your choice, using the PyPI package index.
13
+
14
+ For example, with `pip`, the default Python package:
15
+ ```bash
16
+ pip install spyrrow
17
+ ```
18
+
19
+ ## Examples
20
+ ```python
21
+ import spyrrow
22
+
23
+ rectangle1 = spyrrow.Item(
24
+ 0, [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)], demand=4, allowed_orientations=[0]
25
+ )
26
+ triangle1 = spyrrow.Item(
27
+ 1,
28
+ [(0, 0), (1, 0), (1, 1), (0, 0)],
29
+ demand=6,
30
+ allowed_orientations=[0, 90, 180, -90],
31
+ )
32
+
33
+ instance = spyrrow.StripPackingInstance("test", strip_height=2.001, items=[rectangle1,triangle1])
34
+ sol:spyrrow.StripPackingSolution = instance.solve(30)
35
+ print(sol.width)
36
+ print(sol.density)
37
+ print("\n")
38
+ for pi in sol.placed_items:
39
+ print(pi.id)
40
+ print(pi.rotation)
41
+ print(pi.translation)
42
+ print("\n")
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ Spyrrow is open to contributions.
48
+ The first target should be to reach Python open sources packages standards and practices.
49
+ Second, a easier integration with the package `shapely` is envsionned.
50
+
51
+ Please use GitHub issues to request features.
52
+ They will be considered relative to what is already implemented in the parent library `sparrow`.
53
+ If necessary, they can be forwarded to it.
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,12 @@
1
+ API
2
+ ===
3
+
4
+ Public API of `spyrrow`
5
+
6
+ .. autoclass:: spyrrow::Item
7
+
8
+ .. autoclass:: spyrrow::StripPackingInstance
9
+
10
+ .. autoclass:: spyrrow::StripPackingSolution
11
+
12
+ .. autoclass:: spyrrow::PlacedItem
@@ -0,0 +1,32 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ project = 'spyrrow'
10
+ copyright = '2025, Paul Durand-Lupinski'
11
+ author = 'Paul Durand-Lupinski'
12
+ release = '0.4.0'
13
+
14
+ # -- General configuration ---------------------------------------------------
15
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16
+
17
+ extensions = [
18
+ 'sphinx.ext.napoleon',
19
+ 'sphinx.ext.autodoc'
20
+ ]
21
+
22
+ templates_path = ['_templates']
23
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
24
+
25
+ # Napoleon settings
26
+ napoleon_google_docstring = True
27
+
28
+ # -- Options for HTML output -------------------------------------------------
29
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
30
+
31
+ html_theme = 'alabaster'
32
+ html_static_path = ['_static']
@@ -0,0 +1,57 @@
1
+ .. spyrrow documentation master file, created by
2
+ sphinx-quickstart on Mon May 19 14:10:17 2025.
3
+ You can adapt this file completely to your liking, but it should at least
4
+ contain the root `toctree` directive.
5
+
6
+ spyrrow documentation
7
+ =====================
8
+
9
+ `spyrrow` is a Python wrapper on the Rust project `sparrow <https://github.com/JeroenGar/sparrow>`_.
10
+ It enables to solve 2D `Strip packing problems <https://en.wikipedia.org/wiki/Strip_packing_problem>`_.
11
+
12
+ .. toctree::
13
+ :maxdepth: 2
14
+ :caption: Contents:
15
+
16
+ api
17
+
18
+ Installation
19
+ ============
20
+
21
+ Spyrrow is hosted on `PyPI <https://pypi.org/project/spyrrow/>`_.
22
+
23
+ You can install with the package manager of your choice, using the PyPI package index.
24
+
25
+ For example, with `pip`, the default Python package:
26
+
27
+ .. code-block:: bash
28
+
29
+ pip install spyrrow
30
+
31
+ Examples
32
+ ========
33
+
34
+ .. code-block:: python
35
+
36
+ import spyrrow
37
+
38
+ rectangle1 = spyrrow.Item(
39
+ 0, [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)], demand=4, allowed_orientations=[0]
40
+ )
41
+ triangle1 = spyrrow.Item(
42
+ 1,
43
+ [(0, 0), (1, 0), (1, 1), (0, 0)],
44
+ demand=6,
45
+ allowed_orientations=[0, 90, 180, -90],
46
+ )
47
+
48
+ instance = spyrrow.StripPackingInstance("test", strip_height=2.001, items=[rectangle1,triangle1])
49
+ sol:spyrrow.StripPackingSolution = instance.solve(30)
50
+ print(sol.width)
51
+ print(sol.density)
52
+ print("\n")
53
+ for pi in sol.placed_items:
54
+ print(pi.id)
55
+ print(pi.rotation)
56
+ print(pi.translation)
57
+ print("\n")
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -10,8 +10,14 @@ classifiers = [
10
10
  "Programming Language :: Python :: Implementation :: CPython",
11
11
  "Programming Language :: Python :: Implementation :: PyPy",
12
12
  ]
13
+ authors = [ {name = "Paul Durand-Lupinski", email = "paul.durand-lupinski@reeverse-systems.com"}]
13
14
  license = { file = "LICENSE.txt" }
14
15
  dynamic = ["version"]
16
+
17
+ [project.urls]
18
+ documentation = "https://spyrrow.readthedocs.io/"
19
+ source = "https://github.com/PaulDL-RS/spyrrow"
20
+
15
21
  [tool.maturin]
16
22
  features = ["pyo3/extension-module"]
17
23
 
@@ -19,4 +25,5 @@ features = ["pyo3/extension-module"]
19
25
  dev = [
20
26
  "pytest",
21
27
  "ruff",
22
- ]
28
+ "sphinx>=8.1.3",
29
+ ]
@@ -0,0 +1,104 @@
1
+ from typing import TypeAlias
2
+
3
+ Point: TypeAlias = tuple[float, float]
4
+
5
+ class Item:
6
+ id: int
7
+ demand: int
8
+ shape: list[Point]
9
+ allowed_orientations: list[float]
10
+
11
+ def __init__(
12
+ self,
13
+ id: int,
14
+ shape: list[Point],
15
+ demand: int,
16
+ allowed_orientations: list[float],
17
+ ):
18
+ """
19
+ An Item represents any closed 2D shape by its outer boundary.
20
+
21
+ Spyrrow doesn't support hole(s) inside the shape as of yet. Therefore no Item can be nested inside another.
22
+
23
+ Continous rotation is not supported as of yet. A workaround is to specify any integer degrees between 0 and 360
24
+ to the allowed_orientations list.
25
+
26
+ Args:
27
+ id: The Item identifier for a given StripPackingInstance.
28
+ Best autoincremented as the instance verifies that all ids are presents starting from 0.
29
+ shape: An ordered list of (x,y) defining the shape boundary. The shape is represented as a polygon formed by this list of points.
30
+ The origin point can be included twice as the finishing point. If not, [last point, first point] is infered to be the last straight line of the shape.
31
+ demand: The quantity of identical Items to be placed inside the strip. Should be positive.
32
+ allowed_orientations: List of angles in degrees allowed. An empty list is equivalent to [0.].
33
+ The algorithmn is only very weakly sensible to the length of the list given.
34
+
35
+ """
36
+
37
+ def to_json_str(self)->str:
38
+ """ Return a string of the JSON representation of the object"""
39
+
40
+ class PlacedItem:
41
+ """
42
+ An object representing where a copy of an Item was placed inside the strip.
43
+
44
+ Attributes:
45
+ id (int): The Item identifier for a given StripPackingInstance.
46
+ translation (tuple[float,float]): the translation vector in the X-Y axis
47
+ rotation (float): The roation angle in degrees, assuming that the original Item was defined with 0° as its rotation angle.
48
+ """
49
+
50
+ id: int
51
+ shape: list[Point]
52
+ translation: Point
53
+ rotation: float
54
+
55
+ class StripPackingSolution:
56
+ """
57
+ An object representing the solution to a given StripPackingInstance.
58
+
59
+ Can not be directly instanciated. Result from StripPackingInstance.solve.
60
+
61
+ Attributes:
62
+ width (float): the width of the strip found to contains all Items. In the same unit as input.
63
+ placed_items (list[PlacedItem]): a list of all PlacedItems, describing how Items are placed in the solution
64
+ density (float): the fraction of the final strip used by items.
65
+ """
66
+
67
+ width: float
68
+ density: float
69
+ placed_items: list[PlacedItem]
70
+
71
+ class StripPackingInstance:
72
+ name: str
73
+ strip_height: float
74
+ items: list[Item]
75
+
76
+ def __init__(self, name: str, strip_height: float, items: list[Item]):
77
+ """
78
+ An Instance of a Strip Packing Problem.
79
+
80
+ Args:
81
+ name (str): The name of the instance. Required by the underlying sparrow library.
82
+ An empty string '' can be used, if the user doesn't have a use for this name.
83
+ strip_height (float): the fixed height of the strip. The unit should be compatible with the Item
84
+ items (list[Item]): The Items which defines the instances. All Items should be defined with the same scale ( same length unit).
85
+ Items ids should be an increasing series starting at 0 until len(items)-1.
86
+
87
+ Raises:
88
+ ValueError
89
+ """
90
+ def to_json_str(self)->str:
91
+ """ Return a string of the JSON representation of the object"""
92
+
93
+
94
+ def solve(self, computation_time: int = 600) -> StripPackingSolution:
95
+ """
96
+ The method to solve the instance.
97
+
98
+ Args:
99
+ computation_time (int): The total computation time in seconds used to find a solution.
100
+ The algorithm won't exit early.Waht you input is what you get. Default is 600 s = 10 minutes.
101
+
102
+ Returns:
103
+ a StripPackingSolution
104
+ """