Skip to content

pyo3(get, set) attribute not found when using cfg_attr #1003

Closed
@Waelwindows

Description

@Waelwindows

🐛 Bug Reports

When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.

🌍 Environment

  • Your operating system and version: Arch Linux x86_64 5.7.4-arch1-1
  • Your python version: Python 3.8.3
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: pacman
  • Your Rust version (rustc --version): rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22)
  • Your PyO3 version: 0.10.1
  • Have you tried using latest PyO3 master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?: No

💥 Reproducing

Please provide a minimal working example. This means both the Rust code and the Python.

This compiles

#[cfg_attr(feature="pyo3", pyclass)]
#[derive(Debug, Default)]
pub struct Foo {
    #[pyo3(get, set)]
    bar: bool,
}

However, this doesn't

#[cfg_attr(feature="pyo3", pyclass)]
#[derive(Debug, Default)]
pub struct Foo {
    #[cfg_attr(feature="pyo3", pyo3(get, set))]
    bar: bool,
}

Because it can't find the pyo3 attribute

error: cannot find attribute `pyo3` in this scope
  --> src/material/texture/mod.rs:45:32
   |
45 |     #[cfg_attr(feature="pyo3", pyo3(get, set))]
   |                                ^^^^

Please also write what exact flags are required to reproduce your results.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions