Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to point towards the path of the environment to use for inferring package distribution information. #161

Closed
Tracked by #142
mknorps opened this issue Feb 17, 2023 · 1 comment

Comments

@mknorps
Copy link
Collaborator

mknorps commented Feb 17, 2023

To be able to test the behaviour of FawltyDeps on real projects and to see the improvement, we need to have a way to define and use an environment different that the FD test environment.

This issue was mentioned by @jherland, @Nour-Mws and @mknorps on many occasions:

  • in tests_map_dep_name_to_import_names.py:

    # TODO: These tests are not fully isolated, i.e. they do not control the
    # virtualenv in which they run. For now, we assume that we are running in an
    # environment where at least these packages are available:
    # - setuptools (exposes multiple import names, including pkg_resources)
    # - pip (exposes a single import name: pip)
    # - isort (exposes no top_level.txt, but 'isort' import name can be inferred)
    
  • in Incorporating dependency to imports mapping #150

  • in slack communication:
    @Nour-Mws

    Thinking out loud: with our current local-dep-to-import mapping, even when Incorporating dependency to imports mapping #150 is merged, it will still be impossible to run fawltydeps in the real projects tests, without installing all the deps defined by a project in the env in which fawltydeps is running?
    In other terms, if we want to separate project x run from project y run, we can't use the current test setup, as they all currently run in the same environment.
    Another thing to note is that since fawltydeps needs to be in the env of the project that it tests, it may be the case that some of the project's undeclared deps end up installed by fawltydeps, and so while for a project declaring pyml, you might have ended with: "I couldn't find pyml in the env, mapping to pyml", you actually find the given package in the env.
    Thoughts?

    @jherland

    True. Also PR Run real worlds projects tests with cmd line tool #147 did change real_projects to run fawlytdeps in a subprocess, and with that we could run it inside a different environment, but we still have to add the functionality to setup those environments and then make fawltydeps run inside them.
    In short, I think there are three different scenarios we could look at here:
    A. FD can only query packages inside the environment it is running. This is where we are, and we really haven't planned on changing that all, yet. (The real_projects work would "simply" be about installing and running FD inside the various test environments.)
    B. Make FD somehow able to switch its execution context from one environment to another. I think this is impossible in general (without switching processes), but it might be possible to e.g. call importlib_metadata.packages_distributions() in a subprocess (than runs inside the target environment). However, this still relies on importlib_metadata being installed in that environment.
    C. It might be possible to configure/customize importlib_metadata to examine a different environment than the current environment. Worst case, we could even write our own version of it. I have not looked deeply into this yet.

@mknorps mknorps changed the title Add the possibility to point towards the path of the environment to use for inferring package distribution information. LATER Add the possibility to point towards the path of the environment to use for inferring package distribution information. Feb 17, 2023
@Nour-Mws Nour-Mws self-assigned this Feb 17, 2023
mknorps added a commit that referenced this issue Feb 18, 2023
It is a temporary solution for problem

of taking the D2I mapping from the same environment

as tests are run.

More general solution should come with solving #161
mknorps added a commit that referenced this issue Feb 20, 2023
It is a temporary solution for problem

of taking the D2I mapping from the same environment

as tests are run.

More general solution should come with solving #161
mknorps added a commit that referenced this issue Feb 20, 2023
Fix filter function for unused dependency

to work well for ignored_unused_deps

Edit test case for mixed dependencies

Fix compare tests to use D2I mapping

Change tests with black to flake8

It is a temporary solution for problem

of taking the D2I mapping from the same environment

as tests are run.

More general solution should come with solving #161
mknorps added a commit that referenced this issue Feb 20, 2023
Fix filter function for unused dependency

to work well for ignored_unused_deps

Edit test case for mixed dependencies

Fix compare tests to use D2I mapping

Change tests with black to flake8

It is a temporary solution for problem

of taking the D2I mapping from the same environment

as tests are run.

More general solution should come with solving #161
@Nour-Mws Nour-Mws removed their assignment Feb 21, 2023
@Nour-Mws
Copy link
Collaborator

Closed via #219.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants