Repository: knodle/knodle (language: python)

Issue:
knodle in pypi



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/main_deploy.yml b/.github/workflows/main_deploy.yml
index fd907eb2..5b8e2966 100644
--- a/.github/workflows/main_deploy.yml
+++ b/.github/workflows/main_deploy.yml
@@ -1,20 +1,33 @@
-name: Build and Deploy on Master
+name: Upload to PIP on Release
 
 on:
-  push:
-    branches:
-      - master
+  release:
+    types: [created]
 
 jobs:
-  build:
+  upload:
     runs-on: ubuntu-latest
 
     steps:
-      - name: Build and deploy
-        env:
-          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
-          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
+      - uses: actions/checkout@v2
+
+      - uses: actions/setup-python@v2
+        with:
+          python-version: 3.7
+
+      - name: "Installs dependencies"
+        run: |
+          python3 -m pip install --upgrade pip
+          python3 -m pip install setuptools wheel twine
+
+      - name: "Tag Update"
+        run: |
+          python3 update_version_from_tag.py $(git tag --points-at HEAD)
+
+      - name: "Builds and uploads to PyPI"
         run: |
-          pip install -r requirements_dev.txt
-          python setup.py sdist bdist_wheel
-          # twine upload dist/* FOR UPLOADING PURPOSES
+          python3 setup.py sdist bdist_wheel
+          python3 -m twine upload dist/*
+        env:
+          TWINE_USERNAME: __token__
+          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 3708bdf1..9ed70eb4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
 *.so
 
 # Packages
+PKG-INFO
 *.egg
 *.egg-info
 dist
@@ -19,6 +20,9 @@ lib
 lib64
 __pycache__
 
+# package helper
+knodle-*
+
 # Installer logs
 pip-log.txt
 
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 00000000..d8afddc5
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,32 @@
+#
+# Use .add_data_files and .add_data_dir methods in a appropriate
+# setup.py files to include non-python files such as documentation,
+# data, etc files to distribution (*for installation*).
+# Avoid using MANIFEST.in for that.
+#
+include MANIFEST.in
+include pyproject.toml
+include README.md
+include LICENSE
+
+# Note that sub-directories that don't have __init__ are apparently not
+# included by 'recursive-include', so list those separately
+recursive-include knodle *
+recursive-include tests  *
+prune tutorials
+
+# Exclude generated files
+prune */__pycache__
+global-exclude *.pyc *.pyo *.pyd *.swp *.bak *~
+
+#### save for later ####
+# Exclude license file that we append to the main license when running
+# `python setup.py sdist`
+#exclude LICENSES_bundled.txt
+#include pytest.ini
+#include *.txt
+#include site.cfg.example
+#include runtests.py
+#include tox.ini
+#include .coveragerc
+
diff --git a/README.md b/README.md
index 7382d2b3..b38e0257 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-<img src="./knodle_logo.png" height="100"/>
+<img src="http://knodle.cc/static/logo-866f6c91f8135d66107abccbec7bf77e.png" height="100">
 
 ### Knowledge infused deep learning framework
 
diff --git a/knodle/__init__.py b/knodle/__init__.py
index 088191c5..fe1579b8 100644
--- a/knodle/__init__.py
+++ b/knodle/__init__.py
@@ -1,9 +1,8 @@
 """knodle - Knowledge infused deep learning framework"""
 
-
-__version__ = "0.1.0"
 __author__ = "knodle <knodle@cs.univie.ac.at>"
 __all__ = []
+from knodle.version import __version__
 
 import logging
 
@@ -12,6 +11,6 @@
 formatter = logging.Formatter("%(asctime)s %(name)-12s %(levelname)-8s %(message)s")
 handler.setFormatter(formatter)
 logger.addHandler(handler)
-logger.setLevel(logging.DEBUG)
+logger.setLevel(logging.INFO)
 
 logger.info("Initalized logger")
diff --git a/knodle/version.py b/knodle/version.py
index 6a9beea8..058ef7a7 100644
--- a/knodle/version.py
+++ b/knodle/version.py
@@ -1,1 +1,3 @@
-__version__ = "0.4.0"
+# This is a placeholder file and is not supposed to be maintained.
+# This file will be replaced with an up-to-date value during package build via github action.
+__version__ = '0.0.0'
diff --git a/knodle_logo.png b/knodle_logo.png
index 4e7bbc88..93045af0 100644
Binary files a/knodle_logo.png and b/knodle_logo.png differ
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..374b58cb
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,6 @@
+[build-system]
+requires = [
+    "setuptools>=42",
+    "wheel"
+]
+build-backend = "setuptools.build_meta"
diff --git a/requirements.txt b/requirements.txt
index 0877ad45..318e1050 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,14 +3,14 @@ joblib
 tqdm
 
 # Computation
-numpy
+numpy<1.20.0,>=1.16.5
 scipy
 pandas
 
 # ML frameworks
 scikit-learn
 torch
-snorkel
+snorkel<=0.9.7
 
 # graphics
-matplotlib
\ No newline at end of file
+matplotlib
diff --git a/setup.py b/setup.py
index fc5a971a..0b0eed33 100644
--- a/setup.py
+++ b/setup.py
@@ -23,29 +23,34 @@ def read(filename):
 
 test_requirements = ["pytest", "pytest-cov"]
 
+# use external package to extract tag of the latest release as version
+# https://pypi.org/project/setuptools-git-versioning/
+
 setup(
     name="knodle",
     version=VERSION.get("__version__"),
-    url="https://github.com/knodle/knodle",
-    license="TBC",
+    url="http://knodle.cc",
+    project_urls={
+        "github": "https://github.com/knodle/knodle",
+        "Bug Tracker": "https://github.com/knodle/knodle/issues"
+    },
+    license="Apache 2.0",
     author="knodle",
     author_email="knodle@cs.univie.ac.at",
     description="Knowledge infused deep learning framework",
     long_description=read("README.md"),
-    packages=find_packages(exclude=("tests",)),
+    long_description_content_type="text/markdown",
+    packages=find_packages(exclude=["tests"]),
+    package_dir={'knodle': 'knodle'},
     install_requires=requirements,
     tests_require=test_requirements,
     extras_require={"test": test_requirements},
     classifiers=[
         "Development Status :: 2 - Pre-Alpha",
-        "License :: OSI Approved :: MIT License",
-        "Programming Language :: Python",
-        "Programming Language :: Python :: 2",
-        "Programming Language :: Python :: 2.7",
-        "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.4",
-        "Programming Language :: Python :: 3.5",
+        "License :: OSI Approved :: Apache Software License",
+        "Programming Language :: Python :: 3 :: Only",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8"
     ],
 )
diff --git a/tutorials/__init__.py b/tutorials/__init__.py
deleted file mode 100644
index 088191c5..00000000
--- a/tutorials/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""knodle - Knowledge infused deep learning framework"""
-
-
-__version__ = "0.1.0"
-__author__ = "knodle <knodle@cs.univie.ac.at>"
-__all__ = []
-
-import logging
-
-logger = logging.getLogger()
-handler = logging.StreamHandler()
-formatter = logging.Formatter("%(asctime)s %(name)-12s %(levelname)-8s %(message)s")
-handler.setFormatter(formatter)
-logger.addHandler(handler)
-logger.setLevel(logging.DEBUG)
-
-logger.info("Initalized logger")
diff --git a/update_version_from_tag.py b/update_version_from_tag.py
new file mode 100644
index 00000000..7aefa011
--- /dev/null
+++ b/update_version_from_tag.py
@@ -0,0 +1,12 @@
+import sys
+import re
+
+tag = sys.argv[1]
+version_pattern = re.compile("\d+(.\d+)+(.(dev|post)\d+)?")
+version = re.search(version_pattern, tag).group()
+
+with open("knodle/version.py", "w") as fp:
+    fp.writelines([
+        "# this is an auto-generated file on release\n",
+        f"__version__ = '{version}'\n"
+    ])
\ No newline at end of file


Test patch:
diff --git a/.github/workflows/test_deploy.yml b/.github/workflows/test_deploy.yml
new file mode 100644
index 00000000..5f1679fe
--- /dev/null
+++ b/.github/workflows/test_deploy.yml
@@ -0,0 +1,51 @@
+# This is a basic workflow to help you get started with Actions
+
+name: Upload to TestPyPI
+
+# Controls when the action will run. 
+on:
+  workflow_dispatch:
+    inputs:
+      release-version:
+        description: 'Test release version tag'
+        default: 'v0.1.0'
+        required: true  # Triggers the workflow on push to the master branch
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+  # This workflow contains a single job called "build"
+  build:
+    # The type of runner that the job will run on
+    runs-on: ubuntu-latest
+
+    # Steps represent a sequence of tasks that will be executed as part of the job
+    steps:
+      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+      - uses: actions/checkout@v2
+
+      # Sets up python3
+      - uses: actions/setup-python@v2
+        with:
+          python-version: 3.7
+
+      # Installs and upgrades pip, installs other dependencies and installs the package from setup.py
+      - name: "Installs and upgrades pip, installs other dependencies and installs the package from setup.py"
+        run: |
+          # Upgrade pip
+          python3 -m pip install --upgrade pip
+          # Install build deps
+          python3 -m pip install setuptools wheel twine
+
+      - name: "Tag Release"
+        run: |
+          python3 update_version_from_tag.py ${{ github.event.inputs.release-version }}
+
+      # Upload to TestPyPI
+      - name: Build and Upload to TestPyPI
+        run: |
+          python3 setup.py sdist bdist_wheel
+          python3 -m twine upload dist/*
+        env:
+          TWINE_USERNAME: __token__
+          TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
+          TWINE_REPOSITORY: testpypi