diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 936be05..138ad0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,6 @@ jobs: latest=$(git tag -l | tail -1) cargo_v=$(grep -m 1 -oP 'version = "(.*)"' Cargo.toml | sed -rn 's/.*"(.*)"/v\1/p') pyproject_v=$(grep -m 1 -oP 'version = "(.*)"' pyproject.toml | sed -rn 's/.*"(.*)"/v\1/p') - setup_v=$(grep -m 1 -oP 'version="(.*)"' setup.py | sed -rn 's/.*"(.*)"/v\1/p') if [ ! $latest = $cargo_v ]; then echo "Latest tag doesnt match Cargo.toml version - failing build." @@ -21,11 +20,9 @@ jobs: elif [ ! $latest = $pyproject_v ]; then echo "Latest tag doesnt match pyproject.toml version - failing build." exit 1 - elif [ ! $latest = $setup_v ]; then - echo "Latest tag doesnt match setup.py version - failing build." - exit 1 fi + echo "Tags match: $latest" exit 0 build: @@ -91,7 +88,7 @@ jobs: rustup default stable && rustup show CIBW_BEFORE_BUILD_LINUX: > - pip install -U setuptools-rust && + python -m pip install -U setuptools-rust && curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && rustup show diff --git a/Cargo.toml b/Cargo.toml index 4c00fb1..793121b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "piston_rspy" description = "Python bindings for piston_rs." -version = "0.3.0" +version = "0.3.1" edition = "2021" authors = ["Jonxslays"] readme = "README.md" @@ -17,7 +17,7 @@ name = "piston_rspy" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.14", features = ["extension-module"] } -pyo3-asyncio = { version = "0.14", features = ["tokio-runtime"] } +pyo3 = { version = "0.15", features = ["extension-module"] } +pyo3-asyncio = { version = "0.15", features = ["tokio-runtime"] } tokio = { version = "1" } piston_rs = "^0.4.0" diff --git a/pyproject.toml b/pyproject.toml index dd0e2b3..49d1bcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,11 @@ [project] name = "piston_rspy" -version = "0.3.0" +version = "0.3.1" description = "Python bindings for piston_rs." readme = "README.md" -documentation = "https://jonxslays.github.io/piston_rspy/piston_rspy/" +author = "Jonxslays" +documentation = "https://jonxslays.github.io/piston_rspy/piston_rspy" +issue-tracker = "https://github.com/Jonxslays/piston_rspy/issues" repository = "https://github.com/Jonxslays/piston_rspy" url = "https://github.com/Jonxslays/piston_rspy" requires-python = ">=3.7,<3.11" diff --git a/setup.py b/setup.py index e35d5f1..500c41b 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,7 @@ +from __future__ import annotations + +import typing + from setuptools import setup from setuptools_rust import Binding, RustExtension, Strip # type: ignore @@ -7,19 +11,32 @@ with open("README.md") as r: long_description = r.read() +with open("pyproject.toml") as f: + meta: dict[str, typing.Any] = {} + + for line in f.readlines(): + if line.startswith("\n"): + break + + if line.startswith("[project]"): + continue + + k, v = line.split(" = ") + meta[k] = v.strip().replace("\"", "") + setup( - name="piston_rspy", - version="0.3.0", - description="Python bindings for piston_rs.", - author="Jonxslays", + name=meta["name"], + version=meta["version"], + description=meta["description"], + author=meta["author"], long_description=long_description, long_description_content_type="text/markdown", license="MIT", - url="https://github.com/Jonxslays/piston_rspy", + url=meta["url"], project_urls={ - "Documentation": "https://jonxslays.github.io/piston_rspy/piston_rspy", - "Source": "https://github.com/Jonxslays/piston_rspy", - "Bug Tracker": "https://github.com/Jonxslays/piston_rspy/issues", + "Documentation":meta["documentation"], + "Source": meta["repository"], + "Bug Tracker": meta["issue-tracker"], }, classifiers=[ "Development Status :: 3 - Alpha", diff --git a/src/client.rs b/src/client.rs index 0d8316d..b8138f9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,5 +1,4 @@ use pyo3::prelude::*; -use pyo3::types::PyList; use pyo3::PyObjectProtocol; use std::collections::HashMap; @@ -121,22 +120,23 @@ impl Client { fn fetch_runtimes<'a>(&self, py: Python<'a>) -> PyResult<&'a PyAny> { let client = self.inner.clone(); - pyo3_asyncio::tokio::future_into_py(py, async move { - match client.fetch_runtimes().await { - Ok(runtimes) => Ok(Python::with_gil(|py| { - PyList::new( - py, + pyo3_asyncio::tokio::future_into_py_with_locals::<_, Vec>( + py, + pyo3_asyncio::tokio::get_current_locals(py)?, + async move { + match client.fetch_runtimes().await { + Ok(runtimes) => Ok(Python::with_gil(|_| { runtimes .iter() - .map(|r| Runtime::from_runtime(r.to_owned()).into_py(py)), - ) - .into() - })), - Err(e) => Err(Python::with_gil(|_| { - pyo3::exceptions::PyRuntimeError::new_err(format!("{:?}", e)) - })), - } - }) + .map(|r| Runtime::from_runtime(r.to_owned())) + .collect() + })), + Err(e) => Err(Python::with_gil(|_| { + pyo3::exceptions::PyRuntimeError::new_err(format!("{:?}", e)) + })), + } + }, + ) } /// **async**: Executes code using a given executor. This is an http request. @@ -160,9 +160,7 @@ impl Client { pyo3_asyncio::tokio::future_into_py(py, async move { match client.execute(&exec).await { - Ok(response) => Ok(Python::with_gil(|py| { - ExecResponse::from_response(response).into_py(py) - })), + Ok(response) => Ok(Python::with_gil(|_| ExecResponse::from_response(response))), Err(e) => Err(Python::with_gil(|_| { pyo3::exceptions::PyRuntimeError::new_err(format!("{:?}", e)) })),