Skip to content

Commit

Permalink
Add python 3.10 support (#14)
Browse files Browse the repository at this point in the history
* Add python 3.10 support

* Fix event loop
  • Loading branch information
MrNaif2018 committed Oct 12, 2021
1 parent 240baf8 commit b29f33c
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 65 deletions.
47 changes: 6 additions & 41 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: 2.1

orbs:
bitcartcc: bitcartcc/bitcartcc-shared@1

executors:
main-executor:
parameters:
Expand Down Expand Up @@ -45,46 +48,6 @@ commands:
path: test-results

jobs:
lint:
docker:
- image: cimg/python:3.7

working_directory: ~/repo

steps:
- checkout

- restore_cache:
keys:
- v1-lint-dependencies-{{ .Branch }}-{{ checksum "~/.pyenv/version" }}-{{ checksum "test-requirements.txt" }}

- restore_cache:
keys:
- v1-lint-pre-commit-{{ .Branch }}-{{ checksum ".pre-commit-config.yaml" }}

- run:
name: install dependencies
command: |
virtualenv ~/venv
echo ". ~/venv/bin/activate" >> $BASH_ENV
source $BASH_ENV
pip install -U -r test-requirements.txt
- save_cache:
paths:
- ~/venv
key: v1-lint-dependencies-{{ .Branch }}-{{ checksum "~/.pyenv/version" }}-{{ checksum "test-requirements.txt" }}

- run:
name: run pre-commit checks
command: |
pre-commit run --all-files --show-diff-on-failure
- save_cache:
paths:
- ~/.cache/pre-commit
key: v1-lint-pre-commit-{{ .Branch }}-{{ checksum ".pre-commit-config.yaml" }}

test:
parameters:
v:
Expand Down Expand Up @@ -139,7 +102,8 @@ workflows:
version: 2
build_and_test:
jobs:
- lint
- bitcartcc/lint:
name: lint
- test:
name: test-<< matrix.v >>
requires:
Expand All @@ -150,6 +114,7 @@ workflows:
- "3.7"
- "3.8"
- "3.9"
- "3.10"

- deploy:
context: global
Expand Down
9 changes: 0 additions & 9 deletions .coveragerc

This file was deleted.

4 changes: 0 additions & 4 deletions setup.cfg → .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ max-complexity=10
max-line-length=127
ignore=E266 # for code sections as comments
E203, W503 # black compatibility

[isort]
profile=black
line_length = 127
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Latest changes

## 0.1.1

Python 3.10 support

## 0.1.0

Better, safer compiler by using RestrictedPython
Expand Down
9 changes: 8 additions & 1 deletion bitccl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ def signal_handler(signum, frame):
signal.alarm(0)


def get_event_loop(): # TODO: remove this when we support asyncio.run everywhere
try:
return asyncio.get_running_loop()
except RuntimeError:
return asyncio.get_event_loop_policy().get_event_loop()


def call_universal(func, *args, **kwargs):
result = func(*args, **kwargs)
if inspect.isawaitable(result):
result = asyncio.get_event_loop().run_until_complete(result)
result = get_event_loop().run_until_complete(result)
return result


Expand Down
2 changes: 1 addition & 1 deletion bitccl/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.1.0"
VERSION = "0.1.1"
28 changes: 27 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
[tool.black]
line-length=127
line-length = 127

[tool.isort]
profile = "black"
line_length = 127

[tool.pytest.ini_options]
addopts = [
"--cov=bitccl",
"--cov-report",
"term-missing"
]
filterwarnings = [
"error::DeprecationWarning",
"error::PendingDeprecationWarning"
]

[tool.coverage.run]
source = ["."]
omit = [
"tests/*",
"venv/*",
"env/*",
"bitccl/cli.py",
"bitccl/logger.py",
"setup.py"
]
5 changes: 0 additions & 5 deletions pytest.ini

This file was deleted.

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

with open("requirements.txt") as requirements_file:
requirements = requirements_file.read()

setup(
author="MrNaif2018",
author_email="chuff184@gmail.com",
Expand All @@ -25,6 +26,7 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
description="The BitCCL scripting language compiler package",
entry_points={"console_scripts": ["bitccl=bitccl.cli:main"]},
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
black
codecov
flake8
isort>=5
isort
pre-commit
pytest
pytest-cov
Expand Down
5 changes: 3 additions & 2 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from bitccl import run
from bitccl.compiler import compile_restricted, events, functions
from bitccl.exceptions import CompilationRestrictedError
from bitccl.utils import get_event_loop

CLASS_TEST = """
class Test:
Expand Down Expand Up @@ -69,7 +70,7 @@ async def func2():
global run
run = True
asyncio.get_event_loop().run_until_complete(func())
get_event_loop().run_until_complete(func())
assert run
"""

Expand Down Expand Up @@ -140,7 +141,7 @@ def test_call_args_kwargs():
def test_async_support_works():
class AsyncioPlugin:
def startup(self):
return {"asyncio": asyncio, "contextlib": contextlib}
return {"asyncio": asyncio, "contextlib": contextlib, "get_event_loop": get_event_loop}

def shutdown(self, context):
pass
Expand Down

0 comments on commit b29f33c

Please sign in to comment.