You just need to check if package B is up-to-date before you start the installation of A. So (in your Jenkins job) just put a build step to download everything for B, and after that everything for A.
I'm developing a service in Python which has a package as a dependency. I've developed that dependency myself.
I have a private PyPI server that contains artifacts(a wheel file) of every commit in the master branch(for both packages).
I'd like to create a CI which will use pip to install the dependency from the private PyPI server(because it's faster and easier than installing from the source code itself every time).
Example for the project's dependencies:

packages A requires package B
(which are all in the private repository and not public packages).

My problem is that if I'm trying to execute a CI on the A repository right after the B repository had a merge to master,
the private PyPI server won't have the latest version of B yet(Today there's a Jenkins job that is activated after every merge to master and uploads the B wheel to the private PyPI server,
but it takes a few minutes until the package is being built). The result is that package A might contain an old version of B instead of using the latest version of B.
Any suggestion on how to improve this process?
Installing from a private PyPI, in comparison to installing directly from Gitlab decreases the time it takes to install dramatically.
BTW, today I am using Gitlab's enterprise edition and Jenkins.
Thanks
Building a pipeline for multiple-repository services