问题
I'm creating a library, but the library is also an application. Therefore, I'm trying to make the code as painless as possible for people with no real background in programming. I decided to go along with suggestions in this post. However, I'm running into all sorts of issues. I want users to do
$ make config
$ make install
I need to do this because it's actually a C++/Python code, so I'm mixing them with Swig and Cmake. My objective is then to make those config
and install
targets so installing is a breeze. The first question I have is the following: If the contents of my setup.py
file is as simple as
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",
)
and I type $ python setup.py build
How is it possible that the code is actually installed within pip
?
$ pip freeze
-e git+https://svn.3me.tudelft.nl/git/myproject.git@92f08bfcbaf1f78a6acdf5f03b5c7a36e87800eb#egg=myproject
I improved the setup.py
so that it also has dependencies:
setup(
name="myproject",
version="0.1.0",
install_requires=[
# eg: "aspectlib==1.1.1", "six>=1.7",
"numpy", "scipy", "Sphinx", "pytest", "matplotlib", "dill"
],
)
and I put a requirements.txt
as discussed in the link above:
--index-url https://pypi.python.org/simple/
-e .
and I run pip install -r requirements.txt
it actually installs all dependencies needed, but if I rerun it, it fails with
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)
why am I getting this error?
来源:https://stackoverflow.com/questions/46697117/how-do-i-make-setup-py-play-nice-with-code-thats-both-a-library-and-an-applicat