标签: distutils

如何安装python distutils

我刚刚在VPS服务器上运行了一些空间(在ubuntu 8.04上运行),我正在尝试在其上安装django.服务器安装了python 2.5,但我想它的非标准安装.当我为django运行安装脚本时,我得到了

amitoj@ninja:~/Django-1.2.1$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 1, in <module>
    from distutils.core import setup
ImportError: No module named distutils.core
Run Code Online (Sandbox Code Playgroud)

我很难过.互联网上的所有文章告诉我如何使用distutils安装模块.但是我如何获得distutils呢?有人能指出我为distutils存档吗?我查看了/usr/lib/local/python2.5,/usr/lib/python2.5等,并且正如预期的那样,没有找到distutils.

python distutils

67
推荐指数
7
解决办法
14万
查看次数

distutils:如何将用户定义的参数传递给setup.py?

请提示我如何将命令行和setup.cfg配置文件中的用户定义参数传递给distutils的setup.py脚本.我想编写一个setup.py脚本,它接受我的包特定参数.例如:

python setup.py install -foo myfoo
Run Code Online (Sandbox Code Playgroud)

谢谢你,
Mher

python distutils setup.py

63
推荐指数
8
解决办法
3万
查看次数

使用Pip安装Python包时如何使用MinGW的gcc编译器?

我配置了MinGW和distutils所以现在我可以使用这个命令编译扩展:

setup.py install
Run Code Online (Sandbox Code Playgroud)

将使用MinGW的gcc编译器并安装包.为此,我安装了MinGW并创建了distutils.cfg文件,其中包含以下内容:

[build]
compiler = mingw32
Run Code Online (Sandbox Code Playgroud)

这很酷,但现在我想使用所有的点数好处.有没有办法在pip中使用相同的MinGW的gcc编译器?这样当我运行时:

pip install <package name>
Run Code Online (Sandbox Code Playgroud)

如果需要,pip将使用MinGW的gcc编译器并编译C代码?

目前我收到此错误:Unable to find vcvarsall.bat.似乎pip并不知道我有gcc编译器.如何配置pip使用gcc编译器?

python windows distutils mingw pip

63
推荐指数
2
解决办法
7万
查看次数

如何在python中递归复制目录并覆盖所有?

我正在尝试将/home/myUser/dir1/其所有内容(及其内容等)复制到/home/myuser/dir2/python中.此外,我希望副本覆盖所有内容dir2/.

看起来distutils.dir_util.copy_tree可能是这个职位的合适的工具,但不能肯定是否有什么更容易/更明显,使用这样一个简单的任务.

如果它是正确的工具,我该如何使用它?根据文档,它需要8个参数.我必须通过所有8只src,dst并且update,如果是这样,怎么样(我全新到Python).

如果有更好的东西,有人可以给我一个例子并指出我正确的方向吗?提前致谢!

python distutils copy

62
推荐指数
4
解决办法
8万
查看次数

使用setup.py和软件包共享软件包版本的正确方法是什么?

使用distutils,setuptools等,包版本指定在setup.py:

# file: setup.py
...
setup(
name='foobar',
version='1.0.0',
# other attributes
)
Run Code Online (Sandbox Code Playgroud)

我希望能够从包中访问相同的版本号:

>>> import foobar
>>> foobar.__version__
'1.0.0'
Run Code Online (Sandbox Code Playgroud)

我可以添加__version__ = '1.0.0'到我的包的__init__.py,但我还想在我的包中包含其他导入以创建包的简化接口:

# file: __init__.py

from foobar import foo
from foobar.bar import Bar

__version__ = '1.0.0'
Run Code Online (Sandbox Code Playgroud)

# file: setup.py

from foobar import __version__
...
setup(
name='foobar',
version=__version__,
# other attributes
)
Run Code Online (Sandbox Code Playgroud)

但是,foobar如果导入其他尚未安装的软件包,这些额外的导入可能会导致安装失败.使用setup.py和软件包共享软件包版本的正确方法是什么?

python distutils setuptools

62
推荐指数
4
解决办法
1万
查看次数

pip忽略setup.py中的dependency_links

我在setup.py中有dependency_links:

...
dependency_links = ['http://github.com/robot-republic/python-s3/tarball/master.tar.gz#egg=python-s3'],
...
Run Code Online (Sandbox Code Playgroud)

但它不起作用.但是install_requires工作正常.也许有另一种方法来设置setup.py所需的git repo?

python distutils pip setuptools easy-install

61
推荐指数
5
解决办法
3万
查看次数

如何在没有setup.py的项目中运行tox?

我想用tox两个virtualenvs运行我的单元测试,因为我的应用程序必须支持2个不同的Python版本.

我的问题是tox需要a setup.py,但我没有,因为我的应用程序不是模块并且有自己的安装程序.现在我不想经历自动化安装过程的麻烦setup.py,我只想运行我的单元测试而不必写一个setup.py.

那可能吗?或者我怎么能写一个"空"的setup.py,什么都不做?你能指点我一些关于这个主题的distutils文档(文档解释了如何写一个有意义的setup.py,而不是空的)?

python unit-testing distutils tox

60
推荐指数
2
解决办法
9422
查看次数

使用cx_freeze时如何捆绑其他文件?

我在Windows系统上使用Python 2.6和cx_Freeze 4.1.2.我已经创建了setup.py来构建我的可执行文件,一切正常.

当cx_Freeze运行时,它会将所有内容移动到build目录中.我有一些其他文件,我想包含在我的build目录中.我怎样才能做到这一点?这是我的结构:

src\
    setup.py
    janitor.py
    README.txt
    CHNAGELOG.txt
    helpers\
        uncompress\
            unRAR.exe
            unzip.exe
Run Code Online (Sandbox Code Playgroud)

这是我的片段:

建立

( name='Janitor',
  version='1.0',
  description='Janitor',
  author='John Doe',
  author_email='john.doe@gmail.com',
  url='http://www.this-page-intentionally-left-blank.org/',
  data_files = 
      [ ('helpers\uncompress', ['helpers\uncompress\unzip.exe']),
        ('helpers\uncompress', ['helpers\uncompress\unRAR.exe']),
        ('', ['README.txt'])
      ],
  executables =
      [
      Executable\
          (
          'janitor.py', #initScript
          )
      ]
)
Run Code Online (Sandbox Code Playgroud)

我似乎无法让这个工作.我需要一个MANIFEST.in文件吗?

python distutils cx-freeze

54
推荐指数
2
解决办法
4万
查看次数

如何告诉distutils使用gcc?

我想用Cython包装一个包含C++和OpenMP代码的测试项目,并通过setup.py文件使用distutils构建它.我的文件内容如下所示:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext


modules = [Extension("Interface",
                     ["Interface.pyx", "Parallel.cpp"],
                     language = "c++",
                     extra_compile_args=["-fopenmp"],
                     extra_link_args=["-fopenmp"])]

for e in modules:
    e.cython_directives = {"embedsignature" : True}

setup(name="Interface",
     cmdclass={"build_ext": build_ext},
     ext_modules=modules)
Run Code Online (Sandbox Code Playgroud)

-fopenmp标志与gcc一起用于编译和链接OpenMP.但是,如果我只是调用

cls ~/workspace/CythonOpenMP/src $ python3 setup.py build
Run Code Online (Sandbox Code Playgroud)

这个标志无法识别,因为编译器是clang:

running build
running build_ext
skipping 'Interface.cpp' Cython extension (up-to-date)
building 'Interface' extension
cc -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c Interface.cpp -o build/temp.macosx-10.8-x86_64-3.3/Interface.o …
Run Code Online (Sandbox Code Playgroud)

python distutils compiler-errors cython

53
推荐指数
3
解决办法
4万
查看次数

为什么"python setup.py sdist"会在项目根目录中创建不需要的"PROJECT-egg.info"?

我跑的时候

  python setup.py sdist
Run Code Online (Sandbox Code Playgroud)

它在我的./dist目录中创建了一个sdist.这包括我的"dist"文件夹中的zip中的"PROJECT-egg.info"文件,我没有使用它,但它不会伤害我,所以我只是忽略它.

我的问题是,为什么它建立在我的项目根目录下的"PROJECT-egg.info"文件夹?我可以让它停止创建吗?如果没有,我可以在创建sdist后立即删除它吗?

我正在使用从setuptools导入的'setup'功能.WindowsXP,Python2.7,Setuptools 0.6c11,分发0.6.14.

我的设置配置如下:

{'author': 'Jonathan Hartley',
 'author_email': 'tartley@tartley.com',
 'classifiers': ['Development Status :: 1 - Planning',
                 'Intended Audience :: Developers',
                 'License :: OSI Approved :: BSD License',
                 'Operating System :: Microsoft :: Windows',
                 'Programming Language :: Python :: 2.7'],
 'console': [{'script': 'demo.py'}],
 'data_files': [('Microsoft.VC90.CRT',
                 ['..\\lib\\Microsoft.VC90.CRT\\Microsoft.VC90.CRT.manifest',
                  '..\\lib\\Microsoft.VC90.CRT\\msvcr90.dll'])],
 'description': 'Utilities for games and OpenGL graphics, built around Pyglet.\n',
 'keywords': '',
 'license': 'BSD',
 'long_description': "blah blah blah",
 'name': 'pygpen',
 'options': {'py2exe': {'ascii': True,
                        'bundle_files': 1,
                        'dist_dir': …
Run Code Online (Sandbox Code Playgroud)

python distutils setuptools distribute setup.py

47
推荐指数
4
解决办法
2万
查看次数