0

I created a python package with a dependency that fails to install using pip due to some missing wheels and non pure-pythonic code (needs a Microsoft Visuals Compiler). Other dependencies are installed normally using pip.

the problematic dependency (geopandas->pyproj) is only used in part of my package so I was wondering if I could allow the user to install my package using pip with all functionality except the functions that require the dependency. If the user wants to use the functions in the package that requires the dependency one could simply install it in addition to my package allowing for more flexibility (make use of pip, conda, compile etc.):

pip install mypackage
conda install dependency

and then

import mypackage
import dependency

bar = mypackage.function_that_requires_dependency(foo)

If the user cannot install the dependency, it can still use all parts of my package that do not rely on it.

pip install mypackage

and then

import mypackage

bar = mypackage.function_that_does_not_require_dependency(foo)

Is there a way to accomplish this? I currently have all my imports at the beginning of my init.py file.

package github
package PyPi

Rutger Hofste
  • 4,073
  • 3
  • 33
  • 44
  • 1
    Possible duplicate of [Optional dependencies in distutils / pip](https://stackoverflow.com/questions/6237946/optional-dependencies-in-distutils-pip) – Jim Stewart Jan 09 '18 at 15:54
  • Specifically, see https://stackoverflow.com/a/13681679/719547 in that question. – Jim Stewart Jan 09 '18 at 15:54
  • Update: I solved the pip installation in Linux by installing gcc first. However for my package testing I use Travis CI. Looking for a way to install a compiler in Linux automatically. – Rutger Hofste Jan 09 '18 at 15:54

0 Answers0