diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml new file mode 100644 index 0000000..1ddf084 --- /dev/null +++ b/.github/workflows/publish_to_pypi.yml @@ -0,0 +1,30 @@ +name: Upload new PaDELPy version to PyPI + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 0000000..2a458b7 --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,26 @@ +name: Run PaDELPy tests + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + pip install pytest pytest-md + - name: Install package + run: python -m pip install . + - name: Run tests + uses: pavelzw/pytest-action@v2 + with: + emoji: false + report-title: 'PaDELPy test report' \ No newline at end of file diff --git a/README.md b/README.md index 16ccaa1..d7247fb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Installation via cloned repository: ``` $ git clone https://github.com/ecrl/padelpy $ cd padelpy -$ python setup.py install +$ pip install . ``` PaDEL-Descriptor is bundled into PaDELPy, therefore an external installation/download of PaDEL-Descriptor is not necessary. There are currently no additional Python dependencies for PaDELPy, however it requires an installation of the [Java JRE](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) version 6+. diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index c78004c..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Python package -# Create and test a Python package on multiple Python versions. -# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/python - -trigger: -- master - -pool: - vmImage: 'ubuntu-latest' - -steps: -- task: UsePythonVersion@0 - inputs: - versionSpec: '3.8' - architecture: 'x64' - -- script: | - python -m pip install --upgrade pip setuptools wheel - python setup.py install - displayName: 'Install dependencies' - -- script: | - cd tests - python test.py - displayName: 'Unit Testing' diff --git a/padelpy/__init__.py b/padelpy/__init__.py index 1180e4c..bd6354c 100644 --- a/padelpy/__init__.py +++ b/padelpy/__init__.py @@ -1,3 +1,2 @@ from .wrapper import padeldescriptor from .functions import from_mdl, from_smiles, from_sdf -__version__ = '0.1.13' diff --git a/padelpy/version.py b/padelpy/version.py index 5d258e1..36019fd 100644 --- a/padelpy/version.py +++ b/padelpy/version.py @@ -1,4 +1,3 @@ -VERSION = (0, 1, 14, "") +import pkg_resources -__version__ = ".".join(map(str, VERSION[:-1])) -__release__ = ".".join(map(str, VERSION)) +__version__ = pkg_resources.get_distribution("padelpy").version diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..37b27e1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,30 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = true + +[project] +name = "padelpy" +version = "0.1.15" +authors = [ + { name="Travis Kessler", email="travis.j.kessler@gmail.com" }, +] +description = "A Python wrapper for PaDEL-Descriptor software" +readme = "README.md" +requires-python = ">=3.11" +classifiers = [ + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://github.com/ecrl/padelpy" +"Bug Tracker" = "https://github.com/ecrl/padelpy/issues" + +[tool.pytest.ini_options] +filterwarnings = [ + "ignore::DeprecationWarning", +] \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index a9f7cd1..0000000 --- a/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -from setuptools import setup - - -def get_readme(): - """Load README.rst for display on PyPI.""" - with open('README.md') as fhandle: - return fhandle.read() - - -def get_version_info(): - """Read __version__ from version.py, using exec, not import.""" - fn_version = os.path.join("padelpy", "version.py") - myglobals = {} - with open(fn_version, "r") as f: - # pylint: disable=exec-used - exec(f.read(), myglobals) - return myglobals["__version__"] - - -VERSION = get_version_info() - -setup( - name='padelpy', - version=VERSION, - description='A Python wrapper for PaDEL-Descriptor', - long_description=get_readme(), - long_description_content_type='text/markdown', - url='https://github.com/ecrl/padelpy', - author='Travis Kessler', - author_email='Travis_Kessler@student.uml.edu', - license='MIT', - packages=['padelpy'], - install_requires=[], - package_data={ - 'padelpy': [ - 'PaDEL-Descriptor/*', - 'PaDEL-Descriptor/lib/*', - 'PaDEL-Descriptor/license/*' - ] - }, - zip_safe=False -) diff --git a/tests/test.py b/tests/test.py deleted file mode 100644 index 5dd7a74..0000000 --- a/tests/test.py +++ /dev/null @@ -1,37 +0,0 @@ -import unittest -from collections import OrderedDict - -from padelpy import from_mdl, from_sdf, from_smiles - - -class TestAll(unittest.TestCase): - - def test_from_smiles(self): - descriptors = from_smiles('CCC') - self.assertEqual(len(descriptors), 1875) - self.assertAlmostEqual(float(descriptors['MW']), 44.0626, 4) - self.assertEqual(int(descriptors['nC']), 3) - - def test_multiple_smiles(self): - smiles = ['CCC', 'CCCC'] - descriptors = from_smiles(smiles) - self.assertEqual(len(descriptors), 2) - self.assertEqual(len(descriptors[0]), 1875) - - def test_errors(self): - bad_smiles = 'SJLDFGSJ' - self.assertRaises(RuntimeError, from_smiles, bad_smiles) - bad_smiles = ['SJLDFGSJ', 'CCC'] - self.assertRaises(RuntimeError, from_smiles, bad_smiles) - - def test_from_sdf(self): - """Test SDF file input functionality.""" - descriptors = from_sdf("aspirin_3d.sdf")[0] - self.assertEqual(len(descriptors), 1875) - self.assertAlmostEqual(float(descriptors['MW']), 180.04225, 4) - self.assertAlmostEqual(float(descriptors['SsCH3']), 1.2209, 4) - self.assertEqual(int(descriptors['nC']), 9) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_all.py b/tests/test_all.py new file mode 100644 index 0000000..6b9873c --- /dev/null +++ b/tests/test_all.py @@ -0,0 +1,34 @@ +import pytest + +from padelpy import from_sdf, from_smiles + + +def test_from_smiles(): + descriptors = from_smiles('CCC') + assert len(descriptors) == 1875 + assert float(descriptors['MW']) == pytest.approx(44.0626, 1e-4) + assert int(descriptors['nC']) == 3 + + +def test_multiple_smiles(): + smiles = ['CCC', 'CCCC'] + descriptors = from_smiles(smiles) + assert len(descriptors) == 2 + assert len(descriptors[0]) == 1875 + + +def test_errors(): + bad_smiles = 'SJLDFGSJ' + with pytest.raises(RuntimeError): + _ = from_smiles(bad_smiles) + bad_smiles = ['SJLDFGSJ', 'CCC'] + with pytest.raises(RuntimeError): + _ = from_smiles(bad_smiles) + + +def test_from_sdf(): + descriptors = from_sdf('tests/aspirin_3d.sdf')[0] + assert len(descriptors) == 1875 + assert float(descriptors['MW']) == pytest.approx(180.04225, 1e-4) + assert float(descriptors['SsCH3']) == pytest.approx(1.2209, 1e-4) + assert int(descriptors['nC']) == 9