Python 如何使setup.py与';它既是一个库又是一个应用程序

Python 如何使setup.py与';它既是一个库又是一个应用程序,python,pip,setup.py,requirements.txt,Python,Pip,Setup.py,Requirements.txt,我正在创建一个库,但库也是一个应用程序。因此,我正试图使代码尽可能地无痛于那些没有真正编程背景的人。我决定同意你的建议。然而,我遇到了各种各样的问题。我想让用户这样做 $ make config $ make install 我需要这样做,因为它实际上是一个C++/Python代码,所以我将它们与Swig和Cmake混合在一起。然后,我的目标是使那些config和install成为目标,这样安装就轻而易举了。我的第一个问题是:如果我的setup.py文件的内容 from setuptools

我正在创建一个库,但库也是一个应用程序。因此,我正试图使代码尽可能地无痛于那些没有真正编程背景的人。我决定同意你的建议。然而,我遇到了各种各样的问题。我想让用户这样做

$ make config
$ make install
我需要这样做,因为它实际上是一个C++/Python代码,所以我将它们与Swig和Cmake混合在一起。然后,我的目标是使那些
config
install
成为目标,这样安装就轻而易举了。我的第一个问题是:如果我的
setup.py
文件的内容

from setuptools import setup, find_packages

def read(*names, **kwargs):
    return io.open(
        join(dirname(__file__), *names),
        encoding=kwargs.get("encoding", "utf8")
    ).read()

setup(
    name="myproject",
    version="0.1.0",
)
我打字 $python setup.py build

代码实际安装在
pip
中的可能性如何

$ pip freeze
-e git+https://svn.3me.tudelft.nl/git/myproject.git@92f08bfcbaf1f78a6acdf5f03b5c7a36e87800eb#egg=myproject
我改进了
setup.py
,使其也具有依赖性:

setup(
    name="myproject",
    version="0.1.0",
    install_requires=[
        # eg: "aspectlib==1.1.1", "six>=1.7",
        "numpy", "scipy", "Sphinx", "pytest", "matplotlib", "dill"
    ],
)
我在上面的链接中讨论了一个
requirements.txt

--index-url https://pypi.python.org/simple/

-e . 
我运行了
pip install-r requirements.txt
它实际上安装了所有需要的依赖项,但是如果我重新运行它,它就会失败

Exception:
Traceback (most recent call last):
  File "/Users/aaragon/.virtualenvs/test7/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Users/aaragon/.virtualenvs/test7/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Users/aaragon/.virtualenvs/test7/lib/python3.5/site-packages/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Users/aaragon/.virtualenvs/test7/lib/python3.5/site-packages/pip/req/req_install.py", line 703, in uninstall
    '(at %s)' % (link_pointer, self.name, dist.location)
AssertionError: Egg-link /Users/aaragon/Local/myproject does not match installed location of myproject (at /Users/aaragon/Local/myproject/src)
为什么我会犯这个错误