Hi i have this following code:
I have a strong suspicion that this not not related to python
rust:
let svg_string: String;
if std::path::Path::new(&svg).exists() {
let mut svg_data = std::fs::read(svg)
.map_err(|_| "failed to open the provided file")
.unwrap();
if svg_data.starts_with(&[0x1f, 0x8b]) {
svg_data = resvg::usvg::decompress_svgz(&svg_data)
.map_err(|e| e.to_string())
.unwrap();
};
svg_string = std::str::from_utf8(&svg_data).unwrap().to_owned();
} else {
svg_string = svg;
}
def test_path():
path = os.path.join(BASE_DIR, "acid.svg")
base = resvg_py.svg_to_base64()
print(path)
assert base == svg_output
def test_gzip_path():
path = os.path.join(BASE_DIR, "acid.svg.gz")
base = resvg_py.svg_to_base64()
print(path)
assert base == svg_output
This fails in macos.
Here is the log : Merge branch 'master' of https://github.com/baseplate-admin/resvg-py · baseplate-admin/resvg-py@fafc60e · GitHub
Relevant Source :
The problem is with pip itself.
The problem is with pip preferring PYPI over local package in macos. So essentially what i wrote in current package, even if i bumped the version would not be used.
Here is the explaination
opened 11:55AM - 30 Apr 24 UTC
closed 09:27AM - 06 May 24 UTC
Hi i have this following code
rust:
```rust
let svg_string: String;
… if std::path::Path::new(&svg).exists() {
let mut svg_data = std::fs::read(svg)
.map_err(|_| "failed to open the provided file")
.unwrap();
if svg_data.starts_with(&[0x1f, 0x8b]) {
svg_data = resvg::usvg::decompress_svgz(&svg_data)
.map_err(|e| e.to_string())
.unwrap();
};
svg_string = std::str::from_utf8(&svg_data).unwrap().to_owned();
} else {
svg_string = svg;
}
```
python:
```python
def test_path():
path = os.path.join(BASE_DIR, "acid.svg")
base = resvg_py.svg_to_base64()
print(path)
assert base == svg_output
def test_gzip_path():
path = os.path.join(BASE_DIR, "acid.svg.gz")
base = resvg_py.svg_to_base64()
print(path)
assert base == svg_output
```
This fails in `macos` but runs in all other OS.
Here is the log : https://github.com/baseplate-admin/resvg-py/actions/runs/8889901090/job/24409004312
Relevant Source :
* Rust : https://github.com/baseplate-admin/resvg-py/blob/4a89a841138d3297986892e6418c777fb068c140/src/rust/lib.rs#L164-L178
* Python : https://github.com/baseplate-admin/resvg-py/blob/e981e211fccd43cf0581d870e0fdfb3187667023/tests/test_path.py#L1-L22
* Discussion on pyo3: https://github.com/PyO3/pyo3/discussions/4137#discussion-6584195
* Discussion on reddit : https://www.reddit.com/r/learnrust/comments/1cgpe9d/stdpathpathnewexists_with_python_pathlibpath
system
Closed
August 7, 2024, 6:51am
3
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.