From 431498040ffba3165ddf3ca1c327b152777d3e70 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 11:40:02 +0530 Subject: [PATCH 01/11] version gatekeep while releasing --- .github/workflows/release.yml | 34 +++++++++++++++ pyproject.toml | 65 ---------------------------- setup.py | 81 +++++++++++++++++++++++++++++++++++ src/pyscript/version | 1 + 4 files changed, 116 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 pyproject.toml create mode 100644 setup.py create mode 100644 src/pyscript/version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7da1f31 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release to PyPI + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/pyscript + permissions: + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Build and package + run: | + pip install wheel + python setup.py sdist bdist_wheel + + - name: Upload to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index dc4db25..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,65 +0,0 @@ -[build-system] -build-backend = "setuptools.build_meta" -requires = ["setuptools", "setuptools-scm"] - -[project] -authors = [ - {name = "Matt Kramer", email = "mkramer@anaconda.com"}, - {name = "Fabio Pliger", email = "fpliger@anaconda.com"}, - {name = "Nicholas Tollervey", email = "ntollervey@anaconda.com"}, - {name = "Fabio Rosado", email = "frosado@anaconda.com"} -] -classifiers = [ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Software Development :: Code Generators", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Pre-processors" -] -dependencies = [ - 'importlib-metadata; python_version<"3.8"', - "Jinja2<3.2", - "pluggy<1.3", - "rich<=13.7.1", - "toml<0.11", - "typer<=0.9.0", - "platformdirs<4.3", - "requests<=2.31.0" -] -description = "Command Line Interface for PyScript" -keywords = ["pyscript", "cli", "pyodide", "micropython", "pyscript-cli"] -license = {text = "Apache-2.0"} -name = "pyscript" -readme = "README.md" -requires-python = ">=3.9" -version = "0.3.0" - -[project.optional-dependencies] -dev = [ - "coverage<7.3", - "mypy<=1.4.1", - "pytest<7.5", - "types-toml<0.11", - "types-requests" -] -docs = [ - "Sphinx<5.2", - "sphinx-autobuild<2021.4.0", - "sphinx-autodoc-typehints<1.20", - "myst-parser<0.19.3", - "pydata-sphinx-theme<0.13.4" -] - -[project.scripts] -pyscript = "pyscript.cli:app" - -[project.urls] -Documentation = "https://docs.pyscript.net" -Examples = "https://pyscript.com/@examples" -Homepage = "https://pyscript.net" -Repository = "https://github.com/pyscript/pyscript-cli" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4e0339f --- /dev/null +++ b/setup.py @@ -0,0 +1,81 @@ +import os +from setuptools import setup + +def read_version(): + with open("src/pyscript/version", "r") as f: + return f.read().strip("\n") + +def check_tag_version(): + tag = os.getenv("GITHUB_REF") + expected_version = read_version() + if tag != f"refs/tags/{expected_version}": + raise Exception(f"Tag '{tag}' does not match the expected " + f"version '{expected_version}'") + +with open("README.md", "r") as fh: + long_description = fh.read() + +check_tag_version() + +setup( + name="pyscript", + version=read_version(), + description="Command Line Interface for PyScript", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/pyscript/pyscript-cli", + author="Matt Kramer, Fabio Pliger, Nicholas Tollervey, Fabio Rosado, Madhur Tandon", + author_email="mkramer@anaconda.com, fpliger@anaconda.com, ntollervey@anaconda.com, frosado@anaconda.com, mtandon@anaconda.com", + license="Apache-2.0", + install_requires=[ + 'importlib-metadata; python_version<"3.8"', + 'Jinja2<3.2', + 'pluggy<1.3', + 'rich<=13.7.1', + 'toml<0.11', + 'typer<=0.9.0', + 'platformdirs<4.3', + 'requests<=2.31.0', + ], + python_requires=">=3.9", + keywords=["pyscript", "cli", "pyodide", "micropython", "pyscript-cli"], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Topic :: Software Development :: Code Generators', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Software Development :: Pre-processors', + ], + extras_require={ + "dev": [ + "coverage<7.3", + "mypy<=1.4.1", + "pytest<7.5", + "types-toml<0.11", + "types-requests" + ], + "docs": [ + "Sphinx<5.2", + "sphinx-autobuild<2021.4.0", + "sphinx-autodoc-typehints<1.20", + "myst-parser<0.19.3", + "pydata-sphinx-theme<0.13.4" + ] + }, + entry_points={ + 'console_scripts': [ + 'pyscript = pyscript.cli:app', + ], + }, + project_urls={ + 'Documentation': 'https://docs.pyscript.net', + 'Examples': 'https://pyscript.com/@examples', + 'Homepage': 'https://pyscript.net', + 'Repository': 'https://github.com/pyscript/pyscript-cli', + }, +) diff --git a/src/pyscript/version b/src/pyscript/version new file mode 100644 index 0000000..0d91a54 --- /dev/null +++ b/src/pyscript/version @@ -0,0 +1 @@ +0.3.0 From fe5bd0ad2730543e4c96b5abed2226948de48244 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 11:41:54 +0530 Subject: [PATCH 02/11] version gatekeep while releasing --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7da1f31..b71e1f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,8 @@ jobs: release: runs-on: ubuntu-latest environment: - name: pypi - url: https://pypi.org/project/pyscript + name: pypi + url: https://pypi.org/project/pyscript permissions: id-token: write steps: From a9422ad950d355eb53e1f1602e93e512f5595c8b Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 11:44:01 +0530 Subject: [PATCH 03/11] linting --- .github/workflows/release.yml | 50 +++++++++++++-------------- setup.py | 65 +++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 55 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b71e1f3..4d78b8f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,34 @@ name: Release to PyPI on: - push: - tags: - - '*' + push: + tags: + - '*' jobs: - release: - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/project/pyscript - permissions: - id-token: write - steps: - - name: Checkout code - uses: actions/checkout@v2 + release: + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/pyscript + permissions: + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.11 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 - - name: Install dependencies - run: pip install -r requirements.txt + - name: Install dependencies + run: pip install -r requirements.txt - - name: Build and package - run: | - pip install wheel - python setup.py sdist bdist_wheel + - name: Build and package + run: | + pip install wheel + python setup.py sdist bdist_wheel - - name: Upload to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Upload to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/setup.py b/setup.py index 4e0339f..212a190 100644 --- a/setup.py +++ b/setup.py @@ -1,18 +1,23 @@ import os + from setuptools import setup + def read_version(): - with open("src/pyscript/version", "r") as f: + with open("src/pyscript/version") as f: return f.read().strip("\n") + def check_tag_version(): tag = os.getenv("GITHUB_REF") expected_version = read_version() if tag != f"refs/tags/{expected_version}": - raise Exception(f"Tag '{tag}' does not match the expected " - f"version '{expected_version}'") + raise Exception( + f"Tag '{tag}' does not match the expected " f"version '{expected_version}'" + ) -with open("README.md", "r") as fh: + +with open("README.md") as fh: long_description = fh.read() check_tag_version() @@ -29,27 +34,27 @@ def check_tag_version(): license="Apache-2.0", install_requires=[ 'importlib-metadata; python_version<"3.8"', - 'Jinja2<3.2', - 'pluggy<1.3', - 'rich<=13.7.1', - 'toml<0.11', - 'typer<=0.9.0', - 'platformdirs<4.3', - 'requests<=2.31.0', + "Jinja2<3.2", + "pluggy<1.3", + "rich<=13.7.1", + "toml<0.11", + "typer<=0.9.0", + "platformdirs<4.3", + "requests<=2.31.0", ], python_requires=">=3.9", keywords=["pyscript", "cli", "pyodide", "micropython", "pyscript-cli"], classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Software Development :: Code Generators', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Pre-processors', + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Software Development :: Code Generators", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Pre-processors", ], extras_require={ "dev": [ @@ -57,25 +62,25 @@ def check_tag_version(): "mypy<=1.4.1", "pytest<7.5", "types-toml<0.11", - "types-requests" + "types-requests", ], "docs": [ "Sphinx<5.2", "sphinx-autobuild<2021.4.0", "sphinx-autodoc-typehints<1.20", "myst-parser<0.19.3", - "pydata-sphinx-theme<0.13.4" - ] + "pydata-sphinx-theme<0.13.4", + ], }, entry_points={ - 'console_scripts': [ - 'pyscript = pyscript.cli:app', + "console_scripts": [ + "pyscript = pyscript.cli:app", ], }, project_urls={ - 'Documentation': 'https://docs.pyscript.net', - 'Examples': 'https://pyscript.com/@examples', - 'Homepage': 'https://pyscript.net', - 'Repository': 'https://github.com/pyscript/pyscript-cli', + "Documentation": "https://docs.pyscript.net", + "Examples": "https://pyscript.com/@examples", + "Homepage": "https://pyscript.net", + "Repository": "https://github.com/pyscript/pyscript-cli", }, ) From 459f5430da982208f31ece898052a04e003937cb Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 11:46:05 +0530 Subject: [PATCH 04/11] fix linting --- setup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 212a190..3bdf774 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,13 @@ def check_tag_version(): long_description_content_type="text/markdown", url="https://github.com/pyscript/pyscript-cli", author="Matt Kramer, Fabio Pliger, Nicholas Tollervey, Fabio Rosado, Madhur Tandon", - author_email="mkramer@anaconda.com, fpliger@anaconda.com, ntollervey@anaconda.com, frosado@anaconda.com, mtandon@anaconda.com", + author_email=( + "mkramer@anaconda.com, " + "fpliger@anaconda.com, " + "ntollervey@anaconda.com, " + "frosado@anaconda.com, " + "mtandon@anaconda.com" + ), license="Apache-2.0", install_requires=[ 'importlib-metadata; python_version<"3.8"', From 6018a9545716dbbaebdf2a0cebeffa6c59d7278f Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 11:53:32 +0530 Subject: [PATCH 05/11] add check_version env --- .github/workflows/release.yml | 5 ++--- setup.py | 13 +++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d78b8f..acca5c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,9 @@ jobs: with: python-version: 3.11 - - name: Install dependencies - run: pip install -r requirements.txt - - name: Build and package + env: + CHECK_VERSION: "true" run: | pip install wheel python setup.py sdist bdist_wheel diff --git a/setup.py b/setup.py index 3bdf774..75777b7 100644 --- a/setup.py +++ b/setup.py @@ -9,12 +9,13 @@ def read_version(): def check_tag_version(): - tag = os.getenv("GITHUB_REF") - expected_version = read_version() - if tag != f"refs/tags/{expected_version}": - raise Exception( - f"Tag '{tag}' does not match the expected " f"version '{expected_version}'" - ) + if os.getenv("CHECK_VERSION", "false").lower() == "true": + tag = os.getenv("GITHUB_REF") + expected_version = read_version() + if tag != f"refs/tags/{expected_version}": + raise Exception( + f"Tag '{tag}' does not match the expected " f"version '{expected_version}'" + ) with open("README.md") as fh: From f59d141fd4cb0c8e8c6e920e36ec4989ac1845c2 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 11:54:20 +0530 Subject: [PATCH 06/11] linting --- .github/workflows/release.yml | 2 +- setup.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acca5c4..c3bc51c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: - name: Build and package env: - CHECK_VERSION: "true" + CHECK_VERSION: 'true' run: | pip install wheel python setup.py sdist bdist_wheel diff --git a/setup.py b/setup.py index 75777b7..47173e1 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,8 @@ def check_tag_version(): expected_version = read_version() if tag != f"refs/tags/{expected_version}": raise Exception( - f"Tag '{tag}' does not match the expected " f"version '{expected_version}'" + f"Tag '{tag}' does not match the expected " + f"version '{expected_version}'" ) From 3402bf7d326f6e11088db4c7ecae2ed6907e6637 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 12:07:00 +0530 Subject: [PATCH 07/11] fix jinja stuff --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 47173e1..cd99646 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import os -from setuptools import setup +from setuptools import setup, find_packages def read_version(): @@ -28,6 +28,9 @@ def check_tag_version(): name="pyscript", version=read_version(), description="Command Line Interface for PyScript", + package_dir={"": "src"}, + packages=find_packages(where="src"), + package_data={"pyscript": ["templates/*.html"]}, long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/pyscript/pyscript-cli", From 1f18d9537c325aff59cf44beb3352c7a5782e7d7 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 12:07:35 +0530 Subject: [PATCH 08/11] linting --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cd99646..1b41d57 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import os -from setuptools import setup, find_packages +from setuptools import find_packages, setup def read_version(): From a9254093d95821c5be8cbf03012a19d54bd9561e Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 12:10:59 +0530 Subject: [PATCH 09/11] fix linting again --- tests/test_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_generator.py b/tests/test_generator.py index c9c8c4a..eca8e1d 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -238,7 +238,7 @@ def check_plugin_project_files( f"""

Description

{ plugin_description }

-
""" + """ # noqa: E201, E202 ) assert f'' in contents assert f'' in contents From d0a6a03a00fdf87af88634948cc7676c49179676 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 12:18:27 +0530 Subject: [PATCH 10/11] include version file --- .github/workflows/publish.yaml | 51 ---------------------------------- .github/workflows/release.yml | 7 +++-- MANIFEST.in | 1 + 3 files changed, 6 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/publish.yaml create mode 100644 MANIFEST.in diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index a4903f5..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Publish - -on: - # Only on merges into main - push: - tags: v[0-9]+.[0-9]+.[0-9]+ - - -jobs: - build: - name: Build distribution - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Install pypa/build - run: python3 -m pip install build --user - - name: Build a binary wheel and a source tarball - run: python3 -m build - - name: Store the distribution packages - uses: actions/upload-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - # TODO: Add logic to do github release too here - - publish: - name: Publish to PyPI - runs-on: ubuntu-latest - needs: - - build - environment: - name: pypi - url: https://pypi.org/project/pyscript - permissions: - id-token: write - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - name: Publish release to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3bc51c..63344e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,12 +22,15 @@ jobs: with: python-version: 3.11 + - name: Install build tools + run: | + pip install --upgrade build + - name: Build and package env: CHECK_VERSION: 'true' run: | - pip install wheel - python setup.py sdist bdist_wheel + python -m build - name: Upload to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..156b382 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include src/pyscript/version From 92c8b0af81346cd28d5b440a92f249d972f1f343 Mon Sep 17 00:00:00 2001 From: Madhur Tandon Date: Mon, 26 Aug 2024 16:55:21 +0530 Subject: [PATCH 11/11] add zip_safe as False --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 1b41d57..756c2b4 100644 --- a/setup.py +++ b/setup.py @@ -94,4 +94,5 @@ def check_tag_version(): "Homepage": "https://pyscript.net", "Repository": "https://github.com/pyscript/pyscript-cli", }, + zip_safe=False, )