diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5ab4f0564..637a229b5 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -3,7 +3,7 @@ current_version = 0.2.2 commit = True tag = True -[bumpversion:file:./setup.py] +[bumpversion:file:pyproject.toml] [bumpversion:file:./docs/conf.py] diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 920b44b49..c181b4b57 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -27,18 +27,14 @@ jobs: - name: Installing the library shell: bash -l {0} run: | - mkdir -p $HOME/.tidy3d - echo ${{ secrets.TIDY3D_AUTH }} > $HOME/.tidy3d/auth.json - pip install -e . - sudo wget https://github.com/jgm/pandoc/releases/download/1.16.0.2/pandoc-1.16.0.2-1-amd64.deb - sudo dpkg -i pandoc-1.16.0.2-1-amd64.deb - #sudo apt install pandoc - pip install -r requirements_dev.txt + sudo apt install pandoc + pip install -e .[docs] - name: Running the Sphinx to gh-pages Action uses: uibcdf/action-sphinx-docs-to-gh-pages@v1.0-beta.2 env: TIDY3D_USER: ${{ secrets.TIDY3D_EMAIL }} TIDY3D_PASS: ${{ secrets.TIDY3D_PASSWORD }} + DISPLAY: 1.0 with: branch: main dir_docs: docs diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml deleted file mode 100644 index 38940972d..000000000 --- a/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: pre-commit - -on: - pull_request: - push: - -jobs: - pre-commit: - runs-on: ubuntu-latest - concurrency: - group: ${{ github.ref }}-pre-commit - cancel-in-progress: true - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/release.yml similarity index 64% rename from .github/workflows/pythonpublish.yml rename to .github/workflows/release.yml index 7d27a356c..fef6fe744 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/release.yml @@ -1,21 +1,20 @@ -name: Upload Python Package +name: Release PyPI on: - release: - types: [created, published] push: - branches: [master] - tags: [v*] + tags: "v*" jobs: - deploy: + release_pypi: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: 3.x + cache-dependency-path: pyproject.toml - name: Install dependencies run: | python -m pip install --upgrade pip @@ -25,5 +24,5 @@ jobs: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + make build twine upload dist/* diff --git a/.github/workflows/test_code.yml b/.github/workflows/test_code.yml index ed34d8849..e32331f77 100644 --- a/.github/workflows/test_code.yml +++ b/.github/workflows/test_code.yml @@ -1,35 +1,124 @@ ---- -name: Lint and Test -# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python +name: Test pre-commit, code and docs on: pull_request: push: + branches: + - main jobs: - build: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 + test_code: + needs: [pre-commit] runs-on: ${{ matrix.os }} strategy: max-parallel: 12 matrix: - python-version: [3.7, '3.10'] - os: [ubuntu-latest] + python-version: ["3.10"] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - - name: Cancel Workflow Action - uses: styfle/cancel-workflow-action@0.11.0 - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + cache: "pip" + cache-dependency-path: pyproject.toml - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install flake8 pytest pytest_regressions pip install . + pip install flake8 pytest pytest_regressions - name: Lint with flake8 run: | flake8 . - name: Test with pytest run: pytest + test_code_coverage_python37: + runs-on: ubuntu-latest + needs: [pre-commit] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + cache: "pip" + cache-dependency-path: pyproject.toml + - name: Install dependencies + run: | + pip install -e . + - name: Test with pytest + run: | + python -m pip install --upgrade pip + pip install pytest klayout lytest scikit-image pytest-cov pytest_regressions + pytest --cov=sky130 tests/ + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + test_docs: + needs: [pre-commit] + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 12 + matrix: + python-version: [3.9] + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + python-version: 3.9 + mamba-version: "*" + channels: conda-forge,defaults + channel-priority: true + activate-environment: anaconda-client-env + - name: Add conda to system path + run: | + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + python -m pip install --upgrade pip + sudo apt install pandoc + pip install -e .[docs] + - name: Test documentation + env: + TIDY3D_USER: ${{ secrets.TIDY3D_EMAIL }} + TIDY3D_PASS: ${{ secrets.TIDY3D_PASSWORD }} + DISPLAY: 1.0 + run: | + mkdir -p $HOME/.tidy3d + echo ${{ secrets.TIDY3D_AUTH }} > $HOME/.tidy3d/auth.json + cd docs + make html + + release_pypi: + needs: [pre-commit] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.x + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/test_docs.yml b/.github/workflows/test_docs.yml deleted file mode 100644 index c21257a31..000000000 --- a/.github/workflows/test_docs.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Test documentation - -on: - pull_request: - push: - -jobs: - build-linux: - runs-on: ubuntu-latest - - steps: - - name: Cancel Workflow Action - uses: styfle/cancel-workflow-action@0.11.0 - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v3 - with: - python-version: 3.9 - - name: Install dependencies - run: | - pip install -r requirements_dev.txt - pip install . - sudo apt install pandoc - - name: Test documentation - run: | - cd docs - make html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index e72bd2a5f..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,71 +0,0 @@ -image: python:3.7 - -before_script: - - pip list - - python -V # Print out python version for debugging - - which python # Print out which python for debugging - - pip install -r requirements.txt --upgrade - - python setup.py develop - -stages: - - test - - release - -pre-commit: - stage: test - script: - - pip install pre-commit - - pre-commit install - - pre-commit run -a - -test: - stage: test - script: - - pytest - -python37: - image: python:3.7 - stage: test - script: - - python -m pip install tox - - python -m tox -e py37 - -python38: - image: python:3.8 - stage: test - script: - - python -m pip install tox - - python -m tox -e py38 - -python39: - image: python:3.9 - stage: test - script: - - python -m pip install tox - - python -m tox -e py39 - -doctest: - stage: test - script: - - python -m pip install tox - - python -m tox -e docs - -flake8: - stage: test - script: - - python -m pip install tox - - python -m tox -e flake8 - -mypy: - stage: test - script: - - python -m pip install tox - - python -m tox -e mypy - -docs: - stage: release - script: - - cd docs - - make install clean html upload - only: - - release diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index da00084db..000000000 --- a/.isort.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[settings] -line_length = 88 -multi_line_output = 3 -include_trailing_comma = True -known_third_party = celery,django,environ,pyquery,pytz,redis,requests,rest_framework diff --git a/.mergify.yml b/.mergify.yml deleted file mode 100644 index a41d6856d..000000000 --- a/.mergify.yml +++ /dev/null @@ -1,8 +0,0 @@ -pull_request_rules: - - name: automatic merge for Dependabot pull requests - conditions: - - author~=^dependabot(|-preview)\[bot\]$ - - check-success=Travis CI - Pull Request - actions: - merge: - method: merge diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index ba02e14ca..000000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,24 +0,0 @@ -# .readthedocs.yml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required -version: 2 - -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: docs/conf.py - -# Build documentation with MkDocs -#mkdocs: -# configuration: mkdocs.yml - -# Optionally build your docs in additional formats such as PDF and ePub -# formats: all - -# Optionally set the version of Python and requirements required to build your docs -python: - version: 3.9 - install: - - requirements: requirements.txt - - requirements: requirements_dev.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4e4004d68..000000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: python -python: - - "3.7" - -# install dependencies -install: - - pip install -r requirements.txt - -# run tests -script: - - pytest - -notifications: - email: false diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index cdbd159a3..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,19 +0,0 @@ -include requirements.txt -include README.md -include LICENSE -include sky130/klayout/sky130/sky130.xs -include sky130/klayout/sky130/sky130.lyp -include sky130/klayout/sky130/sky130_xs.lyp -include sky130/klayout/sky130/sky130hd.lyt -include sky130/klayout/sky130/tech.lyt -include sky130/klayout/sky130/layers.lyp -recursive-include sky130/gds *.gds -recursive-include sky130/spice *.spice -global-include *.lyp -global-include *.lym -global-include *.lyt -global-include *.spice -global-include *.xs -include requirements.txt -include requirements_dev.txt -include sky130/gds/*.gds diff --git a/Makefile b/Makefile index 72e8609b8..7dd421b56 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ - install: - pip install -r requirements.txt --upgrade - pip install -r requirements_dev.txt --upgrade - pip install -e . + pip install -e . pre-commit pre-commit install watch: @@ -39,12 +36,20 @@ update: update-pre: pre-commit autoupdate --bleeding-edge +git-rm-merged: + git branch -D `git branch --merged | grep -v \* | xargs` + release: git push git push --tags build: - python setup.py sdist bdist_wheel + rm -rf dist + pip install build + python -m build tech: python3 install_tech.py + + +.PHONY: gdsdiff build conda diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..19ceddf69 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,149 @@ +# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +name="sky130" +description="skywater130 pdk" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: OS Independent", +] +version="0.2.2" +authors = [ + {name = "gdsfactory", email = "contact@gdsfactory.com"}, +] +keywords = ["python"] +license = {file = "LICENSE"} +dependencies = [ + "gdsfactory[full]==6.16.2", + "PySpice" +] +readme = "README.md" +requires-python = ">=3.7" + +[project.optional-dependencies] +dev = [ + "autotyping", + "black>=21", + "doc8", + "mypy", + "pre-commit", + "pylsp-mypy", + "types-cachetools", + "flake8", + "flake8-bugbear", + "ipykernel", + "pytest", + "pytest-cov", + "pytest_regressions", + "types-PyYAML", + "xdoctest", + "pyproject-flake8", + ] +docs = [ + "autodoc_pydantic", + "docutils==0.17.1", + "matplotlib", + "myst-parser", + "nbsphinx", + "sphinx", + "sphinx-autodoc-typehints", + "sphinx-book-theme==0.3.3", + "sphinx-click", + "sphinx-copybutton", + "sphinx-markdown-tables==0.0.16", + "sphinxcontrib-video", + ] + + +[tool.setuptools.packages] +find = {} + +[tool.black] +line-length = 88 +target-version = ['py310'] +include = '\.pyi?$' +exclude = ''' # Specify the files/dirs that should be ignored by the black formatter +/( + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | env + | _build + | buck-out + | build + | dist +)/ +''' + +[tool.pytest.ini_options] +testpaths = ["sky130", "tests"] +# addopts = --tb=no +# addopts = '--tb=short' +python_files = ["sky130/*.py", "tests/*.py"] +# python_files = ["tests/*.py"] +# norecursedirs = ["extra/*.py", 'sky130/simulations/*.py'] +# addopts = '--cov=tests --cov-report html' + +[tool.flake8] +max-line-length = 88 +max-complexity = 57 +select = ["B","C","E","F","W","T4","B9"] +ignore = [ "E501", "E503", "E722", "W503", "W503", "E203", "B950", "B305", "B018", "B902", "B020", "B905"] +extend-ignore = "RST303" + +exclude = [ + ".git", + "__pycache__", + "lib", + "docs/source/conf.py", + "build", + "dist", + ".ipynb_checkpoints", + ".tox", + "extra", + "deprecated", + ".mypy_cache", + "venv", + "devsim", + ] + +[tool.commitizen] +name = "cz_conventional_commits" +version = "0.1.0" +version_files = [ + "pyproject.toml:version", +] + +[tool.mypy] +python_version = "3.10" +strict = true + +[tool.pylsp-mypy] +enabled = true +live_mode = true +strict = true + +[tool.isort] +multi_line_output = 3 +line_length = 88 +include_trailing_comma = true + +[tool.setuptools.package-data] +mypkg = ["*.csv", "*.yaml"] + +[tool.pydocstyle] +inherit = false +match = "(?!test).*\\.py" +add-ignore = ["D100","D101","D102","D103","D104","D203","D405","D417"] +convention = "google" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 3116f2af7..000000000 --- a/pytest.ini +++ /dev/null @@ -1,11 +0,0 @@ -[pytest] -testpaths = sky130 tests -# addopts = --tb=no -addopts = '--tb=short' -python_files = sky130/*.py tests/*.py - -filterwarnings = - ignore::UserWarning - ignore::DeprecationWarning - -# addopts = '--html=test_report.html' '--self-contained-html' diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c33296105..000000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -gdsfactory[full]==6.15.3 -PySpice diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 716ac4e7e..000000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,25 +0,0 @@ -autodoc_pydantic -autotyping -doc8 -docutils==0.17.1 -flake8 -flake8-bugbear -gdsfactory[full] -ipykernel -mypy -myst-parser -nbsphinx -pre-commit -pur -pydocstyle -pytest -pytest-cov -pytest-regressions -sphinx-autodoc-typehints -sphinx-book-theme==0.3.3 -sphinx-click -sphinx-copybutton -sphinx-markdown-tables==0.0.16 -types-PyYAML -types-waitress -xdoctest diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0ac626881..000000000 --- a/setup.cfg +++ /dev/null @@ -1,27 +0,0 @@ -[flake8] -max-line-length = 88 -max-complexity = 38 -select = B,C,E,F,W,T4,B9 -ignore = E501, E503, E722, W503, W503, E203, B950 - -extend-ignore = - RST303 - -exclude = - .git, - __pycache__, - docs/source/conf.py, - build, - dist, - .ipynb_checkpoints, - .tox, - extra, - deprecated, - gdslib, - .tox, - .mypy_cache - -[pydocstyle] -inherit = false -ignore = D100,D203,D405 -match = .*\.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 59954a09a..000000000 --- a/setup.py +++ /dev/null @@ -1,34 +0,0 @@ -from setuptools import find_packages -from setuptools import setup - - -def get_install_requires(): - with open("requirements.txt") as f: - return [line.strip() for line in f.readlines() if not line.startswith("-")] - - -with open("README.md") as f: - LONG_DESCRIPTION = f.read() - - -setup( - name="sky130", - version="0.2.2", - url="https://github.com/gdsfactory/skywater130", - include_package_data=True, - license="MIT", - author="gdsfactory", - description="skywater gdsfactory pdk", - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - packages=find_packages(exclude=("tests",)), - # install_requires=("gdsfactory==5.8.8",), - install_requires=get_install_requires(), - python_requires=">=3.7", - classifiers=[ - "Development Status :: 2 - Pre-Alpha", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - ], -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 8c8086305..000000000 --- a/tox.ini +++ /dev/null @@ -1,57 +0,0 @@ -[tox] -envlist = py37, py38, py39 - - -[testenv] -commands = pytest -deps= - pytest - -rrequirements.txt - -rrequirements_dev.txt - -# Linters -[testenv:flake8] -basepython = python3 -skip_install = true -deps = - flake8 - flake8-bugbear - flake8-docstrings>=1.3.1 - flake8-import-order>=0.9 - flake8-typing-imports>=1.1 - pep8-naming -commands = - flake8 - - -# Flake8 Configuration -[flake8] -ignore = D203, W503, E203, B950 -exclude = - .tox, - .git, - __pycache__, - docs/source/conf.py, - build, - dist, - tests/fixtures/*, - *.pyc, - *.egg-info, - .cache, - .eggs -max-complexity = 10 -import-order-style = google -application-import-names = flake8 - - -[testenv:docs] -commands = - py.test --doctest-glob="*.md" --doctest-glob="README.md" README.md - - -[testenv:mypy] -skip_install = True -deps = - mypy -commands= - mypy . ignore-missing-imports --pretty