-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from torqs-project/cleanup-for-pip
Cleanup for pip
- Loading branch information
Showing
14 changed files
with
268 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/q8s # Replace <package-name> with your PyPI project name | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: >- | ||
gh release create | ||
'${{ github.ref_name }}' | ||
--repo '${{ github.repository }}' | ||
--notes "" | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' | ||
publish-to-testpypi: | ||
name: Publish Python 🐍 distribution 📦 to TestPyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/q8s | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
skip-existing: true | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
[project] | ||
name = "q8s_kernel" | ||
name = "q8s" | ||
version = "0.1.0" | ||
description = "Kernel extension for executing quantum programs in simulators on q8s clusters" | ||
authors = [{ name = "Vlad Stirbu", email = "[email protected]" }] | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
keywords = ["jupyter", "quantum", "kernel"] | ||
classifiers = [ | ||
"Development status :: 3 - Alpha", | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
dependencies = [ | ||
"stdlib-list==0.10.0", | ||
"ipython==8.17.2", | ||
# "stdlib-list==0.10.0", | ||
# "ipython==8.17.2", | ||
"ipykernel==6.26.0", | ||
"kubernetes==29.0.0", | ||
"notebook==7.0.6", | ||
"python_on_whales==0.70.0", | ||
# "notebook==7.0.6", | ||
# "python_on_whales==0.70.0", | ||
"python-dotenv==1.0.1", | ||
"typer==0.12.3", | ||
] | ||
requires-python = ">= 3.8" | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/torqs-project/q8s-kernel" | ||
Issues = "https://github.com/torqs-project/q8s-kernel/issues" | ||
|
||
[build-system] | ||
requires = ["setuptools >= 61.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
@@ -34,4 +42,4 @@ benchmark = ["pandas", "testbook", "mlflow"] | |
development = ["pyre-check"] | ||
|
||
[project.scripts] | ||
q8sctl = "q8s_kernel.cli:app" | ||
q8sctl = "q8s.cli:app" |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import json | ||
import os | ||
import sys | ||
import argparse | ||
import pathlib | ||
import shutil | ||
|
||
from jupyter_client.kernelspec import KernelSpecManager | ||
from IPython.utils.tempdir import TemporaryDirectory | ||
|
||
# from .resources import _ICON_PATH | ||
|
||
kernel_json = { | ||
"argv": [sys.executable, "-m", "q8s", "-f", "{connection_file}"], | ||
"display_name": "Q8s kernel", | ||
"language": "python", | ||
} | ||
|
||
|
||
def install_my_kernel_spec(user=True, prefix=None): | ||
with TemporaryDirectory() as td: | ||
os.chmod(td, 0o755) # Starts off as 700, not user readable | ||
with open(os.path.join(td, "kernel.json"), "w") as f: | ||
json.dump(kernel_json, f, sort_keys=True) | ||
# shutil.copyfile(_ICON_PATH, pathlib.Path(td) / _ICON_PATH.name) | ||
print("Installing q8s kernel spec") | ||
KernelSpecManager().install_kernel_spec(td, "q8s", user=user, prefix=prefix) | ||
|
||
|
||
def _is_root(): | ||
try: | ||
return os.geteuid() == 0 | ||
except AttributeError: | ||
return False # assume not an admin on non-Unix platforms | ||
|
||
|
||
def main(argv=None): | ||
parser = argparse.ArgumentParser( | ||
description="Install KernelSpec for Qubernetes Kernel" | ||
) | ||
prefix_locations = parser.add_mutually_exclusive_group() | ||
|
||
prefix_locations.add_argument( | ||
"--user", | ||
help="Install KernelSpec in user's home directory", | ||
action="store_true", | ||
) | ||
prefix_locations.add_argument( | ||
"--sys-prefix", | ||
help="Install KernelSpec in sys.prefix. Useful in conda / virtualenv", | ||
action="store_true", | ||
dest="sys_prefix", | ||
) | ||
prefix_locations.add_argument( | ||
"--prefix", help="Install KernelSpec in this prefix", default=None | ||
) | ||
|
||
args = parser.parse_args(argv) | ||
|
||
user = False | ||
prefix = None | ||
if args.sys_prefix: | ||
prefix = sys.prefix | ||
elif args.prefix: | ||
prefix = args.prefix | ||
elif args.user or not _is_root(): | ||
user = True | ||
|
||
install_my_kernel_spec(user=user, prefix=prefix) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters