Skip to content

Commit

Permalink
setuptools -> poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Feb 10, 2025
1 parent 6f3b9ec commit 0923d02
Show file tree
Hide file tree
Showing 10 changed files with 473 additions and 55 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ on:
jobs:
lint_python:
name: Lint Python Code
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Check out Git repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Linters
run: make venv
- name: Lint
run: make lint
push_to_pypi:
name: Build (and publish, if applicable)
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: lint_python
steps:
- name: Check out Git repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Export Repo URL
run: echo "REPO_URL=https://github.com/${{ github.repository }}" >> $GITHUB_ENV
- name: Export Branch Name
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Set Up Python 3.6
- name: Set Up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.6
python-version: 3.8
- name: Build Distribution
run: |
make dist
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ parser.out
parsetab.py
*.rpt
*.log
/*.v
/*.v
requirements_tmp.txt
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
FILE=./requirements_dev.txt

all: dist

.PHONY: dist
dist: venv/created
./venv/bin/python3 setup.py sdist bdist_wheel
dist: venv/manifest.txt
./venv/bin/poetry build

.PHONY: lint
lint: venv/created
./venv/bin/black --check .
./venv/bin/flake8 .
lint:
black --check .
flake8 .
mypy --check-untyped-defs .

venv: venv/created
venv/created: $(FILE)
venv: venv/manifest.txt
venv/manifest.txt: ./pyproject.toml
rm -rf venv
python3 -m venv ./venv
./venv/bin/python3 -m pip install wheel
./venv/bin/python3 -m pip install -r $(FILE)
touch venv/created
PYTHONPATH= ./venv/bin/python3 -m pip install --upgrade pip
PYTHONPATH= ./venv/bin/python3 -m pip install --upgrade wheel poetry poetry-plugin-export
PYTHONPATH= ./venv/bin/poetry export --with dev --without-hashes --format=requirements.txt --output=requirements_tmp.txt
PYTHONPATH= ./venv/bin/python3 -m pip install --upgrade -r requirements_tmp.txt
PYTHONPATH= ./venv/bin/python3 -m pip freeze > $@
@echo ">> Venv prepared."

.PHONY: veryclean
veryclean: clean
Expand All @@ -29,4 +30,4 @@ clean:
rm -rf build/
rm -rf logs/
rm -rf dist/
rm -rf *.egg-info
rm -rf *.egg-info
41 changes: 41 additions & 0 deletions nldiff/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import importlib.metadata
import sys


def __get_version():
try:
return importlib.metadata.version(__package__ or __name__)
except importlib.metadata.PackageNotFoundError:
import re

rx = re.compile(r"version\s*=\s*\"([^\"]+)\"")
openlane_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
pyproject_path = os.path.join(openlane_directory, "pyproject.toml")
try:
match = rx.search(open(pyproject_path, encoding="utf8").read())
assert match is not None, "pyproject.toml found, but without a version"
return match[1]
except FileNotFoundError:
print("Warning: Failed to extract nl2diff version.", file=sys.stderr)
return "UNKNOWN"


__version__ = __get_version()


if __name__ == "__main__":
print(__version__, end="")
377 changes: 377 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[tool.poetry]
name = "nldiff"
version = "0.1.0" # Replace with your actual version
description = "Netlist Diff Tool"
authors = ["Mohamed Gaber <[email protected]>"]
license = "MIT" # Replace with your license if different. Common ones: MIT, Apache-2.0, GPL-3.0
readme = "Readme.md"
packages = [{ include = "nldiff" }] # This is how Poetry handles packages
classifiers = [
"Programming Language:: Python:: 3",
"Intended Audience:: Developers",
"Operating System:: POSIX:: Linux",
"Operating System:: MacOS:: MacOS X",
]

[tool.poetry.dependencies]
python = "^3.8" # Redundant, but good practice to keep here too
click = ">=8.0.0,<9"
pyverilog = "*"


[tool.poetry.group.dev.dependencies]
wheel = "*"
black = ">=24.4.0,<25"
flake8 = ">=4"

[tool.poetry.scripts]
nldiff = "nldiff.__main__:diff_cmd"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements_dev.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements_lint.txt

This file was deleted.

26 changes: 0 additions & 26 deletions setup.py

This file was deleted.

0 comments on commit 0923d02

Please sign in to comment.