From 112b88aa0f51584887eb898c233f1636094f9d1d Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 20:29:56 -0300 Subject: [PATCH 1/7] refactor: simplify bitstream path construction for PEP 8 compliance --- pyfpga/gowin.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pyfpga/gowin.py b/pyfpga/gowin.py index fcc44d84..fb3623ac 100644 --- a/pyfpga/gowin.py +++ b/pyfpga/gowin.py @@ -31,14 +31,16 @@ def _make_custom(self): def _get_bitstream(self, bitstream=None): if not bitstream: + project = self.data['project'] + pnr_dir = Path(self.odir) / project / 'impl' / 'pnr' + for ext in self.conf['prog_bit']: - candidate = ( - Path(self.odir) / - f'{self.data["project"]}/impl/pnr/{self.data["project"]}.{ext}' - ) + candidate = pnr_dir / f'{project}.{ext}' if candidate.is_file(): bitstream = candidate break + if not bitstream or not Path(bitstream).is_file(): raise FileNotFoundError(bitstream) + return self._get_absolute(bitstream, self.conf['prog_ext']) From 81cd94aca630f0cc33d3175591743d60405a9be2 Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 20:37:52 -0300 Subject: [PATCH 2/7] Add pylint exception (duplicate-code) --- pyfpga/gowin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfpga/gowin.py b/pyfpga/gowin.py index fb3623ac..f1414ebc 100644 --- a/pyfpga/gowin.py +++ b/pyfpga/gowin.py @@ -29,6 +29,8 @@ def _make_custom(self): if 'part' not in self.data: self.data['part'] = 'GW2AR-LV18QN88C8/I7' + # pylint: disable=duplicate-code + def _get_bitstream(self, bitstream=None): if not bitstream: project = self.data['project'] From 79a81f28d7c3e16a84c2011b87128c28c5fcf534 Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 20:44:14 -0300 Subject: [PATCH 3/7] Add Windows mock-up for gw_sh --- tests/mocks/gw_sh.bat | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/mocks/gw_sh.bat diff --git a/tests/mocks/gw_sh.bat b/tests/mocks/gw_sh.bat new file mode 100644 index 00000000..158862c7 --- /dev/null +++ b/tests/mocks/gw_sh.bat @@ -0,0 +1 @@ +@echo off & python "%~dp0%~n0" %* From d59c30f4002959e71af6610da1ab123635f05afe Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 20:59:30 -0300 Subject: [PATCH 4/7] Fix support for Windows paths --- pyfpga/gowin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfpga/gowin.py b/pyfpga/gowin.py index f1414ebc..48cfd2e0 100644 --- a/pyfpga/gowin.py +++ b/pyfpga/gowin.py @@ -41,8 +41,11 @@ def _get_bitstream(self, bitstream=None): if candidate.is_file(): bitstream = candidate break + else: + bitstream = Path(bitstream) - if not bitstream or not Path(bitstream).is_file(): + if not bitstream or not bitstream.is_file(): raise FileNotFoundError(bitstream) - return self._get_absolute(bitstream, self.conf['prog_ext']) + abs_path = self._get_absolute(bitstream, self.conf['prog_ext']) + return Path(abs_path).as_posix() From bcdd7e8c7323cb21f773f010e7ca8d633c68be82 Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 21:02:32 -0300 Subject: [PATCH 5/7] Bump version --- pyfpga/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpga/__init__.py b/pyfpga/__init__.py index d5dfd336..a7495f1c 100644 --- a/pyfpga/__init__.py +++ b/pyfpga/__init__.py @@ -1,3 +1,3 @@ """PyFPGA""" -__version__ = '0.4.0' +__version__ = '0.5.0' From 8cdefc153a746bce761194045008d646dbe8d975 Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 21:11:16 -0300 Subject: [PATCH 6/7] ci: rename pypi.yaml as pypi.yml --- .github/workflows/{pypi.yaml => pypi.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{pypi.yaml => pypi.yml} (100%) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yml similarity index 100% rename from .github/workflows/pypi.yaml rename to .github/workflows/pypi.yml From c0a8efc5e68a63321031ad13af5e4ce680d88f62 Mon Sep 17 00:00:00 2001 From: Rodrigo Alejandro Melo Date: Sun, 20 Sep 2026 21:25:10 -0300 Subject: [PATCH 7/7] ci: specify python-version and add to run on pull_request --- .github/workflows/docs.yml | 6 +++++- .github/workflows/lint.yml | 12 +++++++++--- .github/workflows/test.yml | 6 ++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index bf55bcfb..056e30b6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,8 +13,12 @@ jobs: docs: runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Checkout code uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' - name: Install dependencies run: pip install . && pip install sphinx sphinx-rtd-theme - name: Build documentation diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a9e2a2f5..0105bc5f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,18 +2,24 @@ name: 'lint' on: push: - paths: + paths: &shared_paths - 'examples/**' - 'pyfpga/**' - 'tests/**' + pull_request: + paths: *shared_paths jobs: lint: runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Checkout code uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' - name: Install dependencies - run: pip install pycodestyle pylint + run: pip install jinja2 pycodestyle pylint - name: Run linting run: make lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1cf17508..f523430c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,10 +2,12 @@ name: 'test' on: push: - paths: + paths: &shared_paths - 'examples/projects/**' - 'pyfpga/**' - 'tests/**' + pull_request: + paths: *shared_paths jobs: test: @@ -25,7 +27,7 @@ jobs: runs-on: ${{ matrix.os }}-latest name: ${{ matrix.os }} | ${{ matrix.pyver }} steps: - - name: Checkout repository + - name: Checkout code uses: actions/checkout@v4 - name: Set up Python ${{ matrix.pyver }} uses: actions/setup-python@v5