question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to determine how to use pre-existing virtualenv for a hook

See original GitHub issue

Sorry, I’m not sure if an issue is the right place to put this, but considering I’ve spent some time reading source and docs and haven’t found the answer it seems fair to consider this a documentation bug.

My use case is this: I have many Python projects I work on. Each one has its own virtualenv where I install the dependencies. I’d like to use pre-commit to run pylint. Pylint needs to run out of the same virtualenv as the project so that it can import the dependencies for its static analysis. When running the pylint hook from https://github.com/pre-commit/mirrors-pylint it appears that the command that is actually run is:

bash -c . '/Users/eliribble/.pre-commit/repoq_elftwa/py_env-default/bin/activate' && xargs -0 -s4000 pylint

Looking at the source and the docs I can’t find a way to indicate to the hook that it should use my virtualenv for the project rather than the virtualenv at /Users/eliribble/.pre-commit/repoq_elftwa/py_env-default. Is there a way to do that?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
webknjazcommented, Jun 24, 2018

Yeah, I just didn’t want to mutate existing app’s env.

0reactions
asottilecommented, Jun 23, 2018

and again, pylint is a bit of a special snowflake here – it does both static analysis and dynamic analysis (which needs to actually import your code)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can an existing folder be re-declared a virtual environment?
Yes. Anatomy of virtualenvwrapper. The existing project has two parts: the virtualenv, where python and the python libs are installed, and ...
Read more >
Best Practices - Apache Airflow
As a DAG Author, you only have to have virtualenv dependency installed and you can specify and modify the environments as you see...
Read more >
Python Virtual Environments tutorial using Virtualenv and Poetry
A mini-guided Python tutorial showing how to use virtual environment and why it's matters on virtualenv and poetry illustrated examples.
Read more >
pre-commit
Hooks that are run via boot2docker are known to be unable to make modifications to files. See this repository for an example Docker-based...
Read more >
Basic usage | Documentation | Poetry - Python dependency ...
Basic usage. Project setup. Initialising a pre-existing project; Specifying dependencies. Using your virtual environment. Using poetry run ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found