Skip to content

Commit 79c033e

Browse files
committed
fix: pypy incompatibility, windows 2019 dead
1 parent 16b408a commit 79c033e

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright (C) 2025 Mohamed Gaber
2+
#
3+
# Adapted from Yosys wheels
4+
#
5+
# Copyright (C) 2024 Efabless Corporation
6+
#
7+
# Permission to use, copy, modify, and/or distribute this software for any
8+
# purpose with or without fee is hereby granted, provided that the above
9+
# copyright notice and this permission notice appear in all copies.
10+
#
11+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
118
name: Build Wheels for PyPI
219

320
# Events that trigger workflow
@@ -33,8 +50,8 @@ jobs:
3350
archs: "x86_64,arm64",
3451
},
3552
{
36-
name: "Windows Server 2019",
37-
runner: "windows-2019",
53+
name: "Windows Server 2022",
54+
runner: "windows-2022",
3855
archs: "AMD64,ARM64",
3956
},
4057
]
@@ -55,11 +72,8 @@ jobs:
5572
- name: Build wheels
5673
uses: pypa/cibuildwheel@v2.21.1
5774
env:
58-
# * APIs not supported by PyPy
59-
# * Musllinux disabled because it increases build time from 48m to ~3h
6075
CIBW_ARCHS: ${{ matrix.os.archs }}
6176
CIBW_BUILD_VERBOSITY: "1"
62-
# manylinux2014 (default) does not have a modern enough C++ compiler for Yosys
6377
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
6478
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
6579
- uses: actions/upload-artifact@v4

libparse/wrapper.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,16 @@ namespace py = pybind11;
2626
using namespace Yosys;
2727

2828
struct PyIStream : public std::istream {
29-
PyIStream(stdio_filebuf<char> *buffer) : std::istream(buffer), buffer_(buffer) {}
29+
PyIStream(FILE *f) : std::istream(&buffer_), buffer_(f) {}
3030

3131
static PyIStream *make_from(const py::object &pyfile)
3232
{
33-
if (pyfile == py::none()) {
33+
if (pyfile.is(py::none())) {
3434
throw std::runtime_error("None is not a valid input stream");
3535
}
36-
if (!hasattr(pyfile, "fileno")) {
37-
throw std::runtime_error("Passed object has no fileno() method");
38-
}
3936

40-
auto fd = PyObject_AsFileDescriptor(pyfile.ptr());
37+
auto fd_attr = pyfile.attr("fileno");
38+
auto fd = fd_attr.cast<int>();
4139
if (fd == -1) {
4240
throw std::runtime_error("Failed to get file descriptor");
4341
}
@@ -47,18 +45,11 @@ struct PyIStream : public std::istream {
4745
throw std::runtime_error("Failed to open input stream");
4846
}
4947

50-
return new PyIStream(new stdio_filebuf<char>(f));
51-
}
52-
53-
~PyIStream()
54-
{
55-
if (buffer_) {
56-
delete buffer_;
57-
}
48+
return new PyIStream(f);
5849
}
5950

60-
private:
61-
stdio_filebuf<char> *buffer_ = nullptr;
51+
private:
52+
stdio_filebuf<char> buffer_;
6253
};
6354

6455
LibertyParser *from_file(const py::object &pyfile)

0 commit comments

Comments
 (0)