Mam repozytorium git z wieloma folderami, jednym z nich jest moduł Pythona, który można zainstalować za pomocą pip, na przykład:
repo.git/
repo.git/folder1/
repo.git/folder2/
repo.git/mymodule/
repo.git/mymodule/__init__.py
repo.git/mymodule/setup.py
repo.git/mymodule/...
Right now I have to do the following to install:
git clone http://server/repo.git
cd repo
pip install mymodule
cd ..
rm -rf repo
Is it possible to install the module directly with pip without explicitly cloning ?
I tried:
pip install git+https://server/repo.git/mymodule/
pip install git+https://server/repo.git:mymodule/
But I get:
IOError: [Errno 2] No such file or directory: '/tmp/pip-88tlLm-build/setup.py'
Odpowiedzi:
There is a pull request regarding this feature, and it seems to have been merged to develop branch a month ago. The syntax is the following:
pip install -e git+https://git.repo/some_repo.git#egg=version_subpkg&subdirectory=repo # install a python package from a repo subdirectory
We probably have to wait for a while until it gets merged to master and is distributed.
UPDATE: This is now available and documented at https://pip.readthedocs.io/en/stable/reference/pip_install/#vcs-support as follows:
Note: On Windows, you must place the URL in double quotes, or you'll get an error "'subdirectory' is not recognized as an internal or external command". E.g., use:
źródło
pip install -e 'git+https://…/repo.git@branch#egg=package&subdirectory=package'
results in the package appearing to install, and apackage.egg-link
file getting put in site-packages — but it points to the root directory ofsrc/repo
, not tosrc/repo/package
, as I would expect. This means thatpy_modules
can’t be imported, andentry_points
don’t actually work: they both raise anImportError: No module named package
.-e
seems necessary, otherwisepip freeze
doesn't show the whole path, only the egg. This happened onpip-1.5.4
It's been already stated in one of the comments under the correct answer, but just to highlight this issue: when executing this from Linux command line, you must escape the
&
-character since ampersand is telling the command line to run a command in background:Notice the backslash before the ampersand. The escaping behaviour might depend on the Linux distro; I'm not an expert.
If you ignore this, you might run into a cryptic error like the following:
źródło
pip install git+ssh://[email protected]/org_or_username/repo.git@branch#subdirectory=path/to/dubdir