Skip to content

Commit

Permalink
Merge pull request #35 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
2.7.2
AngheloAlf authored Dec 15, 2024
2 parents 26810c2 + cb452ec commit fbcc802
Showing 16 changed files with 84 additions and 201 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maturin_upload_pypi.yml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.13'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
@@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.13'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
@@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.13'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
4 changes: 2 additions & 2 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9

- name: Install Dependencies
run: |
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.7.2] - 2024-12-15

### Added

- Prebuilt binaries for Python 3.13.

### Changed

- Python 3.9 or later is now required.
- Bump from Python 3.8 to 3.9.
- Older versions can't be checked on CI anymore, so I prefer to not claim to
support something that may have broken without anybody noticing.
- Nothing really changed. Just the CI tools I was using are refusing to use
any Python version older than this. Sorry if you were affected by this.
- Use newer pyo3 version.
- From 0.20 to 0.23.
- Updated to avoid warnings with newer Rust versions.
- Fix issues introduced by updating pyo3.

## [2.7.1] - 2024-09-25

### Added
@@ -426,6 +445,7 @@ Full changes: <https://github.com/Decompollaborate/mapfile_parser/compare/702a73
- Initial release

[unreleased]: https://github.com/Decompollaborate/mapfile_parser/compare/master...develop
[2.7.2]: https://github.com/Decompollaborate/mapfile_parser/compare/2.7.1...2.7.2
[2.7.1]: https://github.com/Decompollaborate/mapfile_parser/compare/2.7.0...2.7.1
[2.7.0]: https://github.com/Decompollaborate/mapfile_parser/compare/2.6.0...2.7.0
[2.6.0]: https://github.com/Decompollaborate/mapfile_parser/compare/2.5.1...2.6.0
152 changes: 14 additions & 138 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

[package]
name = "mapfile_parser"
version = "2.7.1"
version = "2.7.2"
edition = "2021"
rust-version = "1.65.0"
authors = ["Anghelo Carvajal <angheloalf95@gmail.com>"]
@@ -23,7 +23,7 @@ crate-type = ["cdylib", "staticlib", "rlib"]

[dependencies]
regex = "1.10.2"
pyo3 = { version = "0.20.0", optional = true, features = ["abi3", "abi3-py37"]}
pyo3 = { version = "0.23.2", optional = true, features = ["extension-module"]}
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"], optional = true }

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ If you use a `requirements.txt` file in your repository, then you can add
this library with the following line:

```txt
mapfile_parser>=2.7.1,<3.0.0
mapfile_parser>=2.7.2,<3.0.0
```

#### Development version
@@ -74,7 +74,7 @@ cargo add mapfile_parser
Or add the following line manually to your `Cargo.toml` file:

```toml
mapfile_parser = "2.7.1"
mapfile_parser = "2.7.2"
```

## Versioning and changelog
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[mypy]
python_version = 3.8
python_version = 3.9
check_untyped_defs = True
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@

[project]
name = "mapfile_parser"
version = "2.7.1"
version = "2.7.2"
description = "Map file parser library focusing decompilation projects"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"requests"
]
2 changes: 1 addition & 1 deletion src/mapfile_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

from __future__ import annotations

__version_info__ = (2, 7, 1)
__version_info__ = (2, 7, 2)
__version__ = ".".join(map(str, __version_info__))# + "-dev0"
__author__ = "Decompollaborate"

9 changes: 6 additions & 3 deletions src/rs/file.rs
Original file line number Diff line number Diff line change
@@ -379,7 +379,7 @@ impl Hash for File {
#[cfg(feature = "python_bindings")]
#[allow(non_snake_case)]
pub(crate) mod python_bindings {
use pyo3::{intern, prelude::*};
use pyo3::{intern, prelude::*, IntoPyObjectExt};

use std::path::PathBuf;

@@ -390,9 +390,12 @@ pub(crate) mod python_bindings {

use std::collections::hash_map::DefaultHasher;

use super::*;

#[pymethods]
impl super::File {
impl File {
#[new]
#[pyo3(signature = (filepath, vram, size, section_type, vrom=None, align=None))]
fn py_new(
filepath: PathBuf,
vram: u64,
@@ -414,7 +417,7 @@ pub(crate) mod python_bindings {
let pathlib_path = pathlib.getattr(intern!(py, "Path"))?;
let args = (self.filepath.clone(),);

Ok(pathlib_path.call1(args)?.to_object(py))
pathlib_path.call1(args)?.into_py_any(py)
})
}

3 changes: 2 additions & 1 deletion src/rs/found_symbol_info.rs
Original file line number Diff line number Diff line change
@@ -132,6 +132,7 @@ pub(crate) mod python_bindings {
}

#[pyo3(name = "getAsStrPlusOffset")]
#[pyo3(signature = (sym_name=None))]
fn getAsStrPlusOffset(&self, sym_name: Option<String>) -> String {
let temp = super::FoundSymbolInfo::from(self);
temp.get_as_str_plus_offset(sym_name)
@@ -144,7 +145,7 @@ pub(crate) mod python_bindings {
}
}

impl<'a> From<super::FoundSymbolInfo<'a>> for PyFoundSymbolInfo {
impl From<super::FoundSymbolInfo<'_>> for PyFoundSymbolInfo {
fn from(value: super::FoundSymbolInfo) -> Self {
Self::new(value.file.clone(), value.symbol.clone(), value.offset)
}
2 changes: 1 addition & 1 deletion src/rs/lib.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ use pyo3::prelude::*;

#[cfg(feature = "python_bindings")]
#[pymodule]
fn mapfile_parser(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn mapfile_parser(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<mapfile::MapFile>()?;
m.add_class::<segment::Segment>()?;
m.add_class::<file::File>()?;
6 changes: 3 additions & 3 deletions src/rs/maps_comparison_info.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ pub struct MapsComparisonInfo<'a> {
pub compared_list: Vec<symbol_comparison_info::SymbolComparisonInfo<'a>>,
}

impl<'a> MapsComparisonInfo<'a> {
impl MapsComparisonInfo<'_> {
pub fn new() -> Self {
Self {
bad_files: HashSet::new(),
@@ -24,7 +24,7 @@ impl<'a> MapsComparisonInfo<'a> {
}
}

impl<'a> Default for MapsComparisonInfo<'a> {
impl Default for MapsComparisonInfo<'_> {
fn default() -> Self {
Self::new()
}
@@ -116,7 +116,7 @@ pub(crate) mod python_bindings {
}
}

impl<'a> From<super::MapsComparisonInfo<'a>> for PyMapsComparisonInfo {
impl From<super::MapsComparisonInfo<'_>> for PyMapsComparisonInfo {
fn from(value: super::MapsComparisonInfo) -> Self {
Self {
bad_files: value.bad_files.into_iter().cloned().collect(),
1 change: 1 addition & 0 deletions src/rs/segment.rs
Original file line number Diff line number Diff line change
@@ -328,6 +328,7 @@ pub(crate) mod python_bindings {
#[pymethods]
impl super::Segment {
#[new]
#[pyo3(signature = (name, vram, size, vrom, align=None))]
fn py_new(name: String, vram: u64, size: u64, vrom: u64, align: Option<u64>) -> Self {
Self::new(name, vram, size, vrom, align)
}
64 changes: 23 additions & 41 deletions src/rs/symbol.rs
Original file line number Diff line number Diff line change
@@ -23,11 +23,6 @@ pub struct Symbol {
pub vrom: Option<u64>,

pub align: Option<u64>,

// idk if it is worth to continue maintaining this, given the complexity introduced by other features
#[cfg(feature = "python_bindings")]
#[cfg_attr(feature = "serde", serde(skip))]
chached_name: Option<PyObject>,
}

impl Symbol {
@@ -44,9 +39,6 @@ impl Symbol {
size,
vrom,
align,

#[cfg(feature = "python_bindings")]
chached_name: None,
}
}

@@ -57,9 +49,6 @@ impl Symbol {
size: None,
vrom: None,
align: None,

#[cfg(feature = "python_bindings")]
chached_name: None,
}
}

@@ -125,8 +114,7 @@ impl Hash for Symbol {
#[cfg(feature = "python_bindings")]
#[allow(non_snake_case)]
pub(crate) mod python_bindings {
use pyo3::prelude::*;
use pyo3::types::IntoPyDict;
use pyo3::{prelude::*, types::IntoPyDict, IntoPyObjectExt};

use std::collections::hash_map::DefaultHasher;

@@ -150,14 +138,8 @@ pub(crate) mod python_bindings {
/* Getters and setters */

#[getter]
fn get_name(&mut self) -> PyObject {
Python::with_gil(|py| {
if self.chached_name.is_none() {
self.chached_name = Some(self.name.to_object(py));
}

self.chached_name.as_ref().unwrap().to_object(py)
})
fn get_name(&self) -> PyResult<&str> {
Ok(&self.name)
}

#[setter]
@@ -213,58 +195,58 @@ pub(crate) mod python_bindings {
/* Serializers */

#[pyo3(signature=(_humanReadable=true))]
fn serializeName(&self, _humanReadable: bool) -> PyObject {
Python::with_gil(|py| self.name.to_object(py))
fn serializeName(&self, _humanReadable: bool) -> PyResult<PyObject> {
Python::with_gil(|py| self.name.clone().into_py_any(py))
}

#[pyo3(signature=(humanReadable=true))]
fn serializeVram(&self, humanReadable: bool) -> PyObject {
fn serializeVram(&self, humanReadable: bool) -> PyResult<PyObject> {
Python::with_gil(|py| {
if humanReadable {
return format!("0x{:08X}", self.vram).to_object(py);
return format!("0x{:08X}", self.vram).into_py_any(py);
}

self.vram.to_object(py)
self.vram.into_py_any(py)
})
}

#[pyo3(signature=(humanReadable=true))]
fn serializeSize(&self, humanReadable: bool) -> PyObject {
fn serializeSize(&self, humanReadable: bool) -> PyResult<PyObject> {
Python::with_gil(|py| match self.size {
None => Python::None(py),
None => Ok(Python::None(py)),
Some(size) => {
if humanReadable {
return format!("0x{:X}", size).to_object(py);
return format!("0x{:X}", size).into_py_any(py);
}
size.to_object(py)
size.into_py_any(py)
}
})
}

#[pyo3(signature=(humanReadable=true))]
fn serializeVrom(&self, humanReadable: bool) -> PyObject {
fn serializeVrom(&self, humanReadable: bool) -> PyResult<PyObject> {
Python::with_gil(|py| match self.vrom {
None => Python::None(py),
None => Ok(Python::None(py)),
Some(vrom) => {
if humanReadable {
return format!("0x{:06X}", vrom).to_object(py);
return format!("0x{:06X}", vrom).into_py_any(py);
}
vrom.to_object(py)
vrom.into_py_any(py)
}
})
}

#[pyo3(signature=(humanReadable=true))]
fn toJson(&self, humanReadable: bool) -> PyObject {
fn toJson(&self, humanReadable: bool) -> PyResult<PyObject> {
Python::with_gil(|py| {
[
("name", self.serializeName(humanReadable)),
("vram", self.serializeVram(humanReadable)),
("size", self.serializeSize(humanReadable)),
("vrom", self.serializeVrom(humanReadable)),
("name", self.serializeName(humanReadable)?),
("vram", self.serializeVram(humanReadable)?),
("size", self.serializeSize(humanReadable)?),
("vrom", self.serializeVrom(humanReadable)?),
]
.into_py_dict(py)
.to_object(py)
.into_py_dict(py)?
.into_py_any(py)
})
}

2 changes: 1 addition & 1 deletion src/rs/symbol_comparison_info.rs
Original file line number Diff line number Diff line change
@@ -174,7 +174,7 @@ pub(crate) mod python_bindings {
}
}

impl<'a> From<super::SymbolComparisonInfo<'a>> for PySymbolComparisonInfo {
impl From<super::SymbolComparisonInfo<'_>> for PySymbolComparisonInfo {
fn from(value: super::SymbolComparisonInfo) -> Self {
Self::new(
value.symbol.clone(),

0 comments on commit fbcc802

Please sign in to comment.