mqt-nox 1.0.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.
- mqt_nox-1.0.0/LICENSE +201 -0
- mqt_nox-1.0.0/PKG-INFO +50 -0
- mqt_nox-1.0.0/README.md +31 -0
- mqt_nox-1.0.0/docs/ai_usage.md +180 -0
- mqt_nox-1.0.0/docs/usage.md +103 -0
- mqt_nox-1.0.0/pyproject.toml +97 -0
- mqt_nox-1.0.0/pyproject.toml.orig +117 -0
- mqt_nox-1.0.0/src/mqt/nox/__init__.py +22 -0
- mqt_nox-1.0.0/src/mqt/nox/_sessions.py +154 -0
- mqt_nox-1.0.0/src/mqt/nox/py.typed +0 -0
- mqt_nox-1.0.0/src/mqt/nox/utils.py +114 -0
mqt_nox-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
mqt_nox-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mqt-nox
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Reusable Nox Sessions for Python Projects
|
|
5
|
+
Author: Daniel Haag
|
|
6
|
+
Author-email: Daniel Haag <daniel@mq.sc>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Natural Language :: English
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Requires-Dist: nox>=2026.10.20
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Project-URL: Homepage, https://github.com/munich-quantum-toolkit/nox
|
|
16
|
+
Project-URL: Issues, https://github.com/munich-quantum-toolkit/nox/issues
|
|
17
|
+
Project-URL: Discussions, https://github.com/munich-quantum-toolkit/nox/discussions
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
[](LICENSE)
|
|
21
|
+
|
|
22
|
+
# Reusable Nox Sessions for Python Projects
|
|
23
|
+
|
|
24
|
+
`mqt-nox` provides reusable Nox session functions for Python projects. The
|
|
25
|
+
functions handle recurring test, documentation, lint, and stub-generation tasks.
|
|
26
|
+
Each repository defines its own sessions and can customize them with ordinary
|
|
27
|
+
Python code.
|
|
28
|
+
|
|
29
|
+
These sessions are designed for use across the
|
|
30
|
+
[Munich Quantum Toolkit (MQT)](https://mqt.readthedocs.io), projects maintained
|
|
31
|
+
by [MQSC](https://mq.sc), and the
|
|
32
|
+
[Quantum Device Management Interface (QDMI)](https://github.com/Munich-Quantum-Software-Stack/QDMI)
|
|
33
|
+
ecosystem. Other Python projects can use them by following the conventions in
|
|
34
|
+
the usage guide.
|
|
35
|
+
|
|
36
|
+
## Contributors
|
|
37
|
+
|
|
38
|
+
This project is created and maintained by [MQSC](https://mq.sc), with
|
|
39
|
+
contributions from the community.
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://github.com/munich-quantum-toolkit/nox/graphs/contributors">
|
|
43
|
+
<img src="https://contrib.rocks/image?repo=munich-quantum-toolkit/nox" alt="Contributors to munich-quantum-toolkit/nox" />
|
|
44
|
+
</a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
## Getting Started
|
|
48
|
+
|
|
49
|
+
See the [usage guide](docs/usage.md) for installation, available functions, and
|
|
50
|
+
examples for Python projects.
|
mqt_nox-1.0.0/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[](LICENSE)
|
|
2
|
+
|
|
3
|
+
# Reusable Nox Sessions for Python Projects
|
|
4
|
+
|
|
5
|
+
`mqt-nox` provides reusable Nox session functions for Python projects. The
|
|
6
|
+
functions handle recurring test, documentation, lint, and stub-generation tasks.
|
|
7
|
+
Each repository defines its own sessions and can customize them with ordinary
|
|
8
|
+
Python code.
|
|
9
|
+
|
|
10
|
+
These sessions are designed for use across the
|
|
11
|
+
[Munich Quantum Toolkit (MQT)](https://mqt.readthedocs.io), projects maintained
|
|
12
|
+
by [MQSC](https://mq.sc), and the
|
|
13
|
+
[Quantum Device Management Interface (QDMI)](https://github.com/Munich-Quantum-Software-Stack/QDMI)
|
|
14
|
+
ecosystem. Other Python projects can use them by following the conventions in
|
|
15
|
+
the usage guide.
|
|
16
|
+
|
|
17
|
+
## Contributors
|
|
18
|
+
|
|
19
|
+
This project is created and maintained by [MQSC](https://mq.sc), with
|
|
20
|
+
contributions from the community.
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a href="https://github.com/munich-quantum-toolkit/nox/graphs/contributors">
|
|
24
|
+
<img src="https://contrib.rocks/image?repo=munich-quantum-toolkit/nox" alt="Contributors to munich-quantum-toolkit/nox" />
|
|
25
|
+
</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
## Getting Started
|
|
29
|
+
|
|
30
|
+
See the [usage guide](docs/usage.md) for installation, available functions, and
|
|
31
|
+
examples for Python projects.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<!--- This file has been generated from an external template. Please do not modify it directly. -->
|
|
2
|
+
<!--- Changes should be contributed to https://github.com/munich-quantum-toolkit/templates. -->
|
|
3
|
+
|
|
4
|
+
# AI Usage Guidelines
|
|
5
|
+
|
|
6
|
+
We acknowledge that AI tools (Large Language Models, code completion engines
|
|
7
|
+
like GitHub Copilot, etc.) have become helpful assistants for many developers.
|
|
8
|
+
We allow the use of these tools to assist with contributions, provided that
|
|
9
|
+
their use is transparent, responsible, and that a **human remains in the loop**
|
|
10
|
+
at all times.
|
|
11
|
+
|
|
12
|
+
This guide outlines our policy on AI-assisted contributions to ensure code
|
|
13
|
+
quality, maintainability, and legal compliance.
|
|
14
|
+
|
|
15
|
+
## Core Principles
|
|
16
|
+
|
|
17
|
+
### 1. You are Responsible
|
|
18
|
+
|
|
19
|
+
**You are responsible for every line of code you submit.**
|
|
20
|
+
|
|
21
|
+
Regardless of whether code was written by you or generated by an AI tool, you
|
|
22
|
+
are the author and are fully accountable for the contribution. You must:
|
|
23
|
+
|
|
24
|
+
- Fully understand the code you are submitting.
|
|
25
|
+
- Be able to explain the reasoning behind the code and how it interacts with the
|
|
26
|
+
rest of the codebase.
|
|
27
|
+
- Verify that the code is correct, efficient, and follows our coding standards.
|
|
28
|
+
|
|
29
|
+
**Do not blindly copy-paste AI-generated code.** If you cannot explain it, do
|
|
30
|
+
not submit it.
|
|
31
|
+
|
|
32
|
+
### 2. Human in the Loop
|
|
33
|
+
|
|
34
|
+
**Humans remain accountable for AI-assisted contributions.**
|
|
35
|
+
|
|
36
|
+
AI agents may implement changes and manage issue and pull request workflows when
|
|
37
|
+
a human explicitly authorizes the scope and relevant external actions. The human
|
|
38
|
+
remains the driver and is responsible for the resulting contribution.
|
|
39
|
+
|
|
40
|
+
- **Review:** You must read and review all AI-generated code and relevant public
|
|
41
|
+
text before merging or otherwise accepting the contribution. You remain
|
|
42
|
+
accountable for public text posted within an authorized scope.
|
|
43
|
+
- **Edit:** AI-generated code often requires significant editing to meet project
|
|
44
|
+
standards and correctness.
|
|
45
|
+
- **Verify:** Ensure the code actually solves the problem and doesn't introduce
|
|
46
|
+
subtle bugs or security vulnerabilities.
|
|
47
|
+
- **Authorize:** Explicitly authorize agents before they create, edit, submit,
|
|
48
|
+
or comment on issues and pull requests. A single authorization may cover a
|
|
49
|
+
clearly scoped task; per-message approval is not required. Remain accountable
|
|
50
|
+
for all external communication that agents submit on your behalf. Actions
|
|
51
|
+
outside the authorized scope require fresh authorization.
|
|
52
|
+
|
|
53
|
+
### 3. Communication
|
|
54
|
+
|
|
55
|
+
**AI tools may be used to prepare and manage issue and pull request workflows,
|
|
56
|
+
including descriptions, comments, and code reviews, when a human has authorized
|
|
57
|
+
the action and remains responsible for the result.**
|
|
58
|
+
|
|
59
|
+
AI-generated communication can be incorrect, irrelevant, or overly generic. Keep
|
|
60
|
+
it accurate, specific, and useful to reviewers and contributors. Do not post
|
|
61
|
+
low-quality, repetitive, or unsolicited messages.
|
|
62
|
+
|
|
63
|
+
Every agent-authored or agent-edited public text body must begin with the
|
|
64
|
+
following visible disclosure:
|
|
65
|
+
|
|
66
|
+
`🤖 *AI text below* 🤖`
|
|
67
|
+
|
|
68
|
+
This requirement applies to issue and pull request descriptions, review bodies,
|
|
69
|
+
inline review comments, issue-style comments, replies, and other submitted text
|
|
70
|
+
bodies. Pull request and issue titles are exempt. When editing existing
|
|
71
|
+
human-authored text, preserve the original content and add the disclosure at the
|
|
72
|
+
beginning of the edited field.
|
|
73
|
+
|
|
74
|
+
### 4. Transparency and Disclosure
|
|
75
|
+
|
|
76
|
+
Transparency helps the community understand the role of these tools and develop
|
|
77
|
+
best practices.
|
|
78
|
+
|
|
79
|
+
**AI assistance must be disclosed in the PR description.** This helps reviewers
|
|
80
|
+
understand how the tools were used and where human verification was applied.
|
|
81
|
+
|
|
82
|
+
- **PR Description**: Briefly state how AI tools materially assisted the
|
|
83
|
+
contribution. If an agent authored or edited the description, use the visible
|
|
84
|
+
disclosure required in the [communication policy](#3-communication).
|
|
85
|
+
- **Commit Messages**: We recommend adding an
|
|
86
|
+
`Assisted-by: [Model Name] via [Tool Name]` trailer to commits prepared with
|
|
87
|
+
AI assistance. For example:
|
|
88
|
+
`Assisted-by: Claude Sonnet 4.6 via GitHub Copilot`.
|
|
89
|
+
|
|
90
|
+
### 5. Licensing and Copyright
|
|
91
|
+
|
|
92
|
+
You are responsible for ensuring that your contribution does not violate any
|
|
93
|
+
third-party licenses or copyrights.
|
|
94
|
+
|
|
95
|
+
- **Originality**: Your submission must be your own original work of authorship.
|
|
96
|
+
- **Training Data**: Be aware that some AI tools may generate code that is
|
|
97
|
+
substantially similar to their training data. You must ensure that you have
|
|
98
|
+
the right to contribute the generated code under
|
|
99
|
+
[our license](https://github.com/munich-quantum-toolkit/nox/blob/main/LICENSE).
|
|
100
|
+
|
|
101
|
+
## Extractive Contributions
|
|
102
|
+
|
|
103
|
+
Processing pull requests and comments for MQT Nox Sessions requires significant
|
|
104
|
+
maintainer time and energy. Sending unreviewed AI output to open-source projects
|
|
105
|
+
shifts the burden of verifying correctness from the contributor to the
|
|
106
|
+
maintainer. We classify such contributions as "extractive" because they consume
|
|
107
|
+
more community resources than they provide in value.
|
|
108
|
+
|
|
109
|
+
Our **golden rule** is that a contribution should be valuable enough to justify
|
|
110
|
+
the review effort. Nadia Eghbal captures this concept in her book
|
|
111
|
+
_[Working in Public](https://press.stripe.com/working-in-public)_:
|
|
112
|
+
|
|
113
|
+
> "When attention is being appropriated, producers need to weigh the costs and
|
|
114
|
+
> benefits of the transaction. To assess whether the appropriation of attention
|
|
115
|
+
> is net-positive, it's useful to distinguish between _extractive_ and
|
|
116
|
+
> _non-extractive_ contributions. Extractive contributions are those where the
|
|
117
|
+
> marginal cost of reviewing and merging that contribution is greater than the
|
|
118
|
+
> marginal benefit to the project's producers. In the case of a code
|
|
119
|
+
> contribution, it might be a pull request that's too complex or unwieldy to
|
|
120
|
+
> review, given the potential upside." — Nadia Eghbal
|
|
121
|
+
|
|
122
|
+
Before AI tools became widespread, open-source project maintainers would often
|
|
123
|
+
review all changes sent to the project simply because submitting a pull request
|
|
124
|
+
was a sign of interest from a potential long-term contributor. However, AI tools
|
|
125
|
+
now allow the rapid generation of large volumes of code, which can easily
|
|
126
|
+
overwhelm maintainers if submitted without careful review. Our policy exists to
|
|
127
|
+
ensure that maintainer time is spent on high-quality interactions rather than
|
|
128
|
+
debugging AI-generated code.
|
|
129
|
+
|
|
130
|
+
### Sustainable Open Source
|
|
131
|
+
|
|
132
|
+
The Munich Quantum Toolkit (MQT) is committed to remaining free, open-source,
|
|
133
|
+
and permissively licensed. We want to build a welcoming community where aspiring
|
|
134
|
+
quantum software engineers can learn and grow. Reviewing contributions is a key
|
|
135
|
+
part of this mentorship.
|
|
136
|
+
|
|
137
|
+
However, to keep the project sustainable, we must prioritize non-extractive
|
|
138
|
+
contributions. By thoroughly reviewing and understanding your AI-assisted code
|
|
139
|
+
before submission, you ensure that your contribution is a net positive for the
|
|
140
|
+
project. This helps us maintain a healthy ecosystem where both the software and
|
|
141
|
+
its contributors can thrive.
|
|
142
|
+
|
|
143
|
+
## Prohibited Uses
|
|
144
|
+
|
|
145
|
+
- **"Good First Issues"**: Do not use AI tools to solve issues labeled as "good
|
|
146
|
+
first issue". These are intended as learning opportunities for new
|
|
147
|
+
contributors. Automating them defeats the purpose.
|
|
148
|
+
- **Spam**: Do not use AI to generate low-quality, repetitive, or unsolicited
|
|
149
|
+
comments or reviews ("AI Slop").
|
|
150
|
+
- **Unreviewed Code**: Merging or accepting code that you, as a human, have not
|
|
151
|
+
reviewed and tested yourself.
|
|
152
|
+
|
|
153
|
+
## Summary
|
|
154
|
+
|
|
155
|
+
We want to foster a welcoming community where developers can learn and grow. AI
|
|
156
|
+
tools can be great for productivity, but they should not replace critical
|
|
157
|
+
thinking or the learning process. If a maintainer judges that a contribution
|
|
158
|
+
relies too heavily on unverified AI generation or lacks sufficient human
|
|
159
|
+
understanding ("extractive contribution"), we may request that you revise it or
|
|
160
|
+
close the PR.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
Parts of this guide were inspired by or adapted from the contribution guidelines
|
|
165
|
+
of
|
|
166
|
+
|
|
167
|
+
- [Astral],
|
|
168
|
+
- [Qiskit], and
|
|
169
|
+
- [LLVM], including the sources therein, such as
|
|
170
|
+
[Fedora Council Policy Proposal: Policy on AI-Assisted Contributions (fetched 2026-03-12)][fedora], <!-- rumdl-disable-line MD013 -->
|
|
171
|
+
which is licensed under the
|
|
172
|
+
[Creative Commons Attribution 4.0 International License][cca],
|
|
173
|
+
|
|
174
|
+
with the help of Gemini 3 Pro (Preview). The links above serve as attribution.
|
|
175
|
+
|
|
176
|
+
[Astral]: https://github.com/astral-sh/uv/blob/c89a78ec085077f6344b0439ddf07fdad7336310/CONTRIBUTING.md
|
|
177
|
+
[Qiskit]: https://github.com/Qiskit/qiskit/blob/cd8701690723d3d9602fac63fe0bd7ea618799be/CONTRIBUTING.md#use-of-ai-tools
|
|
178
|
+
[LLVM]: https://github.com/llvm/llvm-project/blob/9b6391f9c439c9926e8587b7b940e9a1e98a7819/llvm/docs/AIToolPolicy.md
|
|
179
|
+
[fedora]: https://communityblog.fedoraproject.org/council-policy-proposal-policy-on-ai-assisted-contributions/
|
|
180
|
+
[cca]: https://creativecommons.org/licenses/by/4.0/
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Using the shared sessions
|
|
2
|
+
|
|
3
|
+
Keep session names, Python versions, and repository-specific setup in your
|
|
4
|
+
`noxfile.py`. The shared functions handle installation and common tasks. Set uv
|
|
5
|
+
as the default Nox environment backend as shown below.
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
Declare the dependencies in `noxfile.py` and call a helper from a regular Nox
|
|
10
|
+
session:
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
# /// script
|
|
14
|
+
# dependencies = ["nox>=2026.10.20", "mqt-nox~=1.0.0"]
|
|
15
|
+
# ///
|
|
16
|
+
|
|
17
|
+
import mqt.nox
|
|
18
|
+
import nox
|
|
19
|
+
|
|
20
|
+
nox.options.default_venv_backend = "uv"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@nox.session(python="3.14", reuse_venv=True)
|
|
24
|
+
def tests(session: nox.Session) -> None:
|
|
25
|
+
"""Run the test suite."""
|
|
26
|
+
mqt.nox.tests(session)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Add `mqt-nox~=1.0.0` to your project's development group as well. Run sessions
|
|
30
|
+
as usual:
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
uvx nox -s tests
|
|
34
|
+
uvx nox -s tests -- -k some_test
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Keep `pyproject.toml` alongside `noxfile.py` and update `uv.lock` when
|
|
38
|
+
dependencies change. Define a `test` dependency group containing `pytest` and
|
|
39
|
+
`pytest-cov` and a `docs` group containing Sphinx and documentation
|
|
40
|
+
dependencies.
|
|
41
|
+
|
|
42
|
+
Build isolation is enabled by default. For projects that build against
|
|
43
|
+
dependencies in the session environment, pass `build_isolation=False`, e.g.,
|
|
44
|
+
`mqt.nox.tests(session, build_isolation=False)`. This adds the `build` group and
|
|
45
|
+
disables isolation for the project package, whose name is read from
|
|
46
|
+
`project.name`. Define that group with the project's Python build dependencies.
|
|
47
|
+
With isolation disabled, the helpers also check for CMake and Ninja on `PATH`
|
|
48
|
+
and install either tool in the session if it is missing.
|
|
49
|
+
|
|
50
|
+
## Available helpers
|
|
51
|
+
|
|
52
|
+
| Helper | Description |
|
|
53
|
+
| --------------------------- | -------------------------------------- |
|
|
54
|
+
| `mqt.nox.lint(session)` | Run all prek hooks |
|
|
55
|
+
| `mqt.nox.tests(session)` | Run tests |
|
|
56
|
+
| `mqt.nox.minimums(session)` | Run tests with minimum dependencies |
|
|
57
|
+
| `mqt.nox.qiskit(session)` | Run tests against Qiskit's main branch |
|
|
58
|
+
| `mqt.nox.docs(session)` | Build or serve documentation |
|
|
59
|
+
|
|
60
|
+
The test and documentation helpers accept `build_isolation`.
|
|
61
|
+
|
|
62
|
+
Installation uses a single `uv sync --locked`, which fails if `uv.lock` is out
|
|
63
|
+
of date instead of updating it. With build isolation disabled, uv installs the
|
|
64
|
+
build dependencies before building the project in the same environment. The
|
|
65
|
+
minimum-dependency helper resolves independently of `uv.lock` and installs the
|
|
66
|
+
build and test groups first when isolation is disabled. The Qiskit helper
|
|
67
|
+
installs the upstream version after project synchronization so `pytest` uses
|
|
68
|
+
that version.
|
|
69
|
+
|
|
70
|
+
Documentation sessions install the locked docs dependencies and additionally
|
|
71
|
+
install sphinx-autobuild for interactive HTML previews. Pass `--non-interactive`
|
|
72
|
+
to build only, or `-- -b linkcheck` to check links.
|
|
73
|
+
|
|
74
|
+
Use `mqt.nox.stubs(session, modules=[...])` to generate nanobind stubs. Stub
|
|
75
|
+
generation installs the `build` group, which must include nanobind, and builds
|
|
76
|
+
without isolation. Pass full module names such as `mqt.qmap.sc`. The default
|
|
77
|
+
output directory follows the MQT layout, e.g., `python/mqt/qmap`. Override it
|
|
78
|
+
with `output_dir` if needed.
|
|
79
|
+
|
|
80
|
+
## Customizing a session
|
|
81
|
+
|
|
82
|
+
Use `pytest_args` for fixed `pytest` flags or test paths, `install_args` for uv
|
|
83
|
+
options such as `--all-extras` or `--reinstall-package`, and `sphinx_args` for
|
|
84
|
+
Sphinx options. Arguments after `--` are forwarded to the session's command.
|
|
85
|
+
`mqt.nox.tests` also accepts `extra_deps` for dependency overrides installed
|
|
86
|
+
after synchronization.
|
|
87
|
+
|
|
88
|
+
Use `utils` to compose custom sessions with additional dependency groups:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from mqt.nox import utils
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@nox.session(python="3.14", reuse_venv=True)
|
|
95
|
+
def evaluation(session: nox.Session) -> None:
|
|
96
|
+
"""Run the evaluation tests."""
|
|
97
|
+
utils.install(session, build_isolation=False, groups=["test", "evaluation"])
|
|
98
|
+
utils.run_pytest(session, pytest_args=["eval/ph/tests"])
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Repository-specific build steps and warning filters stay in the local session.
|
|
102
|
+
Use `session.env` for environment settings. Maturin and other specialized build
|
|
103
|
+
setups should keep their own installation code.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "uv_build"
|
|
3
|
+
requires = ["uv-build>=0.13,<0.14"]
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mqt-nox"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Reusable Nox Sessions for Python Projects"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Natural Language :: English",
|
|
15
|
+
"Programming Language :: Python",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
]
|
|
19
|
+
dependencies = ["nox>=2026.10.20"]
|
|
20
|
+
|
|
21
|
+
[[project.authors]]
|
|
22
|
+
name = "Daniel Haag"
|
|
23
|
+
email = "daniel@mq.sc"
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/munich-quantum-toolkit/nox"
|
|
27
|
+
Issues = "https://github.com/munich-quantum-toolkit/nox/issues"
|
|
28
|
+
Discussions = "https://github.com/munich-quantum-toolkit/nox/discussions"
|
|
29
|
+
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = ["prek>=0.4.5"]
|
|
32
|
+
|
|
33
|
+
[tool.uv]
|
|
34
|
+
required-version = ">=0.13.4"
|
|
35
|
+
|
|
36
|
+
[tool.uv.build-backend]
|
|
37
|
+
module-name = "mqt.nox"
|
|
38
|
+
source-include = ["docs/**"]
|
|
39
|
+
|
|
40
|
+
[tool.ruff]
|
|
41
|
+
line-length = 120
|
|
42
|
+
preview = true
|
|
43
|
+
fix = true
|
|
44
|
+
unsafe-fixes = true
|
|
45
|
+
show-fixes = true
|
|
46
|
+
|
|
47
|
+
[tool.ruff.format]
|
|
48
|
+
preview = true
|
|
49
|
+
docstring-code-format = true
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["ALL"]
|
|
53
|
+
ignore = [
|
|
54
|
+
"C90",
|
|
55
|
+
"COM812",
|
|
56
|
+
"CPY001",
|
|
57
|
+
"PLR09",
|
|
58
|
+
"PLR2004",
|
|
59
|
+
"PT028",
|
|
60
|
+
"S101",
|
|
61
|
+
"S404",
|
|
62
|
+
"S603",
|
|
63
|
+
"S607",
|
|
64
|
+
"T20",
|
|
65
|
+
]
|
|
66
|
+
future-annotations = true
|
|
67
|
+
|
|
68
|
+
[tool.ruff.lint.isort]
|
|
69
|
+
known-first-party = ["mqt.nox"]
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint.pydocstyle]
|
|
72
|
+
convention = "google"
|
|
73
|
+
|
|
74
|
+
[tool.check-sdist]
|
|
75
|
+
sdist-only = ["pyproject.toml.orig"]
|
|
76
|
+
git-only = [
|
|
77
|
+
".gitignore",
|
|
78
|
+
".license-tools-config.json",
|
|
79
|
+
".rumdl.toml",
|
|
80
|
+
"CHANGELOG.md",
|
|
81
|
+
"UPGRADING.md",
|
|
82
|
+
"uv.lock",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[tool.pyproject-fmt]
|
|
86
|
+
generate_python_version_classifiers = false
|
|
87
|
+
table_format = "long"
|
|
88
|
+
sub_table_spacing = """
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
separate_root_table = """
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
[tool.ty.terminal]
|
|
97
|
+
error-on-warning = true
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Copyright (c) 2026 Munich Quantum Software Company GmbH
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
build-backend = "uv_build"
|
|
20
|
+
requires = [ "uv-build>=0.13,<0.14" ]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
[project]
|
|
24
|
+
name = "mqt-nox"
|
|
25
|
+
version = "1.0.0"
|
|
26
|
+
description = "Reusable Nox Sessions for Python Projects"
|
|
27
|
+
readme = "README.md"
|
|
28
|
+
license = "Apache-2.0"
|
|
29
|
+
license-files = [ "LICENSE" ]
|
|
30
|
+
requires-python = ">=3.11"
|
|
31
|
+
classifiers = [
|
|
32
|
+
"Natural Language :: English",
|
|
33
|
+
"Programming Language :: Python",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
36
|
+
]
|
|
37
|
+
dependencies = [ "nox>=2026.10.20" ]
|
|
38
|
+
|
|
39
|
+
[[project.authors]]
|
|
40
|
+
name = "Daniel Haag"
|
|
41
|
+
email = "daniel@mq.sc"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/munich-quantum-toolkit/nox"
|
|
45
|
+
Issues = "https://github.com/munich-quantum-toolkit/nox/issues"
|
|
46
|
+
Discussions = "https://github.com/munich-quantum-toolkit/nox/discussions"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
[dependency-groups]
|
|
50
|
+
dev = [ "prek>=0.4.5" ]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
[tool.uv]
|
|
54
|
+
required-version = ">=0.13.4"
|
|
55
|
+
|
|
56
|
+
[tool.uv.build-backend]
|
|
57
|
+
module-name = "mqt.nox"
|
|
58
|
+
source-include = [ "docs/**" ]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
line-length = 120
|
|
63
|
+
preview = true
|
|
64
|
+
fix = true
|
|
65
|
+
unsafe-fixes = true
|
|
66
|
+
show-fixes = true
|
|
67
|
+
|
|
68
|
+
[tool.ruff.format]
|
|
69
|
+
preview = true
|
|
70
|
+
docstring-code-format = true
|
|
71
|
+
|
|
72
|
+
[tool.ruff.lint.isort]
|
|
73
|
+
known-first-party = [ "mqt.nox" ]
|
|
74
|
+
|
|
75
|
+
[tool.ruff.lint.pydocstyle]
|
|
76
|
+
convention = "google"
|
|
77
|
+
|
|
78
|
+
[tool.ruff.lint]
|
|
79
|
+
select = [ "ALL" ]
|
|
80
|
+
ignore = [
|
|
81
|
+
"C90", # <...> too complex
|
|
82
|
+
"COM812", # Trailing commas are handled by the formatter
|
|
83
|
+
"CPY001", # Missing copyright notice at top of file
|
|
84
|
+
"PLR09", # Too many <...>
|
|
85
|
+
"PLR2004", # Magic value used in comparison
|
|
86
|
+
"PT028", # Nox session helpers have optional arguments
|
|
87
|
+
"S101", # Use of assert detected
|
|
88
|
+
"S404", # `subprocess` module is possibly insecure
|
|
89
|
+
"S603", # `subprocess` call: check for execution of untrusted input
|
|
90
|
+
"S607", # Starting a process with a partial executable path
|
|
91
|
+
"T20", # print statement used
|
|
92
|
+
]
|
|
93
|
+
future-annotations = true
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
[tool.check-sdist]
|
|
97
|
+
sdist-only = [ "pyproject.toml.orig" ]
|
|
98
|
+
git-only = [
|
|
99
|
+
".gitignore",
|
|
100
|
+
".license-tools-config.json",
|
|
101
|
+
".rumdl.toml",
|
|
102
|
+
"CHANGELOG.md",
|
|
103
|
+
"UPGRADING.md",
|
|
104
|
+
"uv.lock",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
[tool.pyproject-fmt]
|
|
109
|
+
generate_python_version_classifiers = false
|
|
110
|
+
table_format = "long"
|
|
111
|
+
sub_table_spacing = "\n"
|
|
112
|
+
separate_root_table = "\n\n"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
[tool.ty.terminal]
|
|
116
|
+
# Error if ty emits any warning-level diagnostics.
|
|
117
|
+
error-on-warning = true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright (c) 2026 Munich Quantum Software Company GmbH
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
"""Common session functions."""
|
|
19
|
+
|
|
20
|
+
from ._sessions import docs, lint, minimums, qiskit, stubs, tests
|
|
21
|
+
|
|
22
|
+
__all__ = ["docs", "lint", "minimums", "qiskit", "stubs", "tests"]
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Copyright (c) 2026 Munich Quantum Software Company GmbH
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
"""Sessions for Python projects using uv dependency groups."""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import shutil
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import TYPE_CHECKING
|
|
25
|
+
|
|
26
|
+
import nox
|
|
27
|
+
from mqt.nox import utils
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
from collections.abc import Sequence
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def lint(session: nox.Session) -> None:
|
|
34
|
+
"""Run all prek hooks, forwarding the session arguments."""
|
|
35
|
+
if shutil.which("prek") is None:
|
|
36
|
+
session.install("prek")
|
|
37
|
+
session.run("prek", "run", "--all-files", *session.posargs, external=True)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def tests(
|
|
41
|
+
session: nox.Session,
|
|
42
|
+
*,
|
|
43
|
+
build_isolation: bool = True,
|
|
44
|
+
install_args: Sequence[str] = (),
|
|
45
|
+
pytest_args: Sequence[str] = (),
|
|
46
|
+
extra_deps: Sequence[str] = (),
|
|
47
|
+
) -> None:
|
|
48
|
+
"""Install the test group and run ``pytest`` with optional dependency overrides.
|
|
49
|
+
|
|
50
|
+
``install_args`` go to uv sync. ``pytest_args`` precede session.posargs. ``extra_deps`` are installed after
|
|
51
|
+
synchronization, e.g., an upstream SDK. The test group must include ``pytest-cov`` for coverage.
|
|
52
|
+
"""
|
|
53
|
+
utils.install(session, build_isolation=build_isolation, groups=["test"], install_args=install_args)
|
|
54
|
+
utils.run_pytest(session, pytest_args=pytest_args, extra_deps=extra_deps)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def qiskit(
|
|
58
|
+
session: nox.Session,
|
|
59
|
+
*,
|
|
60
|
+
build_isolation: bool = True,
|
|
61
|
+
install_args: Sequence[str] = (),
|
|
62
|
+
pytest_args: Sequence[str] = (),
|
|
63
|
+
) -> None:
|
|
64
|
+
"""Test against Qiskit's main branch after installing the locked baseline."""
|
|
65
|
+
tests(
|
|
66
|
+
session,
|
|
67
|
+
build_isolation=build_isolation,
|
|
68
|
+
install_args=install_args,
|
|
69
|
+
pytest_args=pytest_args,
|
|
70
|
+
extra_deps=["qiskit[qasm3-import] @ git+https://github.com/Qiskit/qiskit.git"],
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def minimums(
|
|
75
|
+
session: nox.Session,
|
|
76
|
+
*,
|
|
77
|
+
build_isolation: bool = True,
|
|
78
|
+
install_args: Sequence[str] = (),
|
|
79
|
+
pytest_args: Sequence[str] = (),
|
|
80
|
+
) -> None:
|
|
81
|
+
"""Test lowest direct dependencies without reading or changing uv.lock.
|
|
82
|
+
|
|
83
|
+
With ``build_isolation=False``, install the ``build`` and ``test`` groups before building the project.
|
|
84
|
+
Read the package name from ``project.name`` in pyproject.toml. ``install_args`` are passed to uv pip install.
|
|
85
|
+
"""
|
|
86
|
+
install_command = [
|
|
87
|
+
"uv",
|
|
88
|
+
"pip",
|
|
89
|
+
"install",
|
|
90
|
+
"--upgrade",
|
|
91
|
+
"--resolution=lowest-direct",
|
|
92
|
+
*(["--group", "build"] if not build_isolation else []),
|
|
93
|
+
"--group",
|
|
94
|
+
"test",
|
|
95
|
+
]
|
|
96
|
+
if not build_isolation:
|
|
97
|
+
package = nox.project.load_toml()["project"]["name"]
|
|
98
|
+
utils.prepare_build_env(session)
|
|
99
|
+
session.run(*install_command, *install_args)
|
|
100
|
+
install_args = ["--no-build-isolation-package", package, *install_args]
|
|
101
|
+
session.run(
|
|
102
|
+
*install_command,
|
|
103
|
+
"--editable",
|
|
104
|
+
".",
|
|
105
|
+
*install_args,
|
|
106
|
+
)
|
|
107
|
+
utils.run_pytest(session, pytest_args=["-Wdefault", *pytest_args])
|
|
108
|
+
session.run("uv", "pip", "tree")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def docs(
|
|
112
|
+
session: nox.Session,
|
|
113
|
+
*,
|
|
114
|
+
build_isolation: bool = True,
|
|
115
|
+
install_args: Sequence[str] = (),
|
|
116
|
+
sphinx_args: Sequence[str] = (),
|
|
117
|
+
) -> None:
|
|
118
|
+
"""Install the docs group and build or serve Sphinx documentation."""
|
|
119
|
+
utils.install(session, build_isolation=build_isolation, groups=["docs"], install_args=install_args)
|
|
120
|
+
utils.run_sphinx(session, sphinx_args=sphinx_args)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def stubs(
|
|
124
|
+
session: nox.Session,
|
|
125
|
+
*,
|
|
126
|
+
modules: Sequence[str],
|
|
127
|
+
output_dir: str | Path | None = None,
|
|
128
|
+
stubgen_args: Sequence[str] = (),
|
|
129
|
+
) -> None:
|
|
130
|
+
"""Generate nanobind stubs and format them.
|
|
131
|
+
|
|
132
|
+
The ``build`` group must include nanobind. ``modules`` contains Python import names, e.g., ``mqt.qmap.sc``.
|
|
133
|
+
MQT distribution names such as ``mqt-qmap`` determine the default output directory, e.g., ``python/mqt/qmap``.
|
|
134
|
+
Extra arguments go to nanobind.stubgen.
|
|
135
|
+
"""
|
|
136
|
+
if not modules:
|
|
137
|
+
session.error("At least one nanobind module is required")
|
|
138
|
+
package = nox.project.load_toml()["project"]["name"]
|
|
139
|
+
module_prefix = package.replace("-", ".")
|
|
140
|
+
utils.install(session, build_isolation=False)
|
|
141
|
+
output_dir = Path(output_dir) if output_dir is not None else Path("python", *module_prefix.split("."))
|
|
142
|
+
session.run(
|
|
143
|
+
"python",
|
|
144
|
+
"-m",
|
|
145
|
+
"nanobind.stubgen",
|
|
146
|
+
"--recursive",
|
|
147
|
+
"--include-private",
|
|
148
|
+
"--output-dir",
|
|
149
|
+
output_dir,
|
|
150
|
+
*(arg for module in modules for arg in ["--module", module]),
|
|
151
|
+
*stubgen_args,
|
|
152
|
+
*session.posargs,
|
|
153
|
+
)
|
|
154
|
+
utils.format_stubs(session, sorted(output_dir.rglob("*.pyi")))
|
|
File without changes
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Copyright (c) 2026 Munich Quantum Software Company GmbH
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
"""Reusable operations for custom Nox sessions."""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import argparse
|
|
23
|
+
import shutil
|
|
24
|
+
from typing import TYPE_CHECKING
|
|
25
|
+
|
|
26
|
+
import nox
|
|
27
|
+
|
|
28
|
+
if TYPE_CHECKING:
|
|
29
|
+
from collections.abc import Sequence
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def prepare_build_env(session: nox.Session) -> None:
|
|
34
|
+
"""Ensure CMake and Ninja are available."""
|
|
35
|
+
if shutil.which("cmake") is None:
|
|
36
|
+
session.install("cmake")
|
|
37
|
+
if shutil.which("ninja") is None:
|
|
38
|
+
session.install("ninja")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def install(
|
|
42
|
+
session: nox.Session,
|
|
43
|
+
*,
|
|
44
|
+
build_isolation: bool = True,
|
|
45
|
+
groups: Sequence[str] = (),
|
|
46
|
+
install_args: Sequence[str] = (),
|
|
47
|
+
) -> None:
|
|
48
|
+
"""Install the project and selected groups from the lockfile.
|
|
49
|
+
|
|
50
|
+
With ``build_isolation=False``, install the ``build`` group and build the project in the session environment.
|
|
51
|
+
Read the package name from ``project.name`` in pyproject.toml. Additional ``install_args`` are passed to uv sync.
|
|
52
|
+
"""
|
|
53
|
+
if not build_isolation:
|
|
54
|
+
package = nox.project.load_toml()["project"]["name"]
|
|
55
|
+
prepare_build_env(session)
|
|
56
|
+
groups = ["build", *groups]
|
|
57
|
+
install_args = ["--no-build-isolation-package", package, *install_args]
|
|
58
|
+
session.run(
|
|
59
|
+
"uv",
|
|
60
|
+
"sync",
|
|
61
|
+
"--locked",
|
|
62
|
+
"--inexact",
|
|
63
|
+
"--no-dev",
|
|
64
|
+
*(arg for group in groups for arg in ["--group", group]),
|
|
65
|
+
*install_args,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def run_pytest(session: nox.Session, *, pytest_args: Sequence[str] = (), extra_deps: Sequence[str] = ()) -> None:
|
|
70
|
+
"""Apply dependency overrides after synchronization, then run ``pytest`` directly.
|
|
71
|
+
|
|
72
|
+
``pytest_args`` contains ``pytest`` command-line arguments, including test paths. These precede session.posargs.
|
|
73
|
+
"""
|
|
74
|
+
if extra_deps:
|
|
75
|
+
# Sync can restore locked versions even when Nox runs with --no-install.
|
|
76
|
+
session.run("uv", "pip", "install", *extra_deps)
|
|
77
|
+
session.run("uv", "pip", "freeze")
|
|
78
|
+
session.run("pytest", *pytest_args, *session.posargs, "--cov-config=pyproject.toml")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def run_sphinx(session: nox.Session, *, sphinx_args: Sequence[str] = ()) -> None:
|
|
82
|
+
"""Build docs from an already prepared environment.
|
|
83
|
+
|
|
84
|
+
Accept ``-b <builder>`` in session arguments and forward the remaining arguments to Sphinx. Serve HTML builds only
|
|
85
|
+
in interactive sessions.
|
|
86
|
+
"""
|
|
87
|
+
parser = argparse.ArgumentParser()
|
|
88
|
+
parser.add_argument("-b", dest="builder", default="html", help="Build target (default: html)")
|
|
89
|
+
args, posargs = parser.parse_known_args(session.posargs)
|
|
90
|
+
serve = args.builder == "html" and session.interactive
|
|
91
|
+
if serve:
|
|
92
|
+
session.install("sphinx-autobuild")
|
|
93
|
+
session.run(
|
|
94
|
+
"sphinx-autobuild" if serve else "sphinx-build",
|
|
95
|
+
"-n",
|
|
96
|
+
"-T",
|
|
97
|
+
f"-b={args.builder}",
|
|
98
|
+
"docs",
|
|
99
|
+
f"docs/_build/{args.builder}",
|
|
100
|
+
*sphinx_args,
|
|
101
|
+
*posargs,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def format_stubs(session: nox.Session, files: Sequence[Path]) -> None:
|
|
106
|
+
"""Apply the MQT stub hooks and verify the final Ruff result."""
|
|
107
|
+
if not files:
|
|
108
|
+
session.warn("No .pyi files found")
|
|
109
|
+
return
|
|
110
|
+
if shutil.which("prek") is None:
|
|
111
|
+
session.install("prek")
|
|
112
|
+
for hook in ["license-tools", "ruff-check", "ruff-format"]:
|
|
113
|
+
session.run("prek", "run", hook, "--files", *files, external=True, success_codes=[0, 1])
|
|
114
|
+
session.run("prek", "run", "ruff-check", "--files", *files, external=True)
|