Is there a way to preserve the order in which packages are installed?
See original GitHub issueI’m trying to create a reproducible install of my window manager using pipenv and I bump into this:
Better explanation now:
- cairocffi needs to be installed after xcffib
- pip doesn’t care in which order it installs packages
- you can try
pip install cairocffi[xcb]
to make sure that cairocffi pulls xcffib, but still, pip will install cairocffi first (there is no such thing as conditionalinstall_requires
based onextras_requires
, even if it looks like pip implemented it at some point)- thus, the solution is to sequentially install xcffib, then cairocffi, ensuring that no cache is used when cairocffi is built (
pip install --no-cache-dir cairocffi
)What a mess. 🎉
_Originally posted by @ramnes in https://github.com/qtile/qtile/issues/994#issuecomment-497984551_
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Keep order of installation in pip freeze - Stack Overflow
Is there a way to ensure that pip freeze > requirements.txt keeps the order in which the packages were installed?
Read more >How to view all the packages installed in Ubuntu in the order ...
To see the list the installed packages sorted by install date/time using the following command: grep " install " /var/log/dpkg.log.
Read more >How can I get a list of packages that I have installed using apt ...
You can list installed package using apt using the following command: apt --installed list. Edit. Use the following command to list installed package...
Read more >NuGet Package Restore | Microsoft Learn
To promote a cleaner development environment and to reduce repository size, Package Restore makes all of a project's dependencies available ...
Read more >7.1 install cannot find packages to install, must configure ... - IBM
Tivoli Storage Manager Installation Manager cannot find packages to install. In order to access packages, you must configure a repository connection and can ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the detailed write-up!
From my understanding to the description and the context mentioned above, the main problem is that
cairocffi
only needsxcffib
when it is installed with[xcb]
. So it does not want to declare the build dependency unconditionally since it is not needed when[xcb]
is not requested.In that case, I believe the general recommendation is to split the part that depends
xcffib
into a separate package, and make[xcb]
add that package instead. Socairocffi-xcb
declares dependency onxcffib
both build-time and run-time.cairocffi
does not declare dependency onxcffib
anywhere directly, only oncairocffi-xcb
if[xcb]
is requested.This may make the project structure more complex, but fits better into the modern Python packaging architecture, and allows
cairocffi
(and the subprojectcairocffi-xcb
) to have prebuilt wheels, since the compilation dependency no longer needs to be detected on install-time. Extras in Python packaging are designed to specify optional run-time dependencies, not feature switches (although they are quite often [mis-]used as such).If you make an anology to pure-Python packages, all Python code in a project are always the same no matter. The same goes with compiled code—the compiled binary should be the same regardless of the extras. If you want to add code only when an extra is supplied, those code should be in the package specified as optional requirements, not in the main project.
To be very specific: I’m trying to use pipenv to have a reproducible installation of qtile, my window manager, including my config. qtile uses cairocffi to draw on an XCB surface. That is not core to cairocffi, but an extra: so “I want it to be” installed as cairocffi[xcb].
cairocffi[xcb] uses xcffib as a binding to XCB (a C library). In order to build with xcffib, cairocffi[xcb] needs xcffib to be present at build time as well as runtime. extras_require takes care of the latter, but as I understand it, that doesn’t take care of the build time requirement.
My first naïve try was
That works the first time (and subsequent once when cached wheels are used), but not on a different machine when everything gets installed in arbitrary order from the Pipfile.lock
I’ve tried making a shim package that I can install with
pipenv install .
that depends on xcffib as a build time requirement and on xcffib and cairocffi[xcb]. I tried withsetuptools.setup(setup_requires=['xcffib'], install_requires=['cariocffi[xcb]'])
in a setup.py and with xcffib and setuptools in the[build-system]
section in pyproject.toml and cairo in the setup.cfgBut as I understand it, the cairocffi[xcb] build gets done in isolation from my shim package, so xcffib isn’t present there at build time.
@tych0 please correct me if I am misrepresenting the situation. The only thing I know about cffi is that it’s the preferred way of c-binding of pypy as it doesn’t make any assumptions about reference counting, something the CPython c-api does do. I’ve never used it directly myself.