Skip to content

Commit

Permalink
Use setuptools and pip for packaging and installation (#60)
Browse files Browse the repository at this point in the history
* Use setuptools and piip for packaging and installation

* Less indent, to keep flake8 happy
  • Loading branch information
neilflood committed Aug 10, 2022
1 parent cd0d5b6 commit 210187e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
20 changes: 10 additions & 10 deletions INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ First unpack the bundle. For the tar.gz file, this would be
For the zip file this would be
unzip -q python-fmask-0.4.2.zip

The installation uses Python's distutils packaging, so the following commands are fairly standard.
The installation uses setuptools packaging. This is best driven by pip
(direct use of setup.py is now deprecated by the setuptools people), so
the following commands are fairly standard.

Build the code
cd python-fmask-0.4.2
python setup.py build
pip install .


If all goes well with that, then install. To install in default locations, just use
python setup.py install

If you wish to install in a non-default location, use
python setup.py install --prefix=/yourChosenDirectory
pip install . --prefix=/yourChosenDirectory

If installed in a non-default location, you will then need to ensure that the right environment
variables are set. For simple bash syntax, this would be something like:
If installed in a non-default location, you will then need to ensure that the
right environment variables are set. For simple bash syntax, this would be
something like:
export PATH="/yourChosenDirectory/bin:$PATH"
export PYTHONPATH="/yourChosenDirectory/lib/python2.7/site-packages:$PATH"
export PYTHONPATH="/yourChosenDirectory/lib/pythonX.X/site-packages:$PYTHONPATH"

Note that the python2.7 sub-directory needs to match your version of python.
Note that the pythonX.X sub-directory needs to match your version of python.
19 changes: 10 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
import glob
import fmask

# If we fail to import the numpy version of setup(), still try to proceed, as it is possibly
# because we are being run by ReadTheDocs, and so we just need to be able to generate documentation.
from setuptools import setup, Extension

try:
from numpy.distutils.core import setup, Extension
from numpy import get_include as numpy_get_include
withExtensions = True
except ImportError:
from numpy.distutils.core import setup
withExtensions = False

# Are we installing the command line scripts?
Expand All @@ -38,12 +37,14 @@

if withExtensions:
# This is for a normal build
fillminimaC = Extension(name='_fillminima',
define_macros=[NUMPY_MACROS],
sources=['src/fillminima.c'])
fillminimaC = Extension(name='_fillminima',
define_macros=[NUMPY_MACROS],
sources=['src/fillminima.c'],
include_dirs=[numpy_get_include()])
valueIndexesC = Extension(name='_valueindexes',
define_macros=[NUMPY_MACROS],
sources=['src/valueindexes.c'])
define_macros=[NUMPY_MACROS],
sources=['src/valueindexes.c'],
include_dirs=[numpy_get_include()])
extensionsList = [fillminimaC, valueIndexesC]
else:
# This would be for a ReadTheDocs build.
Expand Down

0 comments on commit 210187e

Please sign in to comment.