Simple Question ;)
Is there a way to simply install the package using pip once you build it. Using easy_install I would simply build my package it (python setup.py build), then if I was happy do a easy_install . and this would dump the resulting egg into the right place. How do I do this using pip?
pip install -e . will install from a local source like easy_install . would.
Most of pip's commands and functionality are designed around installing from source repositories or PyPI package listings, or maintaining consistently versioned dependencies though.
If you are going through the steps of building the package yourself, are you sure you don't want to python setup.py install manually after you are satisfied with the build?
Related
Is there a way, using setup.py, to install a python package as a wheel/pip-style package (i.e. dist-info) instead of the egg installation that setup.py does by default (i.e. egg-info)?
For example, if I have a python package with a setup.py script and I run the following command, it will install the package as an egg.
> python setup.py install
However, I can build a wheel first, and then use pip to install that wheel as a wheel/dist-info type installation
> python setup.py bdist_wheel
> pip install ./dist/package-0.1-py2-none-any.whl
Is there a way to install the package as a wheel/dist-info installation directly from setup.py? Or is the two-step process using both setuptools and pip necessary?
Update: Confirmed, this has landed in pip now. If you are still seeing .egg-info installs when pip installing from a directory, then just upgrade your pip installation. Note that --editable installs will still use egg-info.
Original answer below:
This feature is coming soon. This was issue #4611. Follow the trail and you will find PR 4764 to pip, merged into master approx a week ago. In the meantime, you can
pip wheel .
pip install ./mypackage.whl
For me the proposed solution still didn't work (even with pip 21.0.1), and due to versioning (package-name-XX.YY), I also didn't know the name of the .whl file. You can tell pip to look in the directory and take the .whl from there:
python setup.py bdist_wheel
pip install package-name --find-links dist/
I am packaging my own Python package. I use setuptools and wheel for bundling it and pip for installing (both in develop mode and from test PyPI repository).
Every pip command for installing packages is used with --process-dependency-links here. I will let down this option for simplifying and this option will be implicit here.
One of the dependencies is broken in PyPI but in development repository issue has been fixed. I know which commit fixes this issue, I know its SHA-1 sum, so I know which tarball to download. So I did this in my setup.py file:
...
install_requires=[
'hbmqtt>0.9.0'
],
dependency_links=[
'https://github.com/beerfactory/hbmqtt/archive/f4330985115e3ffb3ccbb102230dfd15bb822a72.zip#egg=hbmqtt-0.9.1'
],
...
While I install package in development mode (both via setuptools and pip), package is downloaded from git repo. Then I can distribute source code of my package.
python setup.py sdist
twine upload -s --sign-with gpg2 -r testpypi dist/<pkg-name>-<version>.tar.gz
Then I can install it from PyPI. If I don't set --no-cache-dir and --no-binary :all: options simultaneously (--no-cache-dir is needed only to make sure that the package is not installed from the cache), first installation looks OK. Pip downloads sources and then make wheel. Resolving dependencies goes well, everything looks OK. Pip downloads appropriate version of (in my example) HBMQTT package and installs it. At the same time pip makes wheel and then caches it. So second installation (without --no-binary option for obvious reason and with --upgrade and -I options) fails due to unsatisfied requirement: pip cannot find HBMQTT package with version 0.9.1. Latest version of HBMQTT in PyPI is 0.9.0. So pip doesn't process dependency links when trying to install from wheel package.
Same thing happens when I'm trying to make wheel (python setup.py bdist_wheel) and upload it on test PyPI. Installation from PyPI fails as well as from downloaded (or made by me) wheel file.
I suppose that trouble is located in pip or wheel. I don't know which one is responsible for installing from wheel.
And so my question is what I should do now? Which workarounds do exist for this case? I think only about forking HBMQTT repo and making my own package until PyPI has broken package.
did you try the --process-dependency-link flag?
https://github.com/pypa/pip/issues/4295
edit: sorry, i see now that you tried that. For me this solved the problem, but that is not very useful for you.
I have a packages file (dependencies.conf) for pip including a bunch of packages that my app needs:
argparse==1.2.1
Cython==0.20.2
...
In my build process, I download all packages using:
pip install --download=build/modules -r conf/dependencies.conf
Then in the deployment process, I want to install these files only if the installed version is different than what I need and in the correct order (dependencies)
I'm currently using the following:
for f in modules/*; do pip install -I $f; done
But this is wrong since it doesn't validate the version (-I is there in order to downgrade packages if needed) and it doesn't handle the right order of dependencies.
Is there a simple method to do that? (I'm basically trying to update the packages in machines that don't have internet connection)
Get the version using PIP, using the following command
eg. pip freeze | grep Jinja2
Jinja2==2.6
as explained in the following link Find which version of package is installed with pip
then compare this with the version, and run pip install with the appropriate version if necessary
I'm new to python. Are there alternatives to downloading a tarball for a python module & installing it via python setup install ? Anything like rubygems?
UPDATE I'm surprised that there are so many solutions for this one problem.
setuptools is one option. Install that and then you can install many Python modules using the easy_install command-line tool.
There are many options - you can stick with your system's default packaging system (if it has one) or you can pick one (or more) of existing Python tools like easy_install, zc.buildout or pip. I would recommend you to use Distribute together with pip.
easy_install or pip. I also recommend checking out virtualenv to isolate environments for test running packages. The Python Package Index(pypi, also called Cheeseshop) is the official third-party software repository for Python.
Pip is great:
$ pip install some_python_module
$ pip freeze > requirements.txt
$ cat requirements.txt
Output from freeze:
Creoleparser==0.7.3
Django==1.3
Genshi==0.6
PIL==1.1.7
South==0.7.3
django-debug-toolbar==0.8.5
....
After this in any other place:
$ pip install < requirements.txt
Checkout pip
This Python package install using pip or easy_install from repos points out a very interesting features of pip.
However, sometimes you just want it to install the source distribution; this is particularly true when
you are running in a virtualenv (so you don't care about messing up the python path, since you are deliberating doing it in an env),
when you are not the developer of that particular package, and you don't want to have it "editable",
when you cannot pip install package-name because the package is not in any index,
when there is no tar.gz available.
Thanks for your answers!
Have you tried just omitting the --editable? If I run
pip install hg+http://bitbucket.org/carljm/django-markitup/
it clones the repo to a temporary build directory and installs normally (via setup.py install rather than setup.py develop).
Of course, if you then freeze this environment, the generated requirement will not be fulfillable. If you need this, then just use --editable (there's really not much difference, works fine even if you don't actually need to edit the package) or just run your own instance of something like chishop and upload the sdists you need to it, then use the -i or --extra-index-url option.