python setup.py develop not updating easy_install.pth - python

According to setuptools documentation, setup.py develop is supposed to create the egg-link file and update easy_install.pth when installing into site-packages folder. However, in my case it's only creating the egg-link file. How does setuptools decide if it needs to update easy_install.pth?
Some more info:
It works when I have setuptools 0.6c7 installed as a folder under site-packages. But when I use setuptools 0.6c9 installed as a zipped egg, it does not work.

Reinstall setuptools with the command easy_install --always-unzip --upgrade setuptools. If that fixes it then the zipping was the problem.

I'd try to debug it with pdb. The issue is most likely with the easy install's method check_site_dir, which seeks for easy-install.pth.

Related

Setuptools: Include subdirectories in package_data

I believe this question was asked before but I'm still a little stuck. I'm trying to install a Python package that has some data files with subdirectories. Here's my setup:
setup.py
src/
mypkg/
__init__.py
module.py
data/
tables.dat
spoons.dat
sub/
forks.dat
Following the docs I tried to add:
setup(...,
packages=['mypkg'],
package_dir={'mypkg': 'src/mypkg'},
package_data={'mypkg': ['data/*.dat', 'data/sub/*.dat']},
)
I install the module with python setup.py install (though eventually I'll use python setup.py sdist upload to upload the package to pypi so others can pip install the module.
After running the python setup.py install command, to find the module location, I then import mypkg and print(mypkg.__file__). In the package directory, however, I can see data but not data/sub. Does anyone know what I'm missing? Any help is greatly appreciated!
Ah, it turns out the above works fine!
To install the module to my site-packages/mypkg location, I just had to use: python setup.py sdist and then pip install dist/mypkg-0.0.1.tar.gz.
Then my data files were in site-packages/mypkg.
I had the same issue, in my case the problem was the package was installed and when executing
pip install .
in my local it didn't reinstall, so the packages weren't included.
Uninstall before install was the key for me

How to include Python-Xlib as a dependency in setup.py?

In my setup.py file, I can declare that PyUserInput is a requirement for my project (Python 3), but a prerequisite for PyUserInput on Linux is the Python module Xlib.
This is the relevant part of my setup.py file:
setup(...
install_requires=['requests', 'nose', 'PyUserInput'],
...
)
I tried putting Python-Xlib and Xlib into the install_requires argument, which didn't work since setuptools couldn't resolve those names automatically.
What do I need to do? I would prefer to be able to have the single command sudo python3 setup.py install handle installing all of the prerequisites for my package and not have to ask the user to manually install some prerequisites.
Using pip search xlib, I found that there was a package named python3-xlib. Adding python3-xlib as a requirement in setup.py was sufficient.

How do I include a tarball or svn dependency in setup.py?

I have a project that has python-xlib as a requirement. Unfortunately python-xlib is not on pypi, so in my requirements file I use:
svn+https://python-xlib.svn.sourceforge.net/svnroot/python-xlib/tags/xlib_0_15rc1/ as per this advice:
How do you install Python Xlib with pip?
This works fine with pip, but I want to package it with setup.py. Only actual eggs are allowed in install_requires, so this answer:
How can I make setuptools install a package that's not on PyPI?
suggests using dependency_links, which I did.
svn+https did not work in a dependency_link, so instead I link to the tarball referenced from this page: http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/tags/xlib_0_15rc1/
. This tarball gets downloaded the way I expect it to, but when it is time to install it, I get:
Searching for pyxlib
Best match: pyxlib [unknown version]
Downloading http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/tags/xlib_0_15rc1/?view=tar#egg=pyxlib
Processing xlib_0_15rc1
error: /tmp/easy_install-BDFVH3/xlib_0_15rc1/COPYING: Not a directory
I don't get it. Of course COPYING is not a directory. Why does setuptools (or is it distutils?) not run the setup.py that is in the python-xlib root? I suspect this must all be quite easy. How do I include python-xlib as a dependency for my egg?

How come I can't get the exactly result to *pip install* by manually *python setup.py install*?

I like to figure out the myth behind Python's namespace packages by setuptools, and here is what I did test.
Make a virtual environment by virtualenv.
Find a namespaced package on PyPI.
Install that package by pip install.
Check the installed file hierarchy.
The package I played with is zope.interface and it worked well with the following file hierarchy on my virtualenv:
~virenv/.../site-packages/zope.interface-3.8.0-py2.6-nspkg.pth
/zope.interface-3.8.0-py2.6.egg-info/
/zope/
/interface/
/...
Everything looked fine and I love the way zope.interface got installed as a real namespaced package (under folder zope).
Then, I did another test and that's the question I would like to ask for your help. I downloaded the tared zope.interface source file. I liked to play it manually again
Make a virtual environment by virtualenv.
Untar the zope.interface into somewhere.
Install the package by python setup.py install.
Go check what happened in site-packages.
The site-packages looks like this:
~virenv/../site-packages/zope.interface-...egg/
/zope/
/__init__.py
/interface/
/EGG-INFO/
Q. How come I can't get the exactly result to pip install by manually python setup.py install?
pip uses setup.py internally. It just passes additional option to it. To reproduce what pip is doing, execute
python setup.py install --single-version-externally-managed
You can also run pip -vv to see exactly which commands are run.
Q. How come I can't get the exactly result to pip install by manually
python setup.py install?
Because pip and setup.py are two different pieces of software.
pip is not advertised as providing identical behaviour to setup.py, nor vice versa.
If you want the behaviour of pip, use pip; if you want the behaviour of setup.py, use setup.py.

Why does my python egg not work? - No distributions at all found for

I have made a distribution of my python package with the following setup.py
#!/usr/bin/env python
from setuptools import setup
setup(name='mypackagename',
version='0.1',
description='Tool ....',
author='Peter Smit',
author_email='lala#lala.com',
packages=['mypackagename'],
package_dir={'': 'src'},
install_requires=['boto'],
entry_points = dict(console_scripts=[
'mypackagenamescript = mypackagename.launcher:run',
])
)
I created an egg of this with python setup.py bdist_egg.
Trying to install it now with pip gives the following error:
bin/pip install mypackagename-0.1-py2.6.egg
Downloading/unpacking mypackagename-0.1-py2.6.egg
Could not find any downloads that satisfy the requirement mypackagename-0.1- py2.6.egg
No distributions at all found for mypackagename-0.1-py2.6.egg
Storing complete log in /home/peter/.pip/pip.log
The mentioned log files showed that it tries to download the package from pypi, where it obviously does not exist.
What did I do wrong? How can I install this egg of mine plus it's dependencies?
why not using setuptools easy_install?
easy_install mypackagename-0.1-py2.6.egg
If you want to work with eggs that's the way.
pip cannot install from eggs.
If you want your package to be available on PyPI, you need to register and account there and upload it. You can then simply say pip install myproject. It will search PyPI, find it, download and install it.
If you have your setup.py ready and want to install your application locally, all you need to do is to say python setup.py install. You don't need to use pip or easy_install.
The hitchhikers guide to packaging contains details on all these things. It should make things clear.
Pip cannot install eggs. IMHO that is a serious lack. I would suggest you to try out Pyg. Just download the get-pyg.py script and execute it:
$ curl -O https://raw.github.com/rubik/pyg/master/get-pyg.py
$ python get-pyg.py
Retrieving archive from ... etc.
Note: As an alternative, you can install it via easy_install or pip.
Then you can use it:
$ pyg install mypackagename-0.1-py2.6.egg
Pyg supports virtualenv too.
rubik

Categories

Resources