Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-development package installation #81

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/QCSchema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: QCSchema

# yamllint disable-line rule:truthy
on: [push, pull_request]

jobs:
test:
name: Test on Python ${{ matrix.python-version }} using ${{ matrix.env-type.env-type-name }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
# yamllint disable rule:braces
env-type:
- { env-type-name: venv, shell: bash }
- { env-type-name: conda, shell: 'bash -l {0}' }
# yamllint enable rule:braces
defaults:
run:
shell: ${{ matrix.env-type.shell }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
if: ${{ matrix.env-type.env-type-name == 'venv' }}
- name: Set up Python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test
auto-activate-base: false
auto-update-conda: true
miniforge-version: latest
python-version: ${{ matrix.python-version }}
if: ${{ matrix.env-type.env-type-name == 'conda' }}
- name: Print Python information
run: |
command -v python
$(command -v python) --version
- name: Update pip and setuptools
run: python -m pip install -U pip setuptools
- name: Print pip config
run: python -m pip config list
- name: Install test dependencies
run: python -m pip install pytest-cov
- name: Install package
run: python -m pip install .
- name: Print installed package contents
run: |
cd ~
PACKAGE_INSTALL_DIR=$(python -c 'import qcschema as _; print(_.__path__[0])')
echo "${PACKAGE_INSTALL_DIR}"
find $PACKAGE_INSTALL_DIR -type f | sort
- name: Print Python environment
run: python -m pip list
- name: Print conda environment
run: conda list
if: ${{ matrix.env-type.env-type-name == 'conda' }}
- name: Print conda info
run: conda info
if: ${{ matrix.env-type.env-type-name == 'conda' }}
- name: Print conda config
run: conda config --show
if: ${{ matrix.env-type.env-type-name == 'conda' }}
- name: Run tests
run: |
# Testing the installed package requires moving out of the source
# directory. There are problems with the pytest cache when trying
# to run from a non-writable dir.
cd ~
PACKAGE_INSTALL_DIR=$(python -c 'import qcschema as _; print(_.__path__[0])')
echo "${PACKAGE_INSTALL_DIR}"
python -m pytest -v --cov=qcschema --cov-report=xml ${PACKAGE_INSTALL_DIR}
# - name: Install docs dependencies
# run: |
# python -m pip install sphinx==1.2.3 sphinxcontrib-napoleon sphinx_rtd_theme numpydoc
# - name: Make docs
# run: make docs
# - name: CodeCov
# users: codecov/codecov-action@v1
# with:
# file: ./coverage.xml
# flags: unittests
# name: codecov-py${{ matrix.python-version }}
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include qcschema *.json
recursive-include qcschema *.schema
Empty file added qcschema/data/v2/__init__.py
Empty file.
Empty file added qcschema/tests/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions tests/test_failures.py → qcschema/tests/test_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"""
import jsonschema
import pytest
import os

import test_helpers
from qcschema.tests import test_helpers
import qcschema

### Test input validation errors
Expand Down
22 changes: 15 additions & 7 deletions tests/test_helpers.py → qcschema/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
Contains helper scripts to assist in testing the schema
"""

import pytest
import os
import glob
import copy
import json
import subprocess

import qcschema
import os


def _read_json_file(*filename):
Expand All @@ -20,15 +15,28 @@ def _read_json_file(*filename):

# Find a few required relative paths
_test_path = os.path.dirname(os.path.abspath(__file__))
_base_path = os.path.dirname(_test_path)


def list_tests(folder, ext=".json", matcher=""):
"""
Lists all tests in a given folder.

Since this function operates under the assumption that tests were expected
in the given folder, raise a RuntimeError if none were found. This is a
workaround for tests being skipped when their parametrizations receive no
values.
"""
files = glob.glob(os.path.join(_test_path, folder, "*" + matcher + "*" + ext))
names = [os.path.basename(x).replace(ext, "") for x in files]

if not files:
raise RuntimeError(
"No files were found in the folder "
"{} with the extension '{}' and matcher '{}'".format(
os.path.abspath(folder), ext, matcher
)
)

return files, names

def get_test(name):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_schema.py → qcschema/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"""
import jsonschema
import pytest
import os

import test_helpers
from qcschema.tests import test_helpers
import qcschema


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
url="https://github.com/MolSSI/QCSchema",
license='',
packages=setuptools.find_packages(),
include_package_data=True,
install_requires=[
'jsonschema',
'pathlib2; python_version < "3.5"', # redundant with jsonschema
Expand All @@ -28,5 +29,5 @@
tests_require=[
'pytest',
],
zip_safe=True,
zip_safe=False,
)