这个`setup.py`有什么问题? [英] What's wrong with this `setup.py`?

查看:108
本文介绍了这个`setup.py`有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在获取 setup.py 正确执行 sdist 时遇到了问题。我把它归结为这一点。我具有以下目录结构:

I've been having problems withe getting setup.py to do the sdist thing correctly. I boiled it down to this. I have the following directory structure:

my_package\
    my_subpackage\
        __init__.py
        deep_module.py
    __init__.py
    module.py
    setup.py

这就是我在 setup.py 中所拥有的:

And here's what I have in setup.py:

#!/usr/bin/env python

from distutils.core import setup
import distutils

setup(
    name='a',
    version='0.1',
    description='a',
    author='a',
    author_email='a@a.com',
    url='http://a.org',
    packages=['my_package','my_package.my_subpackage'],
    package_dir={'': '..'},
    license= "a",
    long_description = 'aaa',

)

'aaa'只是占位符。)

无论如何,当我这样做时,它可以正常工作 setup.py install ,但是当我尝试执行 setup.py sdist 时,发生了一些奇怪的事情:

Anyway, it works okay when I do setup.py install, but when I try to do setup.py sdist, a few curious things happen:


  1. 已创建 MANIFEST 文件。

在现有 my_package 内部中创建 my_package 文件夹的副本$ c>文件夹(尽管它丢失了一些我认为与设置有关的文件。)

A copy of the my_package folder is created inside the existing my_package folder (though it misses a few of the setup-related files I think.)

A dist 文件夹已创建,其中有一个zipfile,在其中有包名称的文件夹中,但是在该文件夹中没有我希望的整个包,而是只有两个文件 setup.py PKG-INFO

A dist folder is created, inside it a zipfile, inside that a folder with the package name, but inside that folder there isn't the whole package like I hoped but only two files, setup.py and PKG-INFO.

我在做什么错?如何使 sdist 工作?

What am I doing wrong? How do I make sdist work?

推荐答案

代替此:

my_package\
    my_subpackage\
        __init__.py
        deep_module.py
    __init__.py
    module.py
    setup.py

尝试一下:

my_package_source\
    setup.py
    README.txt
    my_package\
        my_subpackage\
            __init__.py
            deep_module.py
        __init__.py
        module.py

您实际上并不需要自述文件,它只是出于说明目的,将项目文件夹的根目录中的内容放入目录。

You don't actually need a README, it's just for illustrative purpose for what kind of things sit in the root directory of your project's folder.

===编辑=====================================

=== EDIT ======================================

我应该详细说明。运行它后,目录应如下所示:

I should elaborate. After you run it your directory should then look something like this:

my_package_source\
    setup.py
    README.txt
    MANIFEST
    PKG-INFO
    dist\
        my_package_0.X.tar.gz (or .zip on windows I believe)
    my_package\
        my_subpackage\
            __init__.py
            deep_module.py
        __init__.py
        module.py

使用dist目录下的软件包进行分发。

Use the package under the dist directory to distribute.

这篇关于这个`setup.py`有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆