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 numpy dependency error #25

Closed
wants to merge 13 commits into from
43 changes: 21 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install linting dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 isort==4.3.21 yapf
- name: Lint with flake8
run: flake8 --max-complexity 20 .
- name: Lint with isort
run: isort -rc --check-only --diff pycocotools/ lvis/
- name: Format with yapf
run: yapf -r -d pycocotools/ lvis/
- name: Install python dependencies
run: pip install numpy
- name: Build and install pycocotools
run: cd pycocotools && rm -rf *.eggs-info && pip install .
- name: Build and install lvis
run: cd lvis && rm -rf *.eggs-info && pip install .
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install linting dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 isort==4.3.21 yapf
- name: Lint with flake8
run: flake8 --max-complexity 20 .
- name: Lint with isort
run: isort -rc --check-only --diff pycocotools/ lvis/
- name: Format with yapf
run: yapf -r -d pycocotools/ lvis/
- name: Install python dependencies
run: pip install numpy
- name: Build and install pycocotools
run: cd pycocotools && rm -rf *.eggs-info && pip install .
- name: Build and install lvis
run: cd lvis && rm -rf *.eggs-info && pip install .
11 changes: 9 additions & 2 deletions pycocotools/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy as np
from setuptools import dist # Install numpy and cython at start
from setuptools import Extension, setup

# To compile and install locally run "python setup.py build_ext --inplace"
Expand All @@ -8,6 +8,13 @@
# the Visual C++ 2015 build tools.
# They can safely be removed.

dist.Distribution().fetch_build_eggs(['cython>=0.27.3', 'numpy'])

try:
import numpy as np
except ImportError:
exit('Please install numpy first.')

ext_modules = [
Extension(
'pycocotools._mask',
Expand All @@ -24,5 +31,5 @@
install_requires=[
'setuptools>=18.0', 'cython>=0.27.3', 'matplotlib>=2.1.0'
],
version='12.0.3',
version='12.0.4',
ext_modules=ext_modules)