How to specify a different toxins project folder as a toxic project dependency

We have a tox -enabled project (call it a "main" project) that has a dependency on another toxicity project (let me call it a "library" project) - they are all combined into one repository, because it is all part of a large, comprehensive project.

How the project works for the average user

For a typical installation as an end user, you simply install "library" first and then "main", directly from the repository or any sources, and then run it.

What is our problem with tox

However, as a developer, the situation is different, because the "current" should work, and you may want to have several versions at the same time.

Usually you look at a large shared repository, and then the layout of the file system:

overarchingproject/main/ overarchingproject/main/src/ overarchingproject/main/tox.ini overarchingproject/main/setup.py ... overarchingproject/library/ overarchingproject/library/src/ overarchingproject/library/tox.ini overarchingproject/library/setup.py ... 

Now, if I enter main / and type "tox", this happens:

  • Current behavior:. He will try to build a "main" project with a dependency on the "library", which, obviously, will lead to an attempt to get the "library" from pip. However, the project has not yet been released (therefore not on pip), so it will not work even if lib is in the same repo.

    Result: it does not work.

    Workaround 1: We could set up our own package index / ask users to do this. However, asking everyone involved in the project to do this using DevPI or similar to be able to run unit tests doesn't seem to be such a good idea, so we need to do it centrally.

    But if we provided the package index in some central place or the pip package for the “library”, people couldn’t easily run the tests of the “main” one with the participation of the modified version of the “library” that they themselves created: / p>

    The "library" is in the same repository, so people can also change it at some point.

    The fact that entering the "current" inside the "main" folder of the project will not be easy to select for the current neighboring version of the "library", but only the finished online version is not intuitive.

    Workaround 2: We tried sitepackages = True and installed a “library” on the system - however sitepackages = True caused us a noticeable amount of problems, and this does not seem to be a good idea at all.

  • Desired behavior: We want explicit use of the local version of the “library” in this folder directly in the same comprehensive repository in which people usually fall into one thing:

    This version may be newer or even local, so this is clearly what the developer user wants to use. And it exists, which cannot be said about the package package right now.

Why do we still want the comprehensive repository with subprojects ("main", "library", ...), and not just one project?

We are developing a multi-inch large project with many demons for various purposes, with common code in some libraries to form a university course management system (which discusses forums, course management with the ability to transfer things, code version control systems) for student projects, etc. .).

You can simply use a subset of demons, so it makes sense that they are separate projects, but still they are so connected that most people want to have most of them - so they are all in the same repository.

The library itself is also suitable for use in completely different projects, but it is usually used for our purposes, so it is placed in the repository. Thus, this means that it is always around this relative path, but it has its own separate tox.ini and unit tests.

TL DR / Summary

So, how can we identify a specific dependency in another folder with a toxic project, and not just when installing the project?

Of course, the “basic” regular installation process setup.py should not mess with the phenomenon or look for a local drive: it should just check one specific relative path and then refuse if it doesn’t (and drop back to the pip or something else).

It would be best if the relative path could be somehow stored in tox.ini.

Or is this just a pretty bad idea? Should we solve it differently to make our "main" project lightly toxic with the latest local version of the "library" presented in the local repository?

+6
source share
2 answers

As stated in the comments on the Diabloneo reaction, install_command can be specified in the tox.ini file:

I used this to make a bash script that takes all the usual pip arguments, but then starts pip up with just pip install --editable="file:// pwd /../path/to/neighbour/repo" and only after that it actually starts the usual pip install $@ after that with the help of script arguments (as it would be passed directly to pip by the poison). Then I used this script with install_command instead of the usual default command.

With this two-step procedure, it works great :-)

+1
source

You can use the pip option - editable in your main project, for example:

 deps = --editable=file:///{toxinidir}/../library -r{toxinidir}/requirements.txt 

PS Do not use this style: -e file: /// {toxinidir} /../library, because the current passes the whole line as an argument to argparse in the foramt error.

+6
source

Source: https://habr.com/ru/post/971341/


All Articles