Skip to content

Commit cb114bf

Browse files
committed
Making package pip installable
- Adding package name and dependencies - Updating readme - Adding automatic download of gco_src
1 parent 38a552a commit cb114bf

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ See my blog for examples and comments: [peekaboo-vision.blogspot.com](https://pe
1212
Installation
1313
------------
1414

15+
With Pip
16+
--------
17+
- Run `pip install git+git://amueller/gco_python`
18+
1519
For Linux
1620
---------
1721
- Download and install Cython (use your package manager).

setup.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
from distutils.core import setup
22
from distutils.extension import Extension
3-
from Cython.Distutils import build_ext
43
import os
5-
import numpy
64

7-
gco_directory = "gco_src"
5+
try:
6+
# Attempt to set up the cython module
7+
from Cython.Distutils import build_ext
8+
import numpy
89

9-
files = ['GCoptimization.cpp', 'graph.cpp', 'LinkedBlockList.cpp',
10-
'maxflow.cpp']
10+
gco_directory = "gco_src"
1111

12-
files = [os.path.join(gco_directory, f) for f in files]
13-
files.insert(0, "gco_python.pyx")
12+
files = ['GCoptimization.cpp', 'graph.cpp', 'LinkedBlockList.cpp',
13+
'maxflow.cpp']
1414

15-
setup(cmdclass={'build_ext': build_ext},
16-
ext_modules=[Extension("pygco", files, language="c++",
17-
include_dirs=[gco_directory, numpy.get_include()],
18-
library_dirs=[gco_directory],
19-
extra_compile_args=["-fpermissive"])])
15+
files = [os.path.join(gco_directory, f) for f in files]
16+
files.insert(0, "gco_python.pyx")
17+
18+
setup(
19+
name='pygco',
20+
install_requires=['cython', 'numpy'],
21+
cmdclass={'build_ext': build_ext},
22+
ext_modules=[Extension(
23+
"pygco", files, language="c++",
24+
include_dirs=[gco_directory, numpy.get_include()],
25+
library_dirs=[gco_directory],
26+
extra_compile_args=["-fpermissive"]
27+
)],
28+
)
29+
except ImportError:
30+
# If cython or numpy are not available, then do not try to configure the
31+
# cython extension, just record that we need them as dependencies
32+
setup(
33+
name='pygco',
34+
install_requires=['cython', 'numpy']
35+
)

0 commit comments

Comments
 (0)