0

我正在尝试按照他们的指南在 conda-forge 上安装我的 python 包:https ://conda-forge.org/docs/maintainer/adding_pkgs.html 。到目前为止,我已经成功地将我的包设置为可以从 pip 安装(并且已经在多台机器上测试了 pip install ),并以此为基础来设置 conda-forge 安装。

这是我在 conda 上发布的 meta.yaml 文件,删除了一些个人详细信息:

{% 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

这是 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()]
)

目前,该软件包能够在尝试通过 conda-forge 提出的拉取请求测试时正确安装和打包,但是在测试中:

test:
  imports:
    - package

由于以下错误而失败:

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

graph.pyx 是 package/lib 中的一个 cython 包。

我在其他地方发现了类似的问题ImportError

  1. Python 错误 - “ImportError:无法导入名称‘dist’”
  2. py2exe 中的 Matplotlib — ImportError: cannot import name dist (File "distutils\__init__.pyc")
  3. 获取 ImportError:使用 pip3 安装 flask_dance 时无法导入名称“dist”

但我无法遵循的一般解决方案,sudo apt install python3-distutils因为这是在 conda-forge 测试管道上运行的。我之前在本地直接从 github 安装我的包时遇到过这个问题,但通常使用sudo apt install python3-distutils.

任何人都可以提供的任何帮助都会很棒,谢谢。

4

0 回答 0