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

test with install from wheel, instead of from source #90

Closed
wants to merge 16 commits into from
Closed
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: 75 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,59 @@ on:
branches: [ master ]

jobs:
test:
build-wheel:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: test package before building wheel
run: |
python -m pip install numpy pyparsing pytest pytest-cov
pytest -v

- name: build wheel
run: |
python -m pip install build
python -m build

- name: upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl

check-docs-build:
runs-on: ubuntu-latest
needs: build-wheel

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies for building docs
run: |
python -m pip install -e .[dev]
python -m pip install numpy scipy matplotlib sphinx

- name: check that the docs build
run: |
make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html

# Test the wheel on different platforms
test:
runs-on: ${{ matrix.cfg.os }}
needs: build-wheel

strategy:
matrix:
cfg:
Expand All @@ -19,6 +69,7 @@ jobs:
- { os: ubuntu-latest, py: 3.11, doc: 1 }
- { os: windows-latest, py: 3.11 }
- { os: macos-latest, py: 3.11 }
fail-fast: false

steps:
- uses: actions/checkout@v4
Expand All @@ -28,18 +79,31 @@ jobs:
with:
python-version: ${{ matrix.cfg.py }}

- name: Install Python dependencies
- name: Download the wheel
uses: actions/download-artifact@v4
with:
name: wheel
path: dist

- name: Install the wheel for Windows configuration
if: ${{ runner.os == 'Windows' }}
run: |
python -m pip install --upgrade pip
python -m pip install wheel setuptools
python -m pip install numpy scipy matplotlib pytest pytest-cov
$wheel = Get-ChildItem -Path dist -Filter "periodictable*.whl" | Select-Object -First 1
python -m pip install $wheel.FullName
shell: pwsh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not liking the duplication.

Presumably the following fails in Windows?

name: Install the wheel
      run: python -m pip install dist/periodictable*.whl

How about:

name: Install the wheel
      run: |
        cd dist
        python -m pip install periodictable*.whl

Does windows restore the working directory after powershell exits, or does the cd leak into the next command?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cd does not leak. Duplication is not needed if we use bash as the shell on all platforms, which is straightforward. I just have to look it up.


- name: Test with pytest
- name: Install the wheel for configurations other than Windows
if: ${{ runner.os != 'Windows' }}
run: python -m pip install dist/periodictable*.whl

- name: Install Python dependencies
run: |
pytest -v
python -m pip install pytest pytest-cov

- name: check that the docs build (linux only)
if: matrix.cfg.doc == 1
# Change into the test directory to test the wheel so that the
# source directory is not on the path. Full tests with coverage are
# run before building the wheel.
- name: Test wheel with pytest
run: |
python -m pip install sphinx
make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html
cd test
pytest -v --pyargs --import-mode=append periodictable . ../doc/sphinx/guide
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include LICENSE.txt
include README.rst
include periodictable/activation.dat
graft periodictable/xsf
graft doc
prune doc/sphinx/_build
prune doc/sphinx/build
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/guide/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The simplest solution is to load it directly when your package is imported.
In the current example, this could be done by adding the following
line to the end of the file::

init(periodictable.core.elements)
init(periodictable.core.default_table())

This would be fine for the current example because the table size is
small and load time is fast. For large tables, you may wish to
Expand Down
15 changes: 15 additions & 0 deletions periodictable/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,25 @@ def fasta_table():

beta_casein = "RELEELNVPGEIVESLSSSEESITRINKKIEKFQSEEQQQTEDELQDKIHPFAQTQSLVYPFPGPIPNSLPQNIPPLTQTPVVVPPFLQPEVMGVSKVKEAMAPKHKEMPFPKYPVEPFTESQSLTLTDVENLHLPLPLLQSWMHQPHQPLPPTVMFPPQSVLSLSQSKVLPVPQKAVPYPQRDMPIQAFLLYQEPVLGPVRGPFPIIV"

## Uncomment to show package path on CI infrastructure
#def doctestpath():
# """
# Checking import path for doctests::
#
# >>> import periodictable
# >>> print(f"Path to imported periodictable in docstr is {periodictable.__file__}")
# some path printed here
# """

def test():
from periodictable.constants import avogadro_number
elements = default_table()

## Uncomment to show package path on CI infrastructure
#import periodictable
#print(f"Path to imported periodictable in package is {periodictable.__file__}")
#print(fail_test)

# Beta casein results checked against Duncan McGillivray's spreadsheet
# name Hmass Dmass vol den #el xray Hsld Dsld
# =========== ======= ======= ======= ===== ===== ===== ===== =====
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[pytest]
addopts = --doctest-modules --doctest-glob=*.rst --cov=periodictable
doctest_optionflags = ELLIPSIS
pythonpath = doc/sphinx
testpaths = periodictable test doc/sphinx/guide
python_files = *.py
python_classes = NoClassTestsWillMatch
Expand Down
4 changes: 4 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from periodictable import H, O, Fe, helium, elements, data_files

def test():
## Uncomment to print the package path on the CI infrastructure
#import periodictable
#print(f"Path to imported periodictable in test dir is {periodictable.__file__}")
#print(fail_test)
# Check that we can access element properties
assert H.name == "hydrogen"
assert H.symbol == "H"
Expand Down