Skip to content

Commit 5888885

Browse files
authored
project setup (#1)
* project setup * add typing
1 parent 47b2123 commit 5888885

File tree

14 files changed

+455
-1
lines changed

14 files changed

+455
-1
lines changed

.github/workflows/pre-release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Pre-release to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
pypi-publish:
8+
name: Build pre-release dist & upload to PyPI
9+
runs-on: ubuntu-latest
10+
environment: publish
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 1
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install build dependencies
22+
run: python -m pip install -U pip wheel build toml-cli qbraid-core
23+
24+
- name: Build binary wheel + source tarball
25+
id: build-dev
26+
run: |
27+
export PRE_RELEASE_VERSION=$(python tools/stamp_pre_release.py pyqasm)
28+
[[ "$PRE_RELEASE_VERSION" =~ .*(-a\.|-b\.|-rc\.).* ]] && echo "Deploying pre-release version '$PRE_RELEASE_VERSION'" || (echo "not pre-release version"; exit 0)
29+
out_dir="${PWD}/dist"
30+
tools/create_dev_build.sh $PRE_RELEASE_VERSION "${out_dir}"
31+
echo "dir=$out_dir" >> $GITHUB_OUTPUT
32+
33+
- name: Publish pre-release package to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1
35+
with:
36+
user: __token__
37+
password: ${{ secrets.PYPI_API_TOKEN }}
38+
packages-dir: ${{ steps.build-dev.outputs.dir }}

.github/workflows/publish.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
pypi-publish:
10+
name: Build dist & upload to PyPI
11+
runs-on: ubuntu-latest
12+
environment: publish
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 1
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.12'
22+
23+
- name: Build binary wheel + source tarball
24+
run: |
25+
python3 -m pip install --upgrade pip build
26+
python3 -m build
27+
28+
- name: Publish package to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
with:
31+
user: __token__
32+
password: ${{ secrets.PYPI_API_TOKEN }}

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
Types of changes:
8+
- `Added`: for new features.
9+
- `Improved`: for improvements to existing functionality.
10+
- `Deprecated`: for soon-to-be removed features.
11+
- `Removed`: for now removed features.
12+
- `Fixed`: for any bug fixes.
13+
- `Dependencies`: for updates to external libraries or packages.
14+
15+
## [Unreleased]
16+
17+
### Added
18+
19+
### Improved / Modified
20+
21+
### Deprecated
22+
23+
### Removed
24+
25+
### Fixed
26+
27+
### Dependencies

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
contact@qbraid.com.
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Contributing

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include *.txt *.md
2+
recursive-include docs *.rst *.py *.png *.ico *.txt
3+
recursive-include pyqasm *.py
4+
include pyqasm/py.typed
5+
prune docs/build/

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# pyqasm
1+
# pyqasm
2+
3+
Python toolkit providing an OpenQASM 3 semantic analyzer and utilities for program analysis and compilation.

mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[mypy]
2+
ignore_missing_imports = True
3+
incremental = True
4+
show_error_codes = True
5+
follow_imports = normal
6+
cache_dir = .mypy_cache

pyproject.toml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[build-system]
2+
requires = ["setuptools>=61", "setuptools_scm"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pyqasm"
7+
version = "0.0.0"
8+
description = "Python toolkit providing an OpenQASM 3 semantic analyzer and utilities for program analysis and compilation."
9+
authors = [{name = "qBraid Development Team"}, {email = "contact@qbraid.com"}]
10+
readme = "README.md"
11+
requires-python = ">=3.10"
12+
keywords = ["quantum", "openqasm", "symantic-analyzer", "compiler", "qbraid"]
13+
license = {text = "GNU General Public License v3.0"}
14+
classifiers = [
15+
"Development Status :: 1 - Planning",
16+
"Intended Audience :: Developers",
17+
"Intended Audience :: Science/Research",
18+
"Natural Language :: English",
19+
"Programming Language :: Python",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
"Programming Language :: Python :: 3 :: Only",
26+
'Topic :: Software Development',
27+
'Topic :: Scientific/Engineering',
28+
"Topic :: Scientific/Engineering :: Physics",
29+
'Typing :: Typed',
30+
'Operating System :: Microsoft :: Windows',
31+
'Operating System :: POSIX',
32+
'Operating System :: Unix',
33+
'Operating System :: MacOS',
34+
]
35+
dependencies = ["pyqir>=0.10.0,<0.11.0", "numpy"]
36+
37+
[project.urls]
38+
source = "https://github.com/qBraid/pyqasm"
39+
tracker = "https://github.com/qBraid/pyqasm/issues"
40+
41+
[project.optional-dependencies]
42+
test = ["pytest", "pytest-cov", "autoqasm>=0.1.0"]
43+
lint = ["black", "isort", "pylint", "mypy", "qbraid-cli>=0.8.5"]
44+
docs = ["sphinx>=7.3.7,<8.1.0", "sphinx-autodoc-typehints>=1.24,<2.5", "sphinx-rtd-theme~=2.0.0", "docutils<0.22", "sphinx-copybutton"]
45+
46+
[tool.setuptools_scm]
47+
write_to = "pyqasm/_version.py"
48+
49+
[tool.black]
50+
line-length = 100
51+
target-version = ["py310", "py311", "py312"]
52+
53+
[tool.isort]
54+
profile = "black"
55+
multi_line_output = 3
56+
include_trailing_comma = true
57+
force_grid_wrap = 0
58+
use_parentheses = true
59+
line_length = 100
60+
61+
[tool.pylint.'MESSAGES CONTROL']
62+
max-line-length = 100
63+
disable = "C0414,C0415,R0914,W0511"
64+
65+
[tool.pylint.MASTER]
66+
ignore-paths = [
67+
"^.*\\_version.py$",
68+
]
69+
70+
[tool.pytest.ini_options]
71+
addopts = "-ra"
72+
testpaths = ["tests"]

pyqasm/__init__.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (C) 2024 qBraid
2+
#
3+
# This file is part of the qBraid-SDK
4+
#
5+
# The qBraid-SDK is free software released under the GNU General Public License v3
6+
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
7+
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>.
8+
#
9+
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.
10+
11+
"""
12+
Top level module containing the main PyQASM functionality.
13+
14+
.. currentmodule:: pyqasm
15+
16+
Functions
17+
----------
18+
19+
.. autosummary::
20+
:toctree: ../stubs/
21+
22+
validate
23+
24+
Exceptions
25+
-----------
26+
27+
.. autosummary::
28+
:toctree: ../stubs/
29+
30+
PyQasmError
31+
ValidationError
32+
33+
"""
34+
import warnings
35+
36+
try:
37+
# Injected in _version.py during the build process.
38+
from ._version import __version__ # type: ignore
39+
except ImportError:
40+
warnings.warn("Importing 'pyqasm' outside a proper installation.")
41+
__version__ = "dev"
42+
43+
from .exceptions import PyQasmError, ValidationError
44+
from .validate import validate
45+
46+
__all__ = [
47+
"PyQasmError",
48+
"ValidationError",
49+
"validate",
50+
"__version__",
51+
]

0 commit comments

Comments
 (0)