setuptools searching for false dependency - python

I am running into a bizarre problem where I try to install my python package (using setuptools) on a Linux system and it tries to install pywin32 as a dependency. This only happens if I run it from a specific directory. If I move the whole tree to a different directory, it installs fine.
My setup.py does reference pywin32 for win32 platforms, but even when I remove this it makes no difference. I've also removed all the other requirements without any change in behavior. My setup.py has nothing in it other than setuptools initialization and a call to setup().
I have a virtualenv active and have tried switching to a new clean virtualenv without a change in behavior. I see the following when I run setup.py develop:
python setup.py develop
running develop
running egg_info
deleting foo.egg-info/requires.txt
writing foo.egg-info/PKG-INFO
writing top-level names to foo.egg-info/top_level.txt
writing dependency_links to foo.egg-info/dependency_links.txt
reading manifest file 'foo.egg-info/SOURCES.txt'
writing manifest file 'foo.egg-info/SOURCES.txt'
running build_ext
Creating /home/user/foo-env2/lib/python2.7/site-packages/foo.egg-link (link to .)
foo 1.0 is already the active version in easy-install.pth
Installed /home/user/magicdirectory/magic
Processing dependencies for foo==1.0
Searching for pywin32
Reading http://pypi.python.org/simple/pywin32/
Reading http://sf.net/projects/pywin32
Now, I may have accidentally tried to install a win32 egg of this package at some point, but that was in the original virtual environment and I can't figure out what it could have done to cause this.
How do I debug this? Where else could setuptools be searching for dependencies from?
UPDATE: It appears that it's not the name of the directory that matters, but where it is. If I move the package directory up one level, it will install fine. The directory in question here has been deleted and recreated multiple times so it doesn't appear to be related to anything inside the directory.

Try removing the *.egg-info in the dist develop directory. If that doesn't work, try starting with a fresh, untouched checkout of your code without any of the other setuptools/dist artifacts and see if that reproduces the problem. If it doesn't then you know it's one of the setuptools/dist artifacts that just needs to be cleaned up.

Related

Pip skips a file from installation

I'm trying to deploy a new version of a project I've been working on. I zip the package into a .tar.gz file using the standard python setup.py sdist command, and then install the package using python -m pip install x.tar.gz.
All the files which are required are present in the archive itself (the .tar.gz file) but for some reason pip skips installing one of these, a binary file containing some lookup tables. Moreover, I think this happens only on linux (I make the package itself using Windows, and here everything works fine). I would think that this might have something to do with using sdist instead of bdist, but with previous versions I've had no issues of this kind, despite using the same method. I'm not sure if there is any architecture dependency at play here. Are all binary files architecture dependent?
Any ideas regarding what might be the cause of this?

Does pip install work with single module projects?

I just refactored my Python project to be a single top-level module rather than a package.
However, pip install does not work anymore: I get an error which says:
(forcelib_test) C:\code>pip install git+https://github.com/blokeley/forcelib
Collecting git+https://github.com/blokeley/forcelib
Cloning https://github.com/blokeley/forcelib to c:\users\tomoak~1\appdata\local\temp\pip-t10zegic-build
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\forcelib.egg-info
writing pip-egg-info\forcelib.egg-info\PKG-INFO
writing dependency_links to pip-egg-info\forcelib.egg-info\dependency_links.txt
writing requirements to pip-egg-info\forcelib.egg-info\requires.txt
writing top-level names to pip-egg-info\forcelib.egg-info\top_level.txt
writing manifest file 'pip-egg-info\forcelib.egg-info\SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
error: package directory 'forcelib' does not exist
I'm not trying to install a package called forcelib, only a module. The setup.py script correctly uses the py_modules argument rather than packages.
Is it possible to install a single module or do I have to revert to using a package?
Note: this question is about a different problem. They want to install an additional text file. I just want to install the single Python module. In fact, that question implies that what I'm trying to do should work without the error I got
I needed to use
py_modules=['forcelib']
Rather than what I had which was
py_modules=['forcelib.py']

Difference between setup.py install and setup.py develop

I am trying to improve my workflow when developing python modules and have a rather basic question.
What exactly happens when choosing either option. To my knowledge develop leaves the files in place so I can modify them and play around with the package whereas install copies them in the site-packages folder of my python installation. How is the package linked to my python installation when using the develop option.
develop creates an .egg-link file in the site-packages directory, which points back to the location of the project files. The same path is also added to the easy-install.pth file in the same location. Uninstalling with setup.py develop -u removes that link file again.
Do note that any install_requires dependencies not yet present are also installed, as regular eggs (they are easy_install-ed). Those dependencies are not uninstalled when uninstalling the development egg.

Python Install of Dropbox SDK Fails

I have the same problem as here.
Dropbox Python SDK installation error on Windows 7 (could not create 'build')
The user didn't say how they fixed the issue (I have tried starting again, and reinstalling Python). I asked the user to elaborate and my post was deleted because I wasn't answering the question. Sorry, I'm new here. But re-posting seems counter intuitive to me.
Here goes...
I installed Python 2.7, then downloaded and tried to run setup.py of the Dropbox Python SDK.
It asked me to add the setuptools, so I did, and then tried to install the Dropbox setup.py from a CMD. After which I got the below...
C:\Python27\dropbox-python-sdk-1.5.1>setup.py install
running install
running bdist_egg
running egg_info
writing dropbox_python_sdk.egg-info\PKG-INFO
writing top-level names to dropbox_python_sdk.egg-info\top_level.txt
writing dependency_links to dropbox_python_sdk.egg-info\dependency_links.txt
reading manifest file 'dropbox_python_sdk.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'dropbox_python_sdk.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
error: could not create 'build': Cannot create a file when that file already exists
C:\Python27\dropbox-python-sdk-1.5.1>
What have I done wrong? I know it hasn't installed because the Dropbox module isn't there.
I'm using Windows Server 2008 64bit if that helps.
Answer as per piokuc's comment. He/She did not mark an answer (for quite some time) so I am leaving it here for others to find.
"Remove the build directory you see complaints about. – piokuc"
I found that trying to install the Dropbox python module without 'Easy Install' if fails, leaving the Dropbox module install half finished. Simply delete the file in question and start again.

using setuptools with post-install and python dependencies

This is somewhat related to this question. Let's say I have a package that I want to deploy via rpm because I need to do some file copying on post-install and I have some non-python dependencies I want to declare. But let's also say I have some python dependencies that are easily available in PyPI. It seems like if I just package as an egg, an unzip followed by python setup.py install will automatically take care of my python dependencies, at the expense of losing any post-install functionality and non-python dependencies.
Is there any recommended way of doing this? I suppose I could specify this in a pre-install script, but then I'm getting into information duplication and not really using setuptools for much of anything.
(My current setup involves passing install_requires = ['dependency_name'] to setup, which works for python setup.py bdist_egg and unzip my_package.egg; python my_package/setup.py install, but not for python setup.py bdist_rpm --post-install post-install.sh and rpm --install my_package.rpm.)
I think it would be best if your python dependencies were available as RPMs also, and declared as dependencies in the RPM. If they aren't available elsewhere, create them yourself, and put them in your yum repository.
Running PyPI installations as a side effect of RPM installation is evil, as it won't support proper uninstallation (i.e. uninstalling your RPM will remove your package, but leave the dependencies behind, with no proper removal procedure).

Categories

Resources