Skip to content

Commit

Permalink
Merge pull request #279 from imageworks/remove-pyo3
Browse files Browse the repository at this point in the history
Remove Usage of pyo3
  • Loading branch information
rydrman authored Apr 13, 2022
2 parents c4a47e0 + 251f17c commit fe9f7c3
Show file tree
Hide file tree
Showing 51 changed files with 212 additions and 3,295 deletions.
160 changes: 1 addition & 159 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ indexmap = "1.7.0"
itertools = "0.9"
lazy_static = "1.4.0"
once_cell = "1.8.0"
pyo3 = { version = "0.14.1", features = ["hashbrown", "auto-initialize"] }
regex = "1.5.4"
relative-path = "1.3.2"
ring = "0.16.15"
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ clean: packages.clean
.PHONY: lint lint-rust
lint: lint-rust
lint-rust:
# we need to ingore this clippy warning until the next
# release of py03 which solves for it
cargo clippy -- -Dwarnings -Aclippy::needless_option_as_deref
cargo clippy

.PHONY: format
format:
Expand All @@ -32,7 +30,7 @@ format:
.PHONY: test test-rust
test: test-rust
test-rust:
spfs run - -- cargo test --no-default-features
spfs run - -- cargo test

converters:
$(MAKE) -C packages spk-convert-pip/spk-convert-pip.spk
Expand Down
20 changes: 0 additions & 20 deletions src/api/build_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::collections::HashSet;

use itertools::Itertools;
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};

use super::{Compatibility, Opt, OptionMap, ValidationSpec};
Expand All @@ -14,16 +13,12 @@ use super::{Compatibility, Opt, OptionMap, ValidationSpec};
mod build_spec_test;

/// A set of structured inputs used to build a package.
#[pyclass]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize)]
pub struct BuildSpec {
#[pyo3(get, set)]
pub script: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[pyo3(get, set)]
pub options: Vec<Opt>,
#[serde(default, skip_serializing_if = "BuildSpec::is_default_variants")]
#[pyo3(get, set)]
pub variants: Vec<OptionMap>,
#[serde(default, skip_serializing_if = "ValidationSpec::is_default")]
pub validation: ValidationSpec,
Expand Down Expand Up @@ -51,17 +46,6 @@ impl BuildSpec {
}
variants.get(0) == Some(&OptionMap::default())
}
}

#[pymethods]
impl BuildSpec {
#[new]
fn init(options: Vec<Opt>) -> Self {
Self {
options,
..Self::default()
}
}

pub fn resolve_all_options(&self, package_name: Option<&str>, given: &OptionMap) -> OptionMap {
let mut resolved = OptionMap::default();
Expand All @@ -83,10 +67,6 @@ impl BuildSpec {
resolved
}

fn to_dict(&self, py: Python) -> PyResult<Py<pyo3::types::PyDict>> {
super::python::to_dict(self, py)
}

/// Validate the given options against the options in this spec.
pub fn validate_options(&self, package_name: &str, given_options: &OptionMap) -> Compatibility {
let mut must_exist = given_options.package_options_without_global(&package_name);
Expand Down
6 changes: 0 additions & 6 deletions src/api/component_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://github.com/imageworks/spk
use std::convert::{TryFrom, TryInto};

use pyo3::prelude::*;
use serde::{Deserialize, Serialize};

use crate::{Error, Result};
Expand All @@ -13,20 +12,15 @@ use crate::{Error, Result};
mod component_spec_test;

/// Defines a named package component.
#[pyclass]
#[derive(Debug, Hash, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ComponentSpec {
#[pyo3(get, set)]
pub name: Component,
#[serde(default)]
pub files: FileMatcher,
#[pyo3(get, set)]
#[serde(default)]
pub uses: Vec<Component>,
#[pyo3(get, set)]
#[serde(default)]
pub requirements: super::RequirementsList,
#[pyo3(get, set)]
#[serde(default)]
pub embedded: super::EmbeddedPackagesList,
}
Expand Down
13 changes: 0 additions & 13 deletions src/api/component_spec_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://github.com/imageworks/spk
use std::collections::{HashMap, HashSet};

use pyo3::prelude::*;
use serde::{Deserialize, Serialize};

use super::{Component, ComponentSpec};
Expand Down Expand Up @@ -129,15 +128,3 @@ impl<'de> Deserialize<'de> for ComponentSpecList {
Ok(ComponentSpecList(unchecked))
}
}

impl IntoPy<Py<pyo3::types::PyAny>> for ComponentSpecList {
fn into_py(self, py: Python) -> Py<pyo3::types::PyAny> {
self.0.into_py(py)
}
}

impl<'source> FromPyObject<'source> for ComponentSpecList {
fn extract(ob: &'source PyAny) -> PyResult<Self> {
Ok(ComponentSpecList(Vec::<ComponentSpec>::extract(ob)?))
}
}
13 changes: 0 additions & 13 deletions src/api/embedded_packages_list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2021 Sony Pictures Imageworks, et al.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/imageworks/spk
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};

use super::{Build, BuildSpec, InstallSpec, Spec};
Expand Down Expand Up @@ -65,15 +64,3 @@ impl<'de> Deserialize<'de> for EmbeddedPackagesList {
Ok(EmbeddedPackagesList(unchecked))
}
}

impl IntoPy<Py<pyo3::types::PyAny>> for EmbeddedPackagesList {
fn into_py(self, py: Python) -> Py<pyo3::types::PyAny> {
self.0.into_py(py)
}
}

impl<'source> FromPyObject<'source> for EmbeddedPackagesList {
fn extract(ob: &'source PyAny) -> PyResult<Self> {
Ok(EmbeddedPackagesList(Vec::<Spec>::extract(ob)?))
}
}
Loading

0 comments on commit fe9f7c3

Please sign in to comment.