Skip to content

Commit

Permalink
Merge pull request #5 from ap--/packaging-changes
Browse files Browse the repository at this point in the history
Packaging changes
  • Loading branch information
EBjerrum committed Oct 14, 2022
2 parents 54e3452 + 2c1f408 commit 778fde7
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 17 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/run_pytests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: scikit_mol ci

on: [push, pull_request]

jobs:
# run pytests for scikit_mol
tests:
name: pytest ${{ matrix.os }}::py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 6
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10"]
include:
# test python version compatibility on linux only
- os: ubuntu-latest
python-version: 3.9
- os: ubuntu-latest
python-version: 3.8
- os: ubuntu-latest
python-version: 3.7
steps:
- name: Checkout scikit_mol
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install scikit_mol
run: python -m pip install -e .[dev]
- name: Cache tests/data
uses: actions/cache@v3
with:
path: tests/data
key: ${{ runner.os }}-${{ hashFiles('tests/conftest.py') }}
- name: Run Tests
run: pytest --cov=./scikit_mol .
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ dmypy.json
scikit-mol.code-workspace
notebooks/25747817
*.ipynb

# test data
tests/data/

# setuptools_scm version
scikit_mol/_version.py
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
prune .github
exclude .git*

27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = [
"setuptools >= 64",
"setuptools_scm[toml]>=6.2",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "scikit_mol/_version.py"
version_scheme = "post-release"

[tool.pytest.ini_options]
addopts = [
"-v",
]

[tool.coverage.run]
source = ["scikit_mol"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"if TYPE_CHECKING:",
"if MYPY:",
"^\\s+[.][.][.]$",
]
4 changes: 4 additions & 0 deletions scikit_mol/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
try:
from scikit_mol._version import __version__
except ImportError: # pragma: no cover
__version__ = "not-installed"
45 changes: 45 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[metadata]
name = scikit_mol
url = https://github.com/EBjerrum/scikit-mol
download_url = https://github.com/EBjerrum/scikit-mol
license = Apache-2.0
license_file = LICENSE
description = scikit-learn classes for molecule transformation
long_description = file: README.md
long_description_content_type = text/markdown
author = Esben Jannik Bjerrum
author_email = esben@cheminformania.com
classifiers =
Development Status :: 3 - Alpha
Intended Audience :: Science/Research
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Scientific/Engineering
Topic :: Utilities
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Operating System :: Unix
Operating System :: MacOS

[options]
packages = find:
python_requires = >=3.7
install_requires =
rdkit
numpy
pandas
scikit-learn

[options.packages.find]
exclude =
tests/*

[options.extras_require]
dev =
pytest>=6
pytest-cov
17 changes: 0 additions & 17 deletions setup.py

This file was deleted.

47 changes: 47 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import hashlib
import shutil
from pathlib import Path
from pathlib import PurePath
from urllib.parse import urlsplit
from urllib.request import urlopen

import pandas as pd
import pytest


TEST_DATA_URL = "https://ndownloader.figshare.com/files/25747817"
TEST_DATA_MD5 = "1ec89bde544c3c4bc400d5b75315921e"


def md5(fn):
m = hashlib.md5()
with open(fn, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
m.update(chunk)
return m.hexdigest()


@pytest.fixture(scope="session")
def data_pth(tmp_path_factory) -> Path:
"""download the smallest aperio test image svs or use local"""
filename = PurePath(urlsplit(TEST_DATA_URL).path).name
data_dir = Path(__file__).parent / "data"
data_dir.mkdir(parents=True, exist_ok=True)
data_fn = data_dir / filename

if not data_fn.is_file():
# download svs from openslide test images
with urlopen(TEST_DATA_URL) as response, open(
data_fn, "wb"
) as out_file:
shutil.copyfileobj(response, out_file)

if md5(data_fn) != TEST_DATA_MD5: # pragma: no cover
shutil.rmtree(data_fn)
pytest.fail("incorrect md5")

yield data_fn.absolute()

@pytest.fixture()
def data(data_pth) -> pd.DataFrame:
yield pd.read_csv(data_pth)
4 changes: 4 additions & 0 deletions tests/test_scikit_mol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

def test_load_data(data):
assert len(data) > 0

0 comments on commit 778fde7

Please sign in to comment.