Skip to content

Optionally skip creation of .gitignore in virtualenv directory #2003

Closed
@compwiztobe

Description

@compwiztobe

While version controlling the virtualenv binaries etc. is not desirable, some of us version control pyvenv.cfg as well as other metadata we store about each environment (such as a pip requirements file), to facilitate portability of venv definitions. Before the merge of #1825 in response to #1806, that problem was already easily solvable with a top level .gitignore listing the typical Python bin/, lib/, share/, etc. directories to be ignored.

The * directive in the virtualenv subdirectories cannot be overridden by any .gitignore files in parent directories. If we could pass an option to virtualenv to disable the creation of this blanket * .gitignore, then existing .gitignore files in the venv directory AND all parent directories would continue to work as expected, and we could continue to track chosen config files stored in each environment directory.

For now, here's a workaround:

if [[ ! -f "$venv/.gitignore" ]]; then
  virtualenv $venv
  rm $venv/.gitignore
else
  virtualenv $venv
fi

but I would much rather be able to do this with something like

virtualenv $venv --no-gitignore

to recover the old behavior.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions