portc 0.6.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 (146) hide show
  1. portc-0.6.0/.devcontainer/Dockerfile +5 -0
  2. portc-0.6.0/.devcontainer/devcontainer.json +50 -0
  3. portc-0.6.0/.devcontainer/postCreateCommand.sh +8 -0
  4. portc-0.6.0/.devcontainer/postStartCommand.sh +8 -0
  5. portc-0.6.0/.envrc +1 -0
  6. portc-0.6.0/.git_archival.txt +3 -0
  7. portc-0.6.0/.gitattributes +18 -0
  8. portc-0.6.0/.github/ISSUE_TEMPLATE/bug_report.yml +82 -0
  9. portc-0.6.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
  10. portc-0.6.0/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
  11. portc-0.6.0/.github/ISSUE_TEMPLATE/performance_issue.yml +126 -0
  12. portc-0.6.0/.github/copilot-instructions.md +1 -0
  13. portc-0.6.0/.github/dependabot.yml +31 -0
  14. portc-0.6.0/.github/release.yml +6 -0
  15. portc-0.6.0/.github/scripts/check_tool_pins.py +58 -0
  16. portc-0.6.0/.github/workflows/copilot-setup-steps.yml +34 -0
  17. portc-0.6.0/.github/workflows/deploy.yml +80 -0
  18. portc-0.6.0/.github/workflows/docpages.yml +119 -0
  19. portc-0.6.0/.github/workflows/lint.yml +40 -0
  20. portc-0.6.0/.github/workflows/test.yml +274 -0
  21. portc-0.6.0/.github/workflows/update-ruff.yml +113 -0
  22. portc-0.6.0/.github/workflows/update-ty.yml +103 -0
  23. portc-0.6.0/.gitignore +244 -0
  24. portc-0.6.0/.python-version +1 -0
  25. portc-0.6.0/.vscode/extensions.json +14 -0
  26. portc-0.6.0/.vscode/launch.json +28 -0
  27. portc-0.6.0/.vscode/settings.json +66 -0
  28. portc-0.6.0/AGENTS.md +93 -0
  29. portc-0.6.0/CITATION.cff +42 -0
  30. portc-0.6.0/CLA.md +77 -0
  31. portc-0.6.0/CODE_OF_CONDUCT.md +84 -0
  32. portc-0.6.0/CONTRIBUTING.md +73 -0
  33. portc-0.6.0/LICENSE +202 -0
  34. portc-0.6.0/NOTICE +16 -0
  35. portc-0.6.0/PKG-INFO +238 -0
  36. portc-0.6.0/README.md +198 -0
  37. portc-0.6.0/SECURITY.md +26 -0
  38. portc-0.6.0/benches/README.md +29 -0
  39. portc-0.6.0/benches/large/README.md +167 -0
  40. portc-0.6.0/benches/large/bench_einsum_dp.py +445 -0
  41. portc-0.6.0/benches/large/bench_large.py +332 -0
  42. portc-0.6.0/benches/primitives/README.md +80 -0
  43. portc-0.6.0/benches/primitives/bench_mpo_mpo.py +142 -0
  44. portc-0.6.0/benches/stack/README.md +189 -0
  45. portc-0.6.0/benches/stack/bench_depth.py +466 -0
  46. portc-0.6.0/cspell.json +131 -0
  47. portc-0.6.0/docs/.gitignore +31 -0
  48. portc-0.6.0/docs/README.md +27 -0
  49. portc-0.6.0/docs/bibliography.bib +33 -0
  50. portc-0.6.0/docs/content/docs/benchmarks.mdx +90 -0
  51. portc-0.6.0/docs/content/docs/concepts/algorithm.mdx +70 -0
  52. portc-0.6.0/docs/content/docs/concepts/conventions.mdx +69 -0
  53. portc-0.6.0/docs/content/docs/concepts/index.mdx +9 -0
  54. portc-0.6.0/docs/content/docs/concepts/meta.json +4 -0
  55. portc-0.6.0/docs/content/docs/contributing/dependencies.mdx +61 -0
  56. portc-0.6.0/docs/content/docs/contributing/documenting.mdx +55 -0
  57. portc-0.6.0/docs/content/docs/contributing/index.mdx +87 -0
  58. portc-0.6.0/docs/content/docs/contributing/meta.json +4 -0
  59. portc-0.6.0/docs/content/docs/contributing/sonarcloud.mdx +37 -0
  60. portc-0.6.0/docs/content/docs/contributing/testing.mdx +130 -0
  61. portc-0.6.0/docs/content/docs/contributing/versioning.mdx +25 -0
  62. portc-0.6.0/docs/content/docs/features/cutoff.mdx +61 -0
  63. portc-0.6.0/docs/content/docs/features/gpu.mdx +39 -0
  64. portc-0.6.0/docs/content/docs/features/index.mdx +13 -0
  65. portc-0.6.0/docs/content/docs/features/large-problems.mdx +185 -0
  66. portc-0.6.0/docs/content/docs/features/logging.mdx +20 -0
  67. portc-0.6.0/docs/content/docs/features/meta.json +4 -0
  68. portc-0.6.0/docs/content/docs/features/precision.mdx +53 -0
  69. portc-0.6.0/docs/content/docs/features/stacks.mdx +43 -0
  70. portc-0.6.0/docs/content/docs/getting-started.mdx +71 -0
  71. portc-0.6.0/docs/content/docs/hpc/index.mdx +14 -0
  72. portc-0.6.0/docs/content/docs/hpc/leonardo.mdx +118 -0
  73. portc-0.6.0/docs/content/docs/hpc/meta.json +4 -0
  74. portc-0.6.0/docs/content/docs/index.mdx +50 -0
  75. portc-0.6.0/docs/content/docs/meta.json +3 -0
  76. portc-0.6.0/docs/content/docs/references.mdx +37 -0
  77. portc-0.6.0/docs/next.config.mjs +17 -0
  78. portc-0.6.0/docs/notebooks/accuracy_vs_bond_dimension/accuracy_vs_bond_dimension.ipynb +131 -0
  79. portc-0.6.0/docs/package-lock.json +7340 -0
  80. portc-0.6.0/docs/package.json +38 -0
  81. portc-0.6.0/docs/postcss.config.mjs +7 -0
  82. portc-0.6.0/docs/public/fonts/gt-planar/GT-Planar-Light.woff2 +0 -0
  83. portc-0.6.0/docs/public/fonts/gt-planar/GT-Planar-Regular.woff2 +0 -0
  84. portc-0.6.0/docs/public/fonts/gt-planar/GT-Planar-Thin.woff2 +0 -0
  85. portc-0.6.0/docs/scripts/api-mdx.mjs +254 -0
  86. portc-0.6.0/docs/scripts/gen_api_dump.py +597 -0
  87. portc-0.6.0/docs/scripts/generate-api.mjs +230 -0
  88. portc-0.6.0/docs/scripts/notebooks_to_mdx.py +185 -0
  89. portc-0.6.0/docs/scripts/remark-xref.mjs +75 -0
  90. portc-0.6.0/docs/scripts/xref.mjs +67 -0
  91. portc-0.6.0/docs/source.config.ts +97 -0
  92. portc-0.6.0/docs/src/app/(docs)/[[...slug]]/page.tsx +77 -0
  93. portc-0.6.0/docs/src/app/(docs)/layout.tsx +11 -0
  94. portc-0.6.0/docs/src/app/api/search/route.ts +9 -0
  95. portc-0.6.0/docs/src/app/global.css +64 -0
  96. portc-0.6.0/docs/src/app/icon.svg +21 -0
  97. portc-0.6.0/docs/src/app/layout.tsx +27 -0
  98. portc-0.6.0/docs/src/app/llms-full.txt/route.ts +10 -0
  99. portc-0.6.0/docs/src/app/llms.mdx/docs/[[...slug]]/route.ts +23 -0
  100. portc-0.6.0/docs/src/app/llms.txt/route.ts +8 -0
  101. portc-0.6.0/docs/src/app/og/docs/[...slug]/route.tsx +28 -0
  102. portc-0.6.0/docs/src/components/figure.tsx +22 -0
  103. portc-0.6.0/docs/src/components/logo.tsx +28 -0
  104. portc-0.6.0/docs/src/components/mdx.tsx +37 -0
  105. portc-0.6.0/docs/src/components/py.tsx +155 -0
  106. portc-0.6.0/docs/src/lib/cn.ts +1 -0
  107. portc-0.6.0/docs/src/lib/fonts.ts +27 -0
  108. portc-0.6.0/docs/src/lib/layout.shared.tsx +13 -0
  109. portc-0.6.0/docs/src/lib/shared.ts +18 -0
  110. portc-0.6.0/docs/src/lib/source.ts +37 -0
  111. portc-0.6.0/docs/tsconfig.json +45 -0
  112. portc-0.6.0/flake.lock +27 -0
  113. portc-0.6.0/flake.nix +54 -0
  114. portc-0.6.0/prek.toml +56 -0
  115. portc-0.6.0/pyproject.toml +274 -0
  116. portc-0.6.0/sonar-project.properties +13 -0
  117. portc-0.6.0/src/portc/__init__.py +29 -0
  118. portc-0.6.0/src/portc/_group.py +295 -0
  119. portc-0.6.0/src/portc/_kernels.py +199 -0
  120. portc-0.6.0/src/portc/_plan.py +644 -0
  121. portc-0.6.0/src/portc/_sites.py +315 -0
  122. portc-0.6.0/src/portc/_store.py +355 -0
  123. portc-0.6.0/src/portc/_sweep.py +589 -0
  124. portc-0.6.0/src/portc/_tensor_train.py +429 -0
  125. portc-0.6.0/src/portc/_validation.py +156 -0
  126. portc-0.6.0/src/portc/_version.py +24 -0
  127. portc-0.6.0/src/portc/apply.py +108 -0
  128. portc-0.6.0/src/portc/compress.py +92 -0
  129. portc-0.6.0/src/portc/py.typed +0 -0
  130. portc-0.6.0/src/portc/stack.py +168 -0
  131. portc-0.6.0/src/portc/utils/__init__.py +65 -0
  132. portc-0.6.0/src/portc/utils/_backend.py +486 -0
  133. portc-0.6.0/src/portc/utils/linalg.py +138 -0
  134. portc-0.6.0/tests/test_backend.py +111 -0
  135. portc-0.6.0/tests/test_gpu_backend.py +560 -0
  136. portc-0.6.0/tests/test_group.py +125 -0
  137. portc-0.6.0/tests/test_kernels.py +101 -0
  138. portc-0.6.0/tests/test_linalg.py +102 -0
  139. portc-0.6.0/tests/test_logging.py +88 -0
  140. portc-0.6.0/tests/test_package.py +788 -0
  141. portc-0.6.0/tests/test_plan.py +345 -0
  142. portc-0.6.0/tests/test_sites.py +163 -0
  143. portc-0.6.0/tests/test_stack.py +842 -0
  144. portc-0.6.0/tests/test_store.py +123 -0
  145. portc-0.6.0/tests/test_tensor_train.py +221 -0
  146. portc-0.6.0/uv.lock +2786 -0
@@ -0,0 +1,5 @@
1
+ FROM ghcr.io/astral-sh/uv:latest AS uv
2
+
3
+ FROM mcr.microsoft.com/devcontainers/base:1.2.5-noble
4
+
5
+ COPY --from=uv --chown=vscode: /uv /uvx /bin/
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "portc development environment",
3
+ "build": {
4
+ "dockerfile": "Dockerfile"
5
+ },
6
+ "remoteUser": "vscode",
7
+ "features": {
8
+ "ghcr.io/devcontainers/features/node:2": {
9
+ "version": "22"
10
+ }
11
+ },
12
+ "customizations": {
13
+ "vscode": {
14
+ "settings": {
15
+ "python.defaultInterpreterPath": "/home/vscode/.venv/bin/python",
16
+ "python.terminal.activateEnvInCurrentTerminal": true,
17
+ "terminal.integrated.defaultProfile.linux": "zsh",
18
+ "terminal.integrated.profiles.linux": {
19
+ "zsh": {
20
+ "path": "/bin/zsh"
21
+ }
22
+ }
23
+ },
24
+ "extensions": [
25
+ "MS-vsliveshare.vsliveshare",
26
+ "charliermarsh.ruff",
27
+ "ms-python.python",
28
+ "ms-toolsai.jupyter",
29
+ "mutantdino.resourcemonitor",
30
+ "njpwerner.autodocstring",
31
+ "streetsidesoftware.code-spell-checker",
32
+ "streetsidesoftware.code-spell-checker-scientific-terms",
33
+ "tamasfe.even-better-toml",
34
+ "vivaxy.vscode-conventional-commits"
35
+ ]
36
+ }
37
+ },
38
+ "containerEnv": {
39
+ "PYTHONUNBUFFERED": "True",
40
+ "WORKSPACE": "${containerWorkspaceFolder}",
41
+ "UV_LINK_MODE": "copy",
42
+ "UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv"
43
+ },
44
+ "postCreateCommand": "./.devcontainer/postCreateCommand.sh",
45
+ "postStartCommand": "./.devcontainer/postStartCommand.sh",
46
+ "hostRequirements": {
47
+ "cpus": 4,
48
+ "memory": "6gb"
49
+ }
50
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euxo pipefail
4
+
5
+
6
+ # install uv and uvx shell completions
7
+ echo 'eval "$(uv generate-shell-completion zsh)"' >> /home/vscode/.zshrc
8
+ echo 'eval "$(uvx --generate-shell-completion zsh)"' >> /home/vscode/.zshrc
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+
4
+ # install project with all dependencies (no GPU extras in devcontainer)
5
+ uv sync --all-groups
6
+
7
+ # install the git hook shims
8
+ uv run prek install --prepare-hooks
portc-0.6.0/.envrc ADDED
@@ -0,0 +1 @@
1
+ use flake
@@ -0,0 +1,3 @@
1
+ node: $Format:%H$
2
+ node-date: $Format:%cI$
3
+ describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
@@ -0,0 +1,18 @@
1
+ # Keep GitHub's language statistics meaningful for a pure-Python project.
2
+ *.py linguist-language=Python
3
+ docs/* linguist-documentation
4
+ benches/* linguist-documentation
5
+ *.md linguist-documentation
6
+ *.js linguist-detectable=false
7
+ *.css linguist-detectable=false
8
+
9
+ # Mark generated files.
10
+ **/generated/* linguist-generated=true
11
+
12
+ # Binary assets.
13
+ *.png binary
14
+
15
+ # Substituted at `git archive` time so hatch-vcs can derive a version from a
16
+ # tarball that has no .git directory.
17
+ .git_archival.txt export-subst
18
+ .gitignore export-ignore
@@ -0,0 +1,82 @@
1
+ name: Bug report
2
+ description: Report a bug or unexpected behavior in portc
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for taking the time to report a bug! Please fill in as much detail as possible.
9
+ See also the "Reporting bugs" section of CONTRIBUTING.md.
10
+
11
+ - type: textarea
12
+ id: description
13
+ attributes:
14
+ label: Bug description
15
+ description: A clear and concise description of the bug.
16
+ placeholder: What went wrong?
17
+ validations:
18
+ required: true
19
+
20
+ - type: textarea
21
+ id: reproduction
22
+ attributes:
23
+ label: Steps to reproduce
24
+ description: |
25
+ A minimal, self-contained reproducer, ideally with a fixed `seed=`.
26
+ For accuracy problems include the number of sites, the bond dimensions,
27
+ `chi_out`, the `dtype` and the error metric you used.
28
+ render: python
29
+ validations:
30
+ required: true
31
+
32
+ - type: textarea
33
+ id: expected
34
+ attributes:
35
+ label: Expected behavior
36
+ description: What did you expect to happen?
37
+ validations:
38
+ required: true
39
+
40
+ - type: dropdown
41
+ id: device
42
+ attributes:
43
+ label: Device
44
+ options:
45
+ - CPU (NumPy)
46
+ - GPU, NVIDIA (CuPy, CUDA)
47
+ - GPU, AMD (CuPy, ROCm)
48
+ validations:
49
+ required: true
50
+
51
+ - type: textarea
52
+ id: versions
53
+ attributes:
54
+ label: Versions
55
+ description: Versions of `portc`, Python, NumPy and, for GPU runs, CuPy and the CUDA/ROCm runtime.
56
+ render: text
57
+ placeholder: |
58
+ portc: (python -c "import portc; print(portc.__version__)")
59
+ Python:
60
+ NumPy:
61
+ CuPy:
62
+ validations:
63
+ required: true
64
+
65
+ - type: dropdown
66
+ id: os
67
+ attributes:
68
+ label: Operating system
69
+ options:
70
+ - Linux (x86_64)
71
+ - Linux (aarch64 / ARM64)
72
+ - macOS (Apple Silicon)
73
+ - macOS (Intel)
74
+ - Other (describe below)
75
+ validations:
76
+ required: true
77
+
78
+ - type: textarea
79
+ id: additional
80
+ attributes:
81
+ label: Additional context
82
+ description: Logs, tracebacks, or any other relevant information.
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: true
2
+ contact_links:
3
+ - name: Documentation
4
+ url: https://algorithmiq.github.io/portc/
5
+ about: Check the documentation before opening an issue.
@@ -0,0 +1,43 @@
1
+ name: Feature request / Enhancement
2
+ description: Suggest a new feature or improvement to portc
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for suggesting an improvement! Please describe your idea clearly.
9
+
10
+ - type: textarea
11
+ id: motivation
12
+ attributes:
13
+ label: Motivation
14
+ description: |
15
+ What problem does this feature solve, or what use case does it enable?
16
+ Is this related to something that is currently impossible or inconvenient?
17
+ placeholder: I'm trying to do X, but currently I have to work around it by doing Y…
18
+ validations:
19
+ required: true
20
+
21
+ - type: textarea
22
+ id: proposal
23
+ attributes:
24
+ label: Proposed feature
25
+ description: A clear description of the feature or change you'd like to see.
26
+ validations:
27
+ required: true
28
+
29
+ - type: textarea
30
+ id: api_sketch
31
+ attributes:
32
+ label: Proposed API or usage example (optional)
33
+ description: If applicable, sketch how the feature would look from a user's perspective.
34
+ render: python
35
+ placeholder: |
36
+ import portc
37
+ # ...
38
+
39
+ - type: textarea
40
+ id: additional
41
+ attributes:
42
+ label: Additional context
43
+ description: Any other relevant information, including alternative approaches you considered and why your proposal is preferred.
@@ -0,0 +1,126 @@
1
+ name: Performance issue
2
+ description: Report a performance regression or unexpectedly slow behavior
3
+ labels: ["performance"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for taking the time to report a performance issue!
9
+ Please include benchmark results so we can reproduce and investigate.
10
+
11
+ - type: textarea
12
+ id: description
13
+ attributes:
14
+ label: Performance issue description
15
+ description: Describe the performance problem you observed.
16
+ placeholder: What is slower than expected, and by how much?
17
+ validations:
18
+ required: true
19
+
20
+ - type: textarea
21
+ id: reproduction
22
+ attributes:
23
+ label: Steps to reproduce
24
+ description: |
25
+ Minimal code snippet that demonstrates the slow behavior, with the
26
+ number of sites, bond dimensions, `chi_out`, `dtype` and `device`.
27
+ render: python
28
+ validations:
29
+ required: true
30
+
31
+ - type: dropdown
32
+ id: os
33
+ attributes:
34
+ label: Operating system
35
+ options:
36
+ - Linux (x86_64)
37
+ - Linux (aarch64 / ARM64)
38
+ - macOS (Apple Silicon)
39
+ - macOS (Intel)
40
+ - Other (describe below)
41
+ validations:
42
+ required: true
43
+
44
+ - type: input
45
+ id: cpu
46
+ attributes:
47
+ label: CPU model
48
+ placeholder: "e.g. Intel Core i9-13900K, AMD EPYC 7763, Apple M3 Pro"
49
+ validations:
50
+ required: true
51
+
52
+ - type: input
53
+ id: ram
54
+ attributes:
55
+ label: Total RAM
56
+ placeholder: "e.g. 32 GB"
57
+ validations:
58
+ required: true
59
+
60
+ - type: input
61
+ id: cores_used
62
+ attributes:
63
+ label: Number of cores used
64
+ description: How many CPU cores / threads did portc use during the run (e.g. `OMP_NUM_THREADS`)?
65
+ placeholder: "e.g. 8 (out of 16 physical cores)"
66
+ validations:
67
+ required: true
68
+
69
+ - type: textarea
70
+ id: bench_results
71
+ attributes:
72
+ label: Benchmark results
73
+ description: |
74
+ Please include the benchmark command and output.
75
+
76
+ For the pytest benchmark suite, run for example:
77
+
78
+ uv sync --group test
79
+ uv run pytest -m perf
80
+
81
+ For standalone benchmarks, see `benches/`.
82
+ placeholder: |
83
+ Command:
84
+ uv run pytest -m perf
85
+
86
+ Output:
87
+ ...
88
+ validations:
89
+ required: true
90
+
91
+ - type: dropdown
92
+ id: device
93
+ attributes:
94
+ label: Device
95
+ options:
96
+ - CPU (NumPy)
97
+ - GPU, NVIDIA (CuPy, CUDA)
98
+ - GPU, AMD (CuPy, ROCm)
99
+ validations:
100
+ required: true
101
+
102
+ - type: input
103
+ id: gpu
104
+ attributes:
105
+ label: GPU model and memory
106
+ description: Only for GPU runs.
107
+ placeholder: "e.g. NVIDIA A100 80 GB"
108
+
109
+ - type: textarea
110
+ id: versions
111
+ attributes:
112
+ label: Versions
113
+ description: Versions of `portc`, Python, NumPy and, for GPU runs, CuPy and the CUDA/ROCm runtime.
114
+ render: text
115
+ placeholder: |
116
+ portc:
117
+ Python:
118
+ NumPy:
119
+ CuPy:
120
+ validations:
121
+ required: true
122
+
123
+ - type: textarea
124
+ id: additional
125
+ attributes:
126
+ label: Additional context
@@ -0,0 +1 @@
1
+ ../AGENTS.md
@@ -0,0 +1,31 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ # maintain dependencies for Python
9
+ - package-ecosystem: "uv"
10
+ directory: "/" # Location of package manifests
11
+ # run on the 1st and 15th day of the month
12
+ schedule:
13
+ interval: "cron"
14
+ cronjob: "0 3 1,15 * *"
15
+ open-pull-requests-limit: 10
16
+ ignore:
17
+ # for all dependencies, ignore all patch updates
18
+ - dependency-name: "*"
19
+ update-types: ["version-update:semver-patch"]
20
+
21
+ # maintain dependencies for GitHub Actions
22
+ - package-ecosystem: "github-actions"
23
+ directory: "/"
24
+ schedule:
25
+ interval: "monthly"
26
+
27
+ # maintain dependencies for DevContainer
28
+ - package-ecosystem: "devcontainers"
29
+ directory: "/"
30
+ schedule:
31
+ interval: "monthly"
@@ -0,0 +1,6 @@
1
+ changelog:
2
+ exclude:
3
+ authors:
4
+ - dependabot[bot]
5
+ labels:
6
+ - dependencies
@@ -0,0 +1,58 @@
1
+ # ruff: noqa: INP001 (a standalone script, not part of a package)
2
+ """Fail if a tool is pinned to different versions in pyproject.toml and prek.toml.
3
+
4
+ `uv run ruff` and the prek hook must agree, or a file can pass locally and fail
5
+ in CI. Each tool below is pinned as ``tool==X.Y.Z`` in a dependency group and as
6
+ ``rev = "vX.Y.Z"`` on its pre-commit mirror.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import re
12
+ import sys
13
+ import tomllib
14
+ from pathlib import Path
15
+
16
+ ROOT = Path(__file__).resolve().parents[2]
17
+ MIRRORS = {
18
+ "ruff": "https://github.com/astral-sh/ruff-pre-commit",
19
+ "ty": "https://github.com/astral-sh/ty-pre-commit",
20
+ }
21
+
22
+
23
+ def main() -> int:
24
+ """Compare the pins and report every mismatch.
25
+
26
+ Returns:
27
+ The process exit code: 0 if every pin agrees, 1 otherwise.
28
+ """
29
+ pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text())
30
+ prek = tomllib.loads((ROOT / "prek.toml").read_text())
31
+ requirements = [
32
+ req
33
+ for group in pyproject["dependency-groups"].values()
34
+ for req in group
35
+ if isinstance(req, str)
36
+ ]
37
+ revs = {repo["repo"]: repo.get("rev") for repo in prek["repos"]}
38
+
39
+ errors = []
40
+ for tool, mirror in MIRRORS.items():
41
+ pins = {
42
+ m.group(1)
43
+ for req in requirements
44
+ if (m := re.fullmatch(rf"{tool}==(\S+)", req.replace(" ", "")))
45
+ }
46
+ rev = revs.get(mirror)
47
+ if len(pins) != 1 or rev is None:
48
+ errors.append(f"{tool}: expected one '{tool}==' pin and a {mirror} rev")
49
+ elif rev.removeprefix("v") != (pin := pins.pop()):
50
+ errors.append(f"{tool}: pyproject.toml pins {pin}, prek.toml pins {rev}")
51
+
52
+ for error in errors:
53
+ print(error, file=sys.stderr) # noqa: T201
54
+ return 1 if errors else 0
55
+
56
+
57
+ if __name__ == "__main__":
58
+ sys.exit(main())
@@ -0,0 +1,34 @@
1
+ name: "Copilot Setup Steps"
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ paths:
7
+ - .github/workflows/copilot-setup-steps.yml
8
+ pull_request:
9
+ paths:
10
+ - .github/workflows/copilot-setup-steps.yml
11
+
12
+ jobs:
13
+ # the job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
14
+ copilot-setup-steps:
15
+ runs-on: ubuntu-latest
16
+
17
+ permissions:
18
+ contents: read
19
+
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v7
23
+ with:
24
+ fetch-depth: 0
25
+
26
+ - name: Install the latest version of uv
27
+ uses: astral-sh/setup-uv@v7
28
+ with:
29
+ enable-cache: true
30
+ python-version: "3.14"
31
+
32
+ - name: Install package
33
+ run: |
34
+ uv sync --all-groups
@@ -0,0 +1,80 @@
1
+ name: Publish portc Python sdist and wheels
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+ pull_request:
8
+ # PRs trigger for the "opened", "reopened", "synchronize" events (default) and
9
+ # "ready_for_review"
10
+ paths:
11
+ - .github/workflows/deploy.yml
12
+ types:
13
+ - opened
14
+ - reopened
15
+ - synchronize
16
+ - ready_for_review
17
+
18
+ concurrency:
19
+ group: ${{ github.workflow }}-${{ github.ref }}
20
+ cancel-in-progress: true
21
+
22
+ env:
23
+ COLUMNS: 120
24
+ FORCE_COLOR: 3
25
+
26
+ jobs:
27
+ build-sdist-wheel:
28
+ name: Build source distribution and wheel
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v7
32
+ with:
33
+ fetch-depth: 0 # such that setuptools_scm can do its job correctly
34
+
35
+ - name: Install the latest version of uv
36
+ uses: astral-sh/setup-uv@v7
37
+ with:
38
+ enable-cache: true
39
+
40
+ - name: Build SDist and Wheel
41
+ run: |
42
+ # the `build` package's console script is `pyproject-build`, not `build`
43
+ uvx --from build pyproject-build --verbose --sdist --wheel --installer=uv
44
+
45
+ - uses: actions/upload-artifact@v7
46
+ with:
47
+ name: cibw-dist
48
+ path: |
49
+ dist/*.tar.gz
50
+ dist/*.whl
51
+
52
+
53
+ upload_pypi:
54
+ name: Upload to PyPI
55
+ needs:
56
+ - build-sdist-wheel
57
+ if: github.event_name == 'release' && github.event.action == 'published'
58
+
59
+ runs-on: ubuntu-latest
60
+
61
+ # Requires a `pypi` environment (Settings > Environments) with a Trusted
62
+ # Publisher configured on https://pypi.org for this repo and workflow, and
63
+ # ideally required reviewers, since a release here cannot be undone.
64
+ environment:
65
+ name: pypi
66
+ url: https://pypi.org/project/portc/
67
+
68
+ permissions:
69
+ id-token: write # for PyPI's trusted publishing (OIDC); no token is stored
70
+
71
+ steps:
72
+ - uses: actions/download-artifact@v8
73
+ with:
74
+ # unpacks all CIBW artifacts into dist/
75
+ pattern: cibw-*
76
+ path: dist
77
+ merge-multiple: true
78
+
79
+ - name: Publish to PyPI
80
+ uses: pypa/gh-action-pypi-publish@release/v1