0

I am trying to get my python package installed on conda-forge following their guide: https://conda-forge.org/docs/maintainer/adding_pkgs.html. So far, I have managed to successfully setup my package to be installable from pip (and have tested pip install across multiple machines), and am using that as a base to setup the conda-forge installation.

This is my meta.yaml file for publishing on conda, with some personal details removed:

{% set name = "package" %}
{% set version = "1.0.2" %}

package:
  name: "{{ name|lower }}"
  version: "{{ version }}"

source:
  url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz"
  sha256: XXX 

build:
  number: 0
  noarch: python
  script: "{{ PYTHON }} -m pip install . --no-deps -vv "

requirements:
  build:
    - {{ compiler('c') }}
  host:
    - python >=3.0,<3.7
    - pip
    - setuptools
    - numpy >=1.0
    - cython >=0.2
    - scipy >=1.0
    - wheel
  run:
    - python >=3.0,<3.8
    - scipy >=1.0
    - pandas >=0.2
    - numpy >=1.0
    - scikit-learn >=0.2
    - matplotlib >=3.0.0

test:
  imports:
    - package

about:
  home: "URL"
  license: GPL3
  license_family: GPL3
  license_file: LICENSE
  summary: "XXX"
  doc_url: URL
  dev_url: URL

And this is the setup.py:

from setuptools import setup, Extension, find_packages
from setuptools.command.install import install
import subprocess
import os
import numpy as np

extensions = [Extension("*", ["./package/lib/*.pyx"])]
from Cython.Build import cythonize
extensions = cythonize(extensions)

setup(
  name = 'package',
  packages = ['package',
              'package.classes',
              'package.lib'
      ],
  version = '1.0.2',
  license='GPL3',
  description = 'XXX',
  author = 'XXX',
  author_email = 'XXX',
  url = 'URL',
  download_url = 'URL',
  keywords = ['package'],
  install_requires=[
          'numpy',
          'scipy',
          'scikit-learn',
          'pandas'
      ],
  package_data={'package' : ['./lib/*.pyx', './classes/*.sh', './classes/*.dat', './*.cfg']},
  ext_modules = extensions, include_dirs=[np.get_include()]
)

Currently, the package is able to install and package correctly while attempting to pass the pull request tests put forward by conda-forge, however on the test:

test:
  imports:
    - package

it fails owing to the following error:

from package.lib.graph import *
  File "graph.pyx", line 16, in init graph
ImportError: cannot import name dist

graph.pyx is a cython package within package/lib.

I have found similar questions regarding this ImportError elsewhere:

  1. Python error - "ImportError: cannot import name 'dist'"
  2. Matplotlib in py2exe — ImportError: cannot import name dist (File "distutils\__init__.pyc")
  3. Getting ImportError: cannot import name 'dist' while installing flask_dance using pip3

But I am not able to follow the general solution of sudo apt install python3-distutils because this is running on the conda-forge testing pipeline. I have encountered this problem before when installing my package locally direct from github, but have normally resolved it with the sudo apt install python3-distutils, which may explain why the pip install worked on all the machines I tested on.

Any help anyone could provide would be great, thank you.

Zintho
  • 1
  • 2

0 Answers0