This question already has answers here:
How can I make setuptools install a package that's not on PyPI?
(4 answers)
Closed 8 years ago.
I want to pull the live version of a package as a dependency of another package I install with pip.
Now, I have already found out how to install a live version of a package via pip; and that is not the question I am asking here.
I'd like to know whether I can pull in a live dependency version (e.g. from the PyPI index) - at present I was only able to set up tarballs via PyPI.
In your setup.py, do:
from setuptools import setup
setup(
...
install_requires=[
'a_required_pypi_package',
'another_package_in_pypi>=minimum_version'
]
...
)
and pip, setup.py install or setup.py develop will take care of it.
However the requirement will be considered satisfied, if any version of a_required_pypi_package is installed. This is especially true, if you use pip freeze to write a requirements.txt and use it to install packages.
Related
This question already has answers here:
How to install packages offline?
(12 answers)
Closed 5 months ago.
I am not able to use PIP on this device, so I need to install a module manually. The only problem is that I have to install like 30 dependencies of this module. I would have to download, unzip, include and install them all one by one.
Is there any faster way, like downloading a module with all its dependencies included?
If all requirements are pip packages, a quick solution might involve creating a lean python environment on another machine, installing the package using pip, and then copying over all of the resultant wheel files to the restricted machine either via SSH or another method.
This question already has answers here:
Is there a way to list pip dependencies/requirements?
(10 answers)
How to list dependencies for a python library without installing? [duplicate]
(3 answers)
List Python packages that will be installed from requirements.txt
(2 answers)
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Let's say I have a setup.cfg (or setup.py) file with all the packages listed.
Now, if I run pip install . it'll install all packages and it's dependencies listed in install_requires. Is there a way to only get the list of packages and dependencies without downloading or installing them, like in a requirements.txt format?
This command I'm looking for ideally would also work for pip install '.[tests]', which would list packages defined for tests under extras_require in setup.cfg.
What this question is NOT asking:
I'm not asking for pip freeze or pip list type of command which lists all the packages installed in an environment. Rather I want the same type of list, just not of the packages already installed but of the packages that will be installed by the defined configuration in setup.cfg.
I'm not asking about how to generate this list by downloading these packages either, but only to collect them. I don't see why pip would need to download these packages when what I need is only the list of the packages and dependencies with their versions.
SOLUTION
stackoverflow marked this question as a duplicate which it is NOT. I have found a solution however because this question is closed I won't be able to submit it as an answer, but will post it here in the question instead.
To generate requirements.txt for packages listed in install_requires in your setup.cfg or setup.py, you would need to install pip-tools.
pip install pip-tools
pip-compile
To generate a requirements.txt file that includes packages specified under extras_requires for tests and dev:
pip-compile --extra tests --extra devrequirements.txt file with packages listed under
PEP508 allows specifying a URL for a dependency, in particular a VCS. This is most useful for private packages that are not on pypi. If I have a package whose setup.py looks like:
from setuptools import setup
setup(name='foo',
install_requires=['bar # git+ssh://git#github.com/me/bar#1.2.3']
)
Then when I say pip install foo, it will download and install bar from the github repo. But if I later want to install a new version of foo, (pip install --upgrade foo), which has an updated bar dependency (e.g. tag 2.3.4), pip says that the dependency is already satisfied.
Is there a way to encode version information or something that will force pip to recognize that the dependency is NOT being met? I know I can give pip the --upgrade-strategy eager option, but that would affect ALL dependencies recursively and is too heavy-handed.
This related question PEP508: why either version requirement or URL but not both? asks about not being able to specify a version, but doesn't answer why pip doesn't get the URL when asked to upgrade.
This question already has answers here:
Pip install from pypi works, but from testpypi fails (cannot find requirements)
(2 answers)
Closed 2 years ago.
TL;DR Even though I've specified dependencies with install_requires in setup.py, the install through pip fails because some dependencies can't be found.
I've developed a package which I intend to distribute via PyPi. I've created a built distribution wheel and uploaded it to testPyPI to see if everything is working with the upload and if the package can be installed from a user perspective.
However, when I try to pip install the package inside a vanilla python 2.7 environment, the installation process fails while installing the dependencies.
My package depends on these packages (which I added to the setup.py file accordingly):
...
install_requires=['numpy','gdal','h5py','beautifulsoup4','requests','tables','progress'],
...
So when I run pip install, everything looks normal for a moment, until I receive this error:
Could not find a version that satisfies the requirement progress (from #NAME#) (from versions: )
No matching distribution found for progress (from #NAME#)
When I remove the progress dependency (I could live without it), same thing happens for pytables:
Could not find a version that satisfies the requirement tables (from #NAME#) (from versions: )
No matching distribution found for tables (from #NAME#)
If I run pip install tables and pip install progress manually beforehand, everything works as expected.
So how can I assure that if someone downloads my package, all missing dependencies are installed with it?
Related bonus question:
Can I include a wheel file in my package (maybe through MANIFEST.in) and install it as dependency if the module is not available? If so, how?
And I think I've found the answer to my question myself.
When installing a package from testPyPI, the dependencies are also installed from there. And it seems, that while there are many packages available, pytables and progress are apparently missing. This caused the installation to fail.
Naturally, manually installing with pip install gets the package from the "normal" PyPi, which of course works. This obviously added to my confusion.
Here's a look at the output from pip install when installing the package from the testPyPi:
Downloading https://test-files.pythonhosted.org/packages/4f/96/b3329750a04fcfc316f15f658daf6d81acc3ac61e3db390abe8954574c18/nump
y-1.9.3.tar.gz (4.0MB)
while installing the wheel directly, it looks slightly different:
Downloading https://files.pythonhosted.org/packages/2e/91/504e434d3b95d943caab926f33dee5691768fbb622bc290a0fa6df77e1d8/numpy-1.1
4.2-cp27-none-win32.whl (9.8MB)
Additionally, running
pip install --index-url https://test.pypi.org/simple/ tables
produces the same error as described in my question.
This question already has answers here:
How to easily distribute Python software that has Python module dependencies? Frustrations in Python package installation on Unix
(2 answers)
Closed 5 months ago.
I wish to package a utility that I have created that depends on Pillow, a port of the Python Imaging Library. Is there a way to include Pillow in my own package or to automatically install Pillow upon running the setup script?
Python 3 mainly uses pip for installing packages. This is based off of setuptools and distribute. You would create the setup.py script with the requirement specified. The easiest way is to create a requirements file using pip. http://codeinthehole.com/writing/using-pip-and-requirementstxt-to-install-from-the-head-of-a-github-branch/
Command Line:
pip freeze > requirements.txt
setup.py
import setuptools
from pip.req import parse_requirements
requirements = [str(ir.req)
for ir in parse_requirements("requirements.txt", session=uuid.uuid1())
if ir.req is not None]
setuptools.setup(..., install_requires=requirements)
If you want to build an executable then the process if fairly similar to the standard setup.py file approach only you use cx_freeze.