我正在尝试编译,安装和运行我们将调用的包myPackage.它包含一个从库*.pyx中调用函数的文件.目前,当我运行导入包的脚本时,我获得以下错误消息:fftw_set_timelimit()fftwclientScript.py
Traceback (most recent call last):
File "clientScript.py", line 5, in <module>
import myPackage.myModule
ImportError: /usr/local/lib/python2.7/dist-packages/myPackage/myModule.so: undefined symbol: fftw_set_timelimit
Run Code Online (Sandbox Code Playgroud)
根据我的理解(我是python和cython的新手),我的包中尚未执行与C库的链接.的确,我的setup.py文件看起来像这样:
from setuptools import setup,find_packages
from Cython.Build import cythonize
import os
setup(
name = "myPackage",
version = "0.0.1",
url = "none",
author = "me",
author_email = "me@me.me",
packages=find_packages(),
ext_modules = cythonize("pyClo/pyClo.pyx"),
)
Run Code Online (Sandbox Code Playgroud)
如您所见,我的setup.py文件使用setuptools.我决定这样做,因为它是Python包装用户指南推荐的.但是,使用Cython文档中的说明distutils.链接库是通过调用来完成的distutils.Extension('file',['file.pyx'],libraries='fftw').如何使用相同的结果setuptools?
我正在将我的配置从setup.py移动到setup.cfg并且在设置entry_points参数时遇到问题,有人可以告诉我什么是正确的语法?目前我正在使用混合方法,但是,我想将entry_points移动到setup.cfg.
从
def setup_package():
setup(version=get_version(), entry_points={'console_scripts':['app=my_package.app.run:cli'],})
Run Code Online (Sandbox Code Playgroud)
至
[metadata]
name = my-package
description = my-package
license = unlicensed
long-description = README.md
platforms = any
classifiers =
Programming Language :: Python
[options]
zip_safe = False
packages = my_package, my_package.app
include_package_data = True
package_dir =
= .
tests_require = pytest; pytest-cov
[entry_points]
console_scripts =
my-package = my_package.app.run:cli
Run Code Online (Sandbox Code Playgroud)
谢谢
我想运行python setup.py install(安装脚本使用setuptools),我只想将.pyc文件包含在生成的egg或目录中.所有.py文件不得出现.我怎样才能做到这一点 ?
是否有可能强制virtualenv使用pypi提供的最新setuptools和pip?从本质上讲,我找了相反的的--never-download标志.
目前,当我创建一个新的virtualenv时,它使用与virtualenv捆绑在一起的本地(旧)版本.
$ v.mk testvenv
New python executable in testvenv/bin/python
Installing setuptools............done.
Installing pip...............done.
$ pip show setuptools
---
Name: setuptools
Version: 0.6c11
Location: /Users/cwilson/.virtualenvs/testvenv/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Requires:
$ pip search setuptools
[...]
setuptools - Easily download, build, install, upgrade, and
uninstall Python packages
INSTALLED: 0.6c11
LATEST: 0.7.2
[...]
Run Code Online (Sandbox Code Playgroud) 升级到OS X 10.9 Mavericks并安装了XCode,命令行工具,XQuartz等.现在尝试运行pip安装,但它说找不到分发:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.4.1
Run Code Online (Sandbox Code Playgroud)
所以我尝试用easy_install安装pip.事实证明,这也是愚蠢的:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2607, in <module>
parse_requirements(__requires__), Environment()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in …Run Code Online (Sandbox Code Playgroud) 我有以下项目结构我想打包:
??? doc
? ??? source
??? src
? ??? core
? ? ??? config
? ? ? ??? log.tmpl
? ? ??? job
? ??? scripts
? ??? test
??? tools
Run Code Online (Sandbox Code Playgroud)
我想包core下src,但排除test.这是我尝试失败的原因:
setup(name='core',
version=version,
package_dir = {'': 'src'}, # Our packages live under src but src is not a package itself
packages = find_packages("src", exclude=["test"]), # I also tried exclude=["src/test"]
install_requires=['xmltodict==0.9.0',
'pymongo==2.7.2',
'ftputil==3.1',
'psutil==2.1.1',
'suds==0.4',
],
include_package_data=True,
)
Run Code Online (Sandbox Code Playgroud)
我知道我可以排除test使用MANIFEST.in文件,但如果你能告诉我如何使用setup和,我会很高兴 …
我想知道是否和.deb包一样,在我的setup.py中可以配置我的包的依赖项,然后运行:
$ sudo python setup.py install
Run Code Online (Sandbox Code Playgroud)
它们是自动安装的.已经研究过互联网,但我发现只是让我困惑,像"需要","install_requires"和"requirements.txt"之类的东西
我正在尝试成为一名优秀的Pythonista,并按照我的计划对PEP 338进行部署.
我也在尝试python setuptools install使用setuptools entry_points{'console_scripts': ... }选项生成可执行脚本.
如何使用entry_points生成一个调用的二进制文件python -m mypackage(并传递*args,**kwargs)?
以下是我做过的一些尝试但没有成功:
setuptools(
...
Run Code Online (Sandbox Code Playgroud)
(1)
entry_points=
{'console_scripts': ['mypkg=mypkg.__main__'],},
Run Code Online (Sandbox Code Playgroud)
(2)
entry_points=
{'console_scripts': ['mypkg=mypkg.main'],},
Run Code Online (Sandbox Code Playgroud)
(3)
entry_points=
{'console_scripts': ['mypkg=python -m mypkg'],},
Run Code Online (Sandbox Code Playgroud)
我一直在使用的主要资源:
我研究了几个包含数据的 python 包。我通过 MANIFEST.in 文件添加它们,传递include_package_data=True给安装程序。例如:
# MANIFEST.in
graft mypackage/plugins
graft mypackage/data
Run Code Online (Sandbox Code Playgroud)
到目前为止,据我所知,这在没有任何警告的情况下有效。但是,在 setuptools 62.3.0 中,我收到以下消息:
SetuptoolsDeprecationWarning: Installing 'mypackage.plugins' as data is deprecated, please list it in `packages`.
07:53:53 !!
07:53:53
07:53:53
07:53:53 ############################
07:53:53 # Package would be ignored #
07:53:53 ############################
07:53:53 Python recognizes 'mypackage.plugins' as an importable package, however it is
07:53:53 included in the distribution as "data".
07:53:53 This behavior is likely to change in future versions of setuptools (and
07:53:53 therefore is considered deprecated). …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个 setup.py 文件,其中 find_packages() 递归地查找包。在这个例子中,foo, bar, 和baz都是我想要安装并在 python 路径上可用的模块。例如,我希望能够做到import foo, bar, baz. 该bar-pack和foo-pack只是常规的非蟒目录将包含各种支持文件/显示目录(如测试,自述等,具体到相应的模块)。
??? bar-pack
? ??? bar
? ??? __init__.py
??? baz
? ??? __init__.py
??? foo-pack
? ??? foo
? ??? __init__.py
??? setup.py
Run Code Online (Sandbox Code Playgroud)
然后说setup.py如下:
from setuptools import setup, find_packages
setup(
name="mypackage",
version="0.1",
packages=find_packages(),
)
Run Code Online (Sandbox Code Playgroud)
但是,当我运行python setup.py installor 时python setup.py sdist,只有baz目录被识别和打包。
我可以进一步简化它,并运行以下命令,但同样,只有baz被识别。
python -c "from setuptools import setup, find_packages; …Run Code Online (Sandbox Code Playgroud) python ×10
setuptools ×10
pip ×3
distutils ×2
setup.py ×2
cython ×1
deployment ×1
easy-install ×1
pep ×1
python-3.6 ×1
python-3.x ×1
virtualenv ×1