Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace packages and pip install -e

I have a ns.pkg2 package that depends on ns.pkg1 package. I make a fork of it, publish it to git and want to install my version into my virtualenv. I use pip install -e mygit and end up with ns.pkg in <env>/local/lib/python2.7/site-packages/ns/pkg1 and ns.pkg2 in <env>/src/ns.pkg2 with an <env>/lib/python2.7/site-packages/ns.pkg2.egg-link. Now I can import ns and ns.pkg1 but not ns.pkg2. I couldn't find a way to install a package from git without pip install -e that calls setup.py develop. Also, I'm not sure it's not a problem with module code.

So, is it possible to co-install two modules from the same namespace from a tarball and directly from git?

like image 251
wRAR Avatar asked Nov 15 '12 15:11

wRAR


People also ask

What are namespace packages in Python?

In Python, a namespace package allows you to spread Python code among several projects. This is useful when you want to release related libraries as separate downloads.

What is package namespace?

Namespace packages allow you to split the sub-packages and modules within a single package across multiple, separate distribution packages (referred to as distributions in this document to avoid ambiguity).

How do you create a namespace in Python?

Every package, module, class, function and method occupies a Python namespace in which variable names are set. A namespace gets created automatically when a module or package starts execution. Hence, create namespace in python, all you have to do is call a function/ object or import a module/package.

How do you import a namespace in Python?

Importing is a way of pulling a name from somewhere else into the desired namespace. To refer to a variable, function, or class in Python one of the following must be true: The name is in the Python built-in namespace. The name is the current module's global namespace.


1 Answers

There is an open issue in pip related to --editable and namespace installations: https://github.com/pypa/pip/issues/3

A workaround was merged, and maybe you can solve your problem by doing:

$ pip install -e mygit --egg
like image 150
Hugo Tavares Avatar answered Sep 20 '22 04:09

Hugo Tavares