问题描述
为了加快Python软件包中的部分代码的速度,我编写了一个Fortran子例程。在我的本地系统上可以正常工作。这是包的结构。
p_name/
setup.py
p_name/
__init__.py
fortran_sc_folder/
rsp.f95
这是setup.py(的一部分):
from numpy.distutils.core import setup,Extension
ext1 = Extension(name='p_name.fortran_sc_folder.rsp',sources=['p_name/fortran_sc_folder/rsp.f95'])
setup(
...
ext_modules = [ext1]
...
)
在程序内部,我使用以下代码访问模块:
import .fortran_sc_folder.rsp
它可以安装并正常工作,不会引起任何错误。但是,当我推送更改时,它无法通过GitHub操作。错误是:
E ModuleNotFoundError: No module named 'p_name.fortran_cs_folder.rsp'
您知道如何解决此问题,还有在Python包内使用Fortran代码的更好方法吗?
更新: 这是GitHub动作工作流程:
# This workflow will install Python dependencies,run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master,develop ]
pull_request:
branches: [ master,develop ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7,3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup conda
uses: s-weigand/setup-conda@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
conda install -c conda-forge cartopy
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)