laylight 0.2.2__tar.gz → 0.3.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.
Files changed (38) hide show
  1. {laylight-0.2.2 → laylight-0.3.0}/.gitignore +3 -0
  2. {laylight-0.2.2 → laylight-0.3.0}/PKG-INFO +3 -3
  3. {laylight-0.2.2 → laylight-0.3.0}/README.md +1 -1
  4. {laylight-0.2.2 → laylight-0.3.0}/laylight/backend.py +29 -2
  5. {laylight-0.2.2 → laylight-0.3.0}/pyproject.toml +2 -2
  6. {laylight-0.2.2 → laylight-0.3.0}/laylight/__init__.py +0 -0
  7. {laylight-0.2.2 → laylight-0.3.0}/laylight/font.py +0 -0
  8. {laylight-0.2.2 → laylight-0.3.0}/laylight/geometry.py +0 -0
  9. {laylight-0.2.2 → laylight-0.3.0}/laylight/ir.py +0 -0
  10. {laylight-0.2.2 → laylight-0.3.0}/laylight/klayout_bridge.py +0 -0
  11. {laylight-0.2.2 → laylight-0.3.0}/laylight/layout.py +0 -0
  12. {laylight-0.2.2 → laylight-0.3.0}/laylight/pcell.py +0 -0
  13. {laylight-0.2.2 → laylight-0.3.0}/laylight/placable.py +0 -0
  14. {laylight-0.2.2 → laylight-0.3.0}/laylight/primitives.py +0 -0
  15. {laylight-0.2.2 → laylight-0.3.0}/laylight/render.py +0 -0
  16. {laylight-0.2.2 → laylight-0.3.0}/laylight/render_all.py +0 -0
  17. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/__init__.py +0 -0
  18. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/abstract.py +0 -0
  19. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/black_box.py +0 -0
  20. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/connection.py +0 -0
  21. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/coupler.py +0 -0
  22. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/crossing.py +0 -0
  23. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/curve.py +0 -0
  24. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/cutback.py +0 -0
  25. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/grating.py +0 -0
  26. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/metal.py +0 -0
  27. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/mmi.py +0 -0
  28. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/mzi.py +0 -0
  29. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/mzi_rect.py +0 -0
  30. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/packaging.py +0 -0
  31. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/prober.py +0 -0
  32. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/racetrack.py +0 -0
  33. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/ring.py +0 -0
  34. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/spiral.py +0 -0
  35. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/taper.py +0 -0
  36. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/transition.py +0 -0
  37. {laylight-0.2.2 → laylight-0.3.0}/laylight/structure/wg.py +0 -0
  38. {laylight-0.2.2 → laylight-0.3.0}/laylight/technology.py +0 -0
@@ -31,3 +31,6 @@ packages/laylight-docs/out/
31
31
  packages/laylight-docs/lib/lyl-samples.generated.ts
32
32
  packages/laylight-docs/lib/benchmarks.generated.ts
33
33
  packages/laylight-docs/lib/photonics-examples.generated.ts
34
+
35
+ # Local Wrangler / Miniflare state (packages/telemetry)
36
+ .wrangler/
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: laylight
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: Photonic layout in Python, compiled to GDSII by the Laylight compiler
5
5
  Keywords: gds,layout,photonics
6
6
  Requires-Python: >=3.10
7
- Requires-Dist: laylight-cli==0.2.2
7
+ Requires-Dist: laylight-cli==0.3.0
8
8
  Provides-Extra: klayout
9
9
  Requires-Dist: klayout>=0.30.8; extra == 'klayout'
10
10
  Description-Content-Type: text/markdown
@@ -35,7 +35,7 @@ Photonic layout work often mixes device geometry, parameter sweeps, custom scrip
35
35
  pip install laylight
36
36
  ```
37
37
 
38
- This installs the `laylight` command line too (the `laylight-cli` package). PNG previews and KLayout PCells need KLayout:
38
+ This installs the `laylight` command line too (the `laylight-cli` package), which sends anonymous [usage statistics](https://laylight.photonstack.io/telemetry/) unless `LAYLIGHT_TELEMETRY=0` is set. PNG previews and KLayout PCells need KLayout:
39
39
 
40
40
  ```bash
41
41
  pip install "laylight[klayout]"
@@ -24,7 +24,7 @@ Photonic layout work often mixes device geometry, parameter sweeps, custom scrip
24
24
  pip install laylight
25
25
  ```
26
26
 
27
- This installs the `laylight` command line too (the `laylight-cli` package). PNG previews and KLayout PCells need KLayout:
27
+ This installs the `laylight` command line too (the `laylight-cli` package), which sends anonymous [usage statistics](https://laylight.photonstack.io/telemetry/) unless `LAYLIGHT_TELEMETRY=0` is set. PNG previews and KLayout PCells need KLayout:
28
28
 
29
29
  ```bash
30
30
  pip install "laylight[klayout]"
@@ -4,6 +4,11 @@ package) turns Laylight IR into GDSII, and reads GDSII back as IR.
4
4
  The command is found through the `LAYLIGHT_CLI` environment variable, then
5
5
  where the installed `laylight-cli` package put it, then next to the running
6
6
  Python, then on `PATH`.
7
+
8
+ The command line sends anonymous usage statistics
9
+ (https://laylight.photonstack.io/telemetry/); runs from this library are
10
+ marked `LAYLIGHT_CALLER=python/<version>`, and its one-time notice about them
11
+ is passed on to stderr. `LAYLIGHT_TELEMETRY=0` turns them off.
7
12
  """
8
13
 
9
14
  from __future__ import annotations
@@ -96,9 +101,15 @@ def run(args: Sequence[str], *, cli: str | None = None) -> subprocess.CompletedP
96
101
  raise CompilerError(
97
102
  f"laylight {found} at `{command}` cannot compile IR; laylight-cli {needed} or later is needed"
98
103
  )
99
- result = subprocess.run([command, *args], capture_output=True, text=True)
104
+ result = subprocess.run([command, *args], capture_output=True, text=True, env=_environment())
105
+ # The notice about usage statistics is meant for the user, who does not
106
+ # see the command's stderr otherwise.
107
+ notice = [line for line in result.stderr.splitlines() if line.startswith("notice: ")]
108
+ if notice:
109
+ print("\n".join(notice), file=sys.stderr)
100
110
  if result.returncode != 0:
101
- message = result.stderr.strip() or result.stdout.strip()
111
+ errors = "\n".join(line for line in result.stderr.splitlines() if not line.startswith("notice: "))
112
+ message = errors.strip() or result.stdout.strip()
102
113
  raise CompilerError(f"laylight {' '.join(args[:1])} failed:\n{message}")
103
114
  for line in result.stderr.splitlines():
104
115
  if line.startswith("warning: "):
@@ -106,6 +117,22 @@ def run(args: Sequence[str], *, cli: str | None = None) -> subprocess.CompletedP
106
117
  return result
107
118
 
108
119
 
120
+ def _environment() -> dict[str, str]:
121
+ """The environment of a run: this one, with the caller named for the
122
+ command line's usage statistics unless a tool around us already did."""
123
+ env = dict(os.environ)
124
+ env.setdefault("LAYLIGHT_CALLER", f"python/{_library_version()}")
125
+ return env
126
+
127
+
128
+ @functools.lru_cache(maxsize=None)
129
+ def _library_version() -> str:
130
+ try:
131
+ return metadata.version("laylight")
132
+ except metadata.PackageNotFoundError:
133
+ return "0.0.0"
134
+
135
+
109
136
  def build(
110
137
  ir_text: str,
111
138
  output: "str | os.PathLike[str]",
@@ -2,14 +2,14 @@
2
2
  name = "laylight"
3
3
  # Released together with the `laylight` command line, at its version
4
4
  # (crates/laylight-cli/Cargo.toml); scripts/check_version.py checks both.
5
- version = "0.2.2"
5
+ version = "0.3.0"
6
6
  description = "Photonic layout in Python, compiled to GDSII by the Laylight compiler"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.10"
9
9
  dependencies = [
10
10
  # The `laylight` command line (Rust), which compiles the IR this library
11
11
  # builds: the release of the same version.
12
- "laylight-cli==0.2.2",
12
+ "laylight-cli==0.3.0",
13
13
  ]
14
14
  keywords = ["layout", "gds", "photonics"]
15
15
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes