【发布时间】:2014-09-16 07:04:53
【问题描述】:
我有一个带有安装脚本的软件包,在 2.7 下可以正常安装,但是在 3.4 下运行时安装脚本(使用 setuptools)失败:
± python setup.py develop
running develop
Traceback (most recent call last):
File "setup.py", line 45, in <module>
url = "http:www.planetfour.org",
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/distutils/dist.py", line 973, in run_command
cmd_obj.ensure_finalized()
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/site-packages/setuptools-5.7-py3.4.egg/setuptools/command/develop.py", line 50, in finalize_options
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/site-packages/setuptools-5.7-py3.4.egg/setuptools/command/easy_install.py", line 313, in finalize_options
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/site-packages/setuptools-5.7-py3.4.egg/setuptools/package_index.py", line 269, in __init__
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/site-packages/setuptools-5.7-py3.4.egg/pkg_resources.py", line 802, in __init__
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/site-packages/setuptools-5.7-py3.4.egg/pkg_resources.py", line 832, in scan
File "/Users/maye/miniconda3/envs/py34/lib/python3.4/site-packages/setuptools-5.7-py3.4.egg/pkg_resources.py", line 852, in add
TypeError: unorderable types: str() < NoneType()
(py34)-> [1]
我尝试了什么:
- 我在安装 2.7 版本的同一源文件夹中执行此操作,这是否有害/危险?我删除了所有 *.pyc FWIW?
- 我尝试了 2to3,如果它会在我的 setup.py 脚本中显示任何必需的更改,但它说不需要:
± 2to3 setup.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: No changes to setup.py RefactoringTool: Files that need to be modified: RefactoringTool: setup.py (py34)maye@lunatic|~/Dropbox/src/P4_sandbox on master
根据评论进行编辑:
我能找到的唯一命令是install_requires 行:
install_requires = ['pandas>='+pandas_version]
和
pandas_version = '0.13.1'
如果这是罪魁祸首,如何在 Python 3.4 中正确地做到这一点?
这是整个 setup.py:
import ez_setup
ez_setup.use_setuptools()
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
pandas_version = '0.13.1'
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = ['-v']
self.test_suite = True
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
setup(
name = "Planet4",
version = "0.1beta2",
packages = find_packages(),
install_requires = ['pandas>='+pandas_version],
tests_require = ['pytest'],
cmdclass = {'test': PyTest},
entry_points={
"console_scripts": [
'p4reduction = planet4.reduction:main',
'plot_p4_imageid = planet4.markings:main',
]
},
#metadata
author = "K.-Michael Aye",
author_email = "kmichael.aye@gmail.com",
description = "Software for the reduction and analysis of Planet4 data.",
license = "BSD 2-clause",
keywords = "Mars Planet4 Zooniverse",
url = "http:www.planetfour.org",
)
【问题讨论】:
-
2to3 并不完美;排序的语法仍然相同,但行为发生了变化。见docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
-
啊,那么一定是这一行:
install_requires = ['pandas>='+pandas_version]with pandas_version = '0.13.1' ?那么如何在 3.4 中正确执行此操作?我在 setuptools 文档中看不到 3.4 的任何特殊说明? -
不,这不是排序,只是字符串连接。这是一个干净的虚拟环境吗?
-
清洁是如何定义的?它是用 conda for python 3.4 设置的,一些包是通过 pip 进来的,它是通过“source activate
”系统激活的。我还能说什么? -
但是当确定可用的 pandas 版本是否 >= 所需的版本时,难道没有某处发生排序吗?
标签: python-3.x setuptools setup.py