Skip to content

Commit

Permalink
fix python 3.10 bug by updating dependencies(#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 authored Jun 22, 2022
1 parent ddc5328 commit 9424c9d
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 37 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_executable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
workflow_dispatch:

env:
default-python: 3.9
default-python: "3.10"

jobs:
build-executable:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]
python-version: ["3.10"]
node-version: [12.x]
include:
- os: macos-latest
python-version: 3.9
python-version: "3.10"
node-version: 12.x
buildname: "mac"
- os: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
push:

env:
default-python: 3.9
default-python: "3.10"

jobs:
python-lint:
Expand All @@ -25,18 +25,18 @@ jobs:
python -m pip install nox
- name: Lint
run: |
nox --error-on-missing-interpreters --non-interactive --session lint
nox --error-on-missing-interpreters --non-interactive --session lint-${{ env.default-python }}
run-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]
python-version: ["3.10"]
node-version: [12.x]
include:
- os: macos-latest
python-version: 3.9
python-version: "3.10"
node-version: 12.x

steps:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.1.5

- Update dependencies to fix a Python 3.10 incompatibility

## 0.3.1.4

- Show user a clear error if the browser is not running in a secure context
Expand Down
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,35 @@ Install [nox](https://pypi.org/project/nox/).
You can run the server from source with:

```
nox -s serve-3.9
nox -s serve-3.10
```

### Terminal Client

Install [nox](https://pypi.org/project/nox/).

You can run the terminal client from source with:

```
nox -s share-3.9
nox -s share-3.10
```

You can pass additional arguments like this

```
nox -s share-3.9 -- <arguments>
nox -s share-3.10 -- <arguments>
```

### Frontend Web App

First, get [yarn](https://yarnpkg.com/en/).

Next go to the directory `termpair/frontend_src` and run

```bash
yarn install
```

to install dependencies.

You can run the development server and hot reload changes. This is the easiest way to quickly statically serve the app from source.
Expand All @@ -51,17 +55,21 @@ To build the production code, run:
```bash
yarn build
```

The static web app will be compiled to `termpair/termpair_build/`. TermPair will then serve this with `nox -s serve`.

You can also serve locally with

```
$ cd termpair/termpair/frontend_build
$ python3 -m http.server 7999 --bind 127.0.0.1
# Serves at http://127.0.01:7999
```

or deploy to GitHub pages, Vercel, etc.

## Releasing new versions to PyPI

```
nox -s publish
```
Expand Down
11 changes: 10 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import nox # type: ignore


python = ["3.8", "3.9"]
python = ["3.10"]
nox.options.sessions = ["lint"]
nox.options.reuse_existing_virtualenvs = True

Expand All @@ -20,20 +20,23 @@

@nox.session(python=python)
def serve(session):
"""Install and run termpair serve <posargs>"""
print("Note: Frontend must be built for this to work")
session.install("-e", ".")
session.run("termpair", "serve", *session.posargs)


@nox.session(python=python)
def share(session):
"""Install and run 'termpair share <posargs>'"""
print("Note: Frontend must be built for this to work")
session.install("-e", ".")
session.run("termpair", "share", *session.posargs)


@nox.session(python=python)
def watch_docs(session):
"""Build mkdocs, run server, and watch for changes"""
session.install(*doc_deps)
session.run("mkdocs", "serve")

Expand All @@ -53,12 +56,14 @@ def build_executable(session):

@nox.session()
def publish_docs(session):
"""Run mkdocs gh-deploy"""
session.install(*doc_deps)
session.run("mkdocs", "gh-deploy")


@nox.session()
def publish_static_webapp(session):
"""Build frontend and publish to github pages"""
build_frontend(session)
session.run("git", "checkout", "gh-pages", external=True)
session.run("rm", "-rf", "connect/", external=True)
Expand All @@ -71,6 +76,7 @@ def publish_static_webapp(session):

@nox.session()
def publish(session):
"""Build+Publish to PyPI, docs, and static webapp"""
print("REMINDER: Has the changelog been updated?")
session.run("rm", "-rf", "dist", "build", external=True)
publish_deps = ["setuptools", "wheel", "twine"]
Expand All @@ -84,6 +90,7 @@ def publish(session):

@nox.session(python=python)
def lint(session):
"""Run all lint checks"""
session.install(*lint_deps)
files = ["termpair", "tests"] + [str(p) for p in Path(".").glob("*.py")]
session.run("black", "--check", *files)
Expand All @@ -95,12 +102,14 @@ def lint(session):

@nox.session(python=[python])
def test(session):
"""Run unit tests"""
session.install(".", *test_deps)
# can't use default capture method because termpair requires stdin to have a fileno()
session.run("pytest", "tests", "--capture", "tee-sys", *session.posargs)


@nox.session(python=[python])
def termpair(session):
"""Install termapir and run it with args passed with -- arg1 arg2"""
session.install("-e", ".")
session.run("termpair", *session.posargs)
68 changes: 49 additions & 19 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,54 @@
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile
#
aiofiles==0.7.0 # via -r requirements.in
asgiref==3.3.4 # via uvicorn
cffi==1.14.5 # via cryptography
click==8.0.1 # via uvicorn
cryptography==3.4.7 # via -r requirements.in
fastapi==0.65.1 # via -r requirements.in
h11==0.12.0 # via uvicorn
httptools==0.2.0 # via uvicorn
pycparser==2.20 # via cffi
pydantic==1.8.2 # via fastapi
python-dotenv==0.17.1 # via uvicorn
pyyaml==5.4.1 # via uvicorn
starlette==0.14.2 # via fastapi
typing-extensions==3.10.0.0 # via pydantic
uvicorn[standard]==0.14.0 # via -r requirements.in
uvloop==0.15.2 # via uvicorn
watchgod==0.7 # via uvicorn
websockets==9.1 # via -r requirements.in, uvicorn
aiofiles==0.8.0
# via -r requirements.in
anyio==3.6.1
# via
# starlette
# watchgod
asgiref==3.5.2
# via uvicorn
cffi==1.15.0
# via cryptography
click==8.1.3
# via uvicorn
cryptography==37.0.3
# via -r requirements.in
fastapi==0.78.0
# via -r requirements.in
h11==0.13.0
# via uvicorn
httptools==0.4.0
# via uvicorn
idna==3.3
# via anyio
pycparser==2.21
# via cffi
pydantic==1.9.1
# via fastapi
python-dotenv==0.20.0
# via uvicorn
pyyaml==6.0
# via uvicorn
sniffio==1.2.0
# via anyio
starlette==0.19.1
# via fastapi
typing-extensions==4.2.0
# via
# pydantic
# starlette
uvicorn[standard]==0.17.6
# via -r requirements.in
uvloop==0.16.0
# via uvicorn
watchgod==0.8.2
# via uvicorn
websockets==10.3
# via
# -r requirements.in
# uvicorn
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def get_version():
install_requires=distutils.text_file.TextFile(
filename="./requirements.txt"
).readlines(),
python_requires=">=3.6",
python_requires=">=3.8",
# license and classifier list:
# https://pypi.org/pypi?%3Aaction=list_classifiers
license="License :: OSI Approved :: MIT License",
classifiers=[
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Development Status :: 4 - Beta",
Expand Down
4 changes: 2 additions & 2 deletions termpair/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ class TermPairError(Exception):
pass


# this must match constants.ts
TERMPAIR_VERSION = "0.3.1.4"
# this must match constants.tsx
TERMPAIR_VERSION = "0.3.1.5"
2 changes: 1 addition & 1 deletion termpair/frontend_src/src/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Terminal as Xterm } from "xterm";
// this must match constants.py
export const TERMPAIR_VERSION = "0.3.1.4";
export const TERMPAIR_VERSION = "0.3.1.5";

export const defaultTermpairServer = new URL(
`${window.location.protocol}//${window.location.hostname}:${window.location.port}${window.location.pathname}`
Expand Down
4 changes: 2 additions & 2 deletions termpair/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

max_read_bytes = 1024 * 2
ws_queue: asyncio.Queue = asyncio.Queue()
JS_MAX_SAFE_INTEGER = 2 ** 53 - 1
JS_MAX_SAFE_INTEGER = 2**53 - 1


class AesKeys:
Expand All @@ -33,7 +33,7 @@ class AesKeys:
def __init__(self):
self.bootstrap_message_count = 0
self.message_count = 0
self.message_count_rotation_required = 2 ** 20
self.message_count_rotation_required = 2**20
self.browser_rotation_buffer_count = self.message_count_rotation_required * 0.1
self.secret_bootstrap_key = encryption.aes_generate_secret_key()
self.secret_unix_key = encryption.aes_generate_secret_key()
Expand Down

0 comments on commit 9424c9d

Please sign in to comment.