Github Desktop not honouring pylint installed in a .venv - pylint

I have a python project running in a virtual environment (created by poetry).
pylint is installed only in the virtual environment, not in the base.
pylint works well in the venv from command line, via pre-commit and inside Visual Studio Code which I start from the command line (poetry shell).
GitHub desktop cannot be started from the venv command line and when I try using it to commit my updated code it fails because the pre-commit hooks are launched and fail since it does not find pylint.
How to fix (other than installing pylint in the base env)?

pre-commit try to use a separate virtualenv, you need to tell it to use the local venv with something like this:
- repo: local
hooks:
- id: pylint
name: pylint

Related

Python packages are not installing in my virtual environment

I set up a Python virtual environment in 'Visual Studio Code'. Here is the full path to my python interpreter:
"C:\Users\Hamid\Desktop\VisualStudio.venv\Scripts\python.exe"
I am creating an Azure function. I have the following files in my folder:
In my requirements.txt file I have the names of the Python packages I need installed for my main Python script. When I run the following command in the terminal:
pip install -r requirements.txt
I get the following message:
Requirement already satisfied: azure-functions in c:\users\hamid\appdata\local\programs\python\python39\lib\site-packages (from -r requirements.txt (line 5)) (1.12.0)
The Terminal doesn't seem to be connected to my Virtual Python environment. How can I set the terminal up so that it connects to the virtual enviornment?.
I came across two suggestions on stackoverflow. I tried to manually set the python interpreter and I also pressed ctrl+shift+' to reset the terminal. Unfortunately both methods did not work for me.
One of the workarounds is to activate the virtual environment and change the function run path to virtual environment folder in the VS Code terminal:
python -m venv .venv
source .venv/bin/activate
OR
set-executionpolicy remotesigned
.venv\Scripts\Activate.ps1
OR
when you open the project in VS Code, you'll get the dialog box like below and click on yes:
and freeze the requirements file using the cmdlet
pip freeze > requirements.txt`
Refer to few of my workarounds SO Thread1 and Thread2 in regards of Virtual Environment activating in Azure Functions

Does poetry (or pip) 'install' create/have the option to deploy an executable?

I am running
poetry install
from within a python local virtualenv ".venv" . The project is supposed to create an executable hercl that becomes available on the user's path. Two questions:
What options / configuration of I'm not sure if that's supposed to gets installed into the local .venv/bin or in the pyenv shims.
Since poetry reuses / redirects many functions to pip it may be the case that the feature I'm asking about is actually from pip itself. I have not been able to discover from either poetry or pip documentation about this shell script installation. How is this achieved?
Update
After running running pip install outside of the virtualenv it pulls from pypi and creates a bash script ~/.pyenv/shims/my_app .
In my case the my_app is "hercl" and we see this:
$which hercl
~/.pyenv/shims/hercl
Its contents are :
$cat $(which hercl)
#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x
program="${0##*/}"
export PYENV_ROOT="~/.pyenv"
exec "~/.pyenv/libexec/pyenv" exec "$program" "$#"
Somehow this script is installed when running pip install: I am wondering how pip knows to do this. Is it from the pyproject.ml from poetry ? Is it from a setup.py or setup.cfg associated with pip ?
Anoterh Update #sinoroc has another tack on this: poetry has a scripts section that I did not notice (noobie on that tool).
[tool.poetry.scripts]
hercl = "hercl.hercl:main"
hercl is a command that I was looking for .
But there was also an actual _bash script that would launch hercl that got installed under the shims as part of the virtualenv. i think that script were in the
In a Poetry-based project such executable scripts are defined in the scripts section of pyproject.toml.
If a virtual environment is active when installing the application then the executable is installed in the virtual environment's bin directory. So it is available only while the virtual environment is "active".

vs code git error: Git: /usr/bin/bash: init: No such file or directory

EDIT: I've rebooted my computer, and the issue is fixed. I have no idea why it fixed it.
In vs code on windows, when I try to Initialize Repository, I get the error
However, it used to worked fine. It changed when I tried to install Ubuntu on Windows following this video. Git is installed, and the path is in the .json file.
I'll recommend you to install git in ubuntu by apt
The git.path you've specified is to bash, not git. There's probably some wrapper that invokes that binary using git, and so when you type git init, you're really invoking bash init, which asks bash to run the script named init. Since it doesn't exist, your command is failing.
You should set git.path to a path to a Git binary, and not a bash binary.

Anaconda equivalent of "setup.py develop"

How can I install a package under development to an Anaconda environment?
With pip:
pip install -e /path/to/mypackage
or with regular setuptools:
python /path/to/mypackage/setup.py develop
There is also conda develop available now.
http://conda.pydata.org/docs/commands/build/conda-develop.html
Update in 2019: conda develop hasn't been maintained and is not recommended. See https://github.com/conda/conda-build/issues/1992
Recommendation is to use python setup.py develop or pip install -e .
Using either of those will work with Anaconda. Make sure that you have pip or setuptools installed into the conda environment you want to install into, and that you have it activated.
This is the equivalent to pip install -e .
conda install conda-build
conda develop .
As explained in this gh issue thread, because of build isolation and dependency installation, Anaconda developers recommend using:
pip install --no-build-isolation --no-deps -e .
Build / Host Environment
To create build and host environments and a build script go to your recipe directory and use
conda debug /path/to/your/recipe-directory
as documented here. This will print an instructive message like
################################################################################
Build and/or host environments created for debugging. To enter a debugging environment:
cd /home/UserName/miniconda3/conda-bld/debug_1542385789430/work && source /home/UserName/miniconda3/conda-bld/debug_1542385789430/work/build_env_setup.sh
To run your build, you might want to start with running the conda_build.sh file.
################################################################################
(The message might tell you incorrectly, that it created a test environment.) Your source code has been copied to the .../work directory and there is also a conda_build.sh script. Note, that sourcing the build_env_setup.sh will load both build and host environments.
You can work on your code and your recipe and build with the conda_build.sh, but you won't get a proper conda package, as far as I know. When you are finished, you can remove the debug environment:
conda deactivate # maybe twice
conda build purge
Test Environment
To get the test environment, you have to build the package first and then debug that. This might be useful to fix your test files.
conda build /path/to/your/recipe-directory # creates mypackage*.tar.bz2
# find file location of mypackage*.tar.bz2 with:
conda search --info --use-local mypackage # look at the url row for the path
cd /path/to/miniconda3/conda-bld/linux-64/ # go to that path, can be different
conda debug mypackage*.tar.bz2
This will print e. g.:
################################################################################
Test environment created for debugging. To enter a debugging environment:
cd /home/UserName/miniconda3/conda-bld/debug_1542385789430/test_tmp && source /home/UserName/miniconda3/conda-bld/debug_1542385789430/work/conda_test_env_vars.sh
To run your tests, you might want to start with running the conda_test_runner.sh file.
################################################################################
Again, remove with
conda deactivate
conda build purge
Run Environment
This is actually no debugging, but the general process of building and installing a local package. With the run environment you can check, whether all dependencies are specified in the requirements/run section. Also pinning can be an issue.
(base) $ conda build /path/to/your/recipe-directory
(base) $ conda create --name package-env --use-local mypackage
(base) $ conda activate package-env
(package-env) $ python
>>> import mypackage
You can also list the dependencies of your package with (man page)
conda search --info --use-local mypackage
A last hint: If you want to know the versions of the dependencies and see, whether pinning works, try (man page)
conda render /path/to/your/recipe-directory

How to install go-sql-driver on Windows

I am trying to install go-sql-driver on Windows Vista but I am having problems with GOPATH.
I installed git as suggested and added GOPATH as a new user environment in Windows with path C:/users/A/desktop/go.
I ran go get github.com/go-sql-driver/mysql in the command line but it gives me this error:
C:\>go get github.com/go-sql-driver/mysql
go: missing Git command. See http://golang.org/s/gogetcmd
package github.com/go-sql-driver/mysql: exec: "git": executable file not found in %PATH%
When I go look at http://golang.org/s/gogetcmd it merely says download git. But it is already downloaded in my machine.
I also went ahead and created a new environement variable for PATH and set its path to the directory where git was installed but that did not help either.
What am I doing wrong?
Download the Windows version of Git from http://git-scm.com/downloads.
Run the downloaded executable file, currently Git-1.8.3-preview20130601.exe, which will start a Git Setup wizard to install Git.
Check Git Setup Options
Run Git from the Windows Command Prompt
Checkout as-is, commit Unix-style line endings
Check the installation by running:
C:\>git --version
git version 1.8.3.msysgit.0
Make sure Git is in the %PATH% environment variable and ensure Git is installed. If you cannot run git --version in the command prompt, then the Git binary directory isn't listed in your %PATH%. Fix this by adding Git to the path, close the command prompt, and run git --version in a new command prompt. If you're still having issues, then you might be having other problems.
Install the GIT BASH desktop app in your Windows PC. The download link is here. Once installed, open the shell and type:
go get -u github.com/go-sql-driver/mysql
This will install driver for Golang's MySQL database package

Resources