diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7f5c8e4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ +# This workflow builds and publishes the package to PyPI when a tag is pushed + +name: Publish Python Package + +on: + push: + tags: + - 'v*' # Trigger on tags starting with 'v' + +jobs: + deploy: + runs-on: ubuntu-latest + + # Grant GITHUB_TOKEN the permissions required to create a release + permissions: + contents: read + id-token: write # Required for trusted publishing + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' # Use a recent Python version for building + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Build package + run: python -m build + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + # No API token needed if using trusted publishing + # with: + # password: ${{ secrets.PYPI_API_TOKEN }} # Use an API Token if not using Trusted Publishing + + # Optional: Create a GitHub Release + # - name: Create GitHub Release + # uses: softprops/action-gh-release@v1 + # with: + # files: dist/* + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index f8475cb..34d9386 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -26,8 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements-dev.txt - pip install -e . + pip install .[dev] - name: Test with pytest run: | pytest diff --git a/publish.sh b/publish.sh deleted file mode 100755 index b621a36..0000000 --- a/publish.sh +++ /dev/null @@ -1,5 +0,0 @@ -# build and publish to -# https://pypi.org/project/livelossplot/ -rm -r dist/ -python setup.py sdist bdist_wheel -twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4525337 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,74 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "livelossplot" +dynamic = ["version"] # Version is read from version.py via setuptools config +description = "Live training loss plot in Jupyter Notebook for Keras, PyTorch and others." +readme = "README.md" +requires-python = ">=3.7" +license = {text = "MIT"} +keywords = ["keras", "pytorch", "plot", "chart", "deep-learning"] +authors = [ + {name = "Piotr Migdał", email = "pmigdal@gmail.com"} +] +classifiers = [ + "Development Status :: 4 - Beta", + "Framework :: Jupyter", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Scientific/Engineering :: Visualization", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "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", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + 'ipython==7.*; python_version<"3.8"', + 'matplotlib', + 'bokeh', + 'numpy<1.22; python_version<"3.8"', +] + +[project.urls] +Homepage = "https://github.com/stared/livelossplot" + +[project.optional-dependencies] +dev = [ + "pytest", + "flake8", + "twine", + "wheel", + "build", + # Add other dev dependencies if needed (e.g., from the old requirements-dev.txt) +] + +[tool.setuptools.dynamic] +# Read version from livelossplot/version.py +version = {attr = "livelossplot.version.__version__"} + +[tool.setuptools.packages.find] +# Look for packages in the root directory (no src layout) +where = ["."] + +[tool.flake8] +exclude = ".git,*migrations*,build*,old*,dist" +max-line-length = 120 + +[tool.yapf] +based_on_style = "facebook" +column_limit = 120 + +# --- Add configuration for tools like flake8 if desired --- +# Example: [tool.flake8] +# ignore = "E501,W503" +# max-line-length = 88 +# exclude = ".git,__pycache__,build,dist" \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index f9a3464..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,5 +0,0 @@ -pytest -flake8 -yapf -jupyter -pdoc3 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8ca4264..0000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[flake8] -exclude = .git,*migrations*,build*,old* -max-line-length = 120 - -[yapf] -based_on_style = facebook -column_limit = 120 diff --git a/setup.py b/setup.py deleted file mode 100644 index 0e435df..0000000 --- a/setup.py +++ /dev/null @@ -1,58 +0,0 @@ -from setuptools import setup, find_packages -from os import path -import re - - -def readme(): - with open('README.md', encoding='utf-8') as f: - return f.read() - - -def version(): - this_directory = path.abspath(path.dirname(__file__)) - with open(path.join(this_directory, 'livelossplot/version.py')) as f: - version_file = f.read() - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) - version = version_match.group(1) - - return version - - -setup( - name='livelossplot', - version=version(), - python_requires=">=3.7", - install_requires=[ - 'ipython==7.*;python_version<"3.8"', - 'matplotlib', 'bokeh', - 'numpy<1.22;python_version<"3.8"', - ], - description='Live training loss plot in Jupyter Notebook for Keras, PyTorch and others.', - long_description=readme(), - long_description_content_type='text/markdown', - url='https://github.com/stared/livelossplot', - author='Piotr Migdał', - author_email='pmigdal@gmail.com', - keywords=['keras', 'pytorch', 'plot', 'chart', 'deep-learning'], - license='MIT', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Framework :: Jupyter', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'Topic :: Scientific/Engineering :: Visualization', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - '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', - 'Programming Language :: Python :: 3.12', - ], - packages=find_packages(), - zip_safe=False -)