I adapted the workflow for testing my own python package in ubuntu-latest and windows-latest with python 3.8 is below:
name: Test with Mamba in Linux & Windows
on:
push:
branches: [ continuous-integration ]
tags:
- "v*.*.*"
pull_request:
branches: [ continuous-integration ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: Python ${{ matrix.python-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8']
os: ["ubuntu-latest", "windows-latest"]
include:
- os: ubuntu-latest
environment-file: etc/environment-dev.yml
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
- os: windows-latest
environment-file: etc/environment-dev.yml
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Setup conda environment with mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
use-mamba: true
activate-environment: ptac-dev
python-version: ${{ matrix.python-version }}
condarc-file: ${{ matrix.condarc-file }}
environment-file: ${{ matrix.environment-file }}
miniforge-variant: ${{ matrix.miniforge-variant }}
miniforge-version: ${{ matrix.miniforge-version }}
- name: Install PtAC (name of my own python package)
run: |
python setup.py install
conda list
conda info --all
- name: Test code
run: |
coverage run --source ./ptac --module pytest --verbose
coverage xml -i
coverage report -m
- name: Upload coverage report
uses: codecov/codecov-action@v1
using environment-dev.yml below:
name: ptac-dev
channels:
- conda-forge
- defaults
dependencies:
# required
- python=3.8
- osmnx==1.1.1
- networkx>=2.5
- numpy==1.20.3
- Shapely==1.7.1
- pyproj==3.1.0
- geopandas==0.9.0
- rasterio==1.2.4
- pandas==1.2.4
# linting/testing
- pylint
- coverage
- flake8
- isort
- pydocstyle
- pytest
- sphinx
- sphinx_rtd_theme
- setuptools
The workflow runs through and passing all the tests in linux whereas it fails in windows with:
platform win32 -- Python 3.8.13[pypy-7.3.9-final], pytest-7.1.2, pluggy-1.0.0 -- C:\Miniconda3\envs\ptac-dev\python.exe
cachedir: .pytest_cache
rootdir: D:\a\PtAC\PtAC
collecting ... collected 0 items / 1 error
=================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_ptac.py _____________________
ImportError while importing test module 'D:\a\PtAC\PtAC\tests\test_ptac.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Miniconda3\envs\ptac-dev\Lib\importlib\__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests\test_ptac.py:6: in <module>
import geopandas as gpd
C:\Miniconda3\envs\ptac-dev\lib\site-packages\geopandas\__init__.py:1: in <module>
from geopandas._config import options # noqa
C:\Miniconda3\envs\ptac-dev\lib\site-packages\geopandas\_config.py:126: in <module>
default_value=_default_use_pygeos(),
C:\Miniconda3\envs\ptac-dev\lib\site-packages\geopandas\_config.py:112: in _default_use_pygeos
import geopandas._compat as compat
C:\Miniconda3\envs\ptac-dev\lib\site-packages\geopandas\_compat.py:7: in <module>
import pandas as pd
C:\Miniconda3\envs\ptac-dev\lib\site-packages\pandas\__init__.py:17: in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
E ImportError: Unable to import required dependencies:
E numpy:
E
E IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
E
E Importing the numpy C-extensions failed. This error can happen for
E many reasons, often due to issues with your setup or how NumPy was
E installed.
E
E We have compiled some common reasons and troubleshooting tips at:
E
E https://numpy.org/devdocs/user/troubleshooting-importerror.html
E
E Please note and check the following:
E
E * The Python version is: Python3.8 from "C:\Miniconda3\envs\ptac-dev\python.exe"
E * The NumPy version is: "1.20.3"
E
E and make sure that they are the versions you expect.
E Please carefully study the documentation linked above for further help.
E
E Original error was: No module named 'numpy.core._multiarray_umath'
=========================== short test summary info ===========================
ERROR tests/test_ptac.py
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
============================== 1 error in 1.73s ===============================
C:\Miniconda3\envs\ptac-dev\lib\site-packages\coverage\control.py:794: CoverageWarning: No data was collected. (no-data-collected)
self._warn("No data was collected.", slug="no-data-collected")
Error: Process completed with exit code 2.
Any idea how I can fix the run on windows? I would be glad to have help on this issue. Thanks so much in advance!