Skip to content

Commit f996fd6

Browse files
committed
Rewrite docs w/ Cline + Claude AI prompt for more cohesive technical voice and expanded examples.
1 parent 1cf036a commit f996fd6

23 files changed

+8529
-1384
lines changed

docs/advanced.md

Lines changed: 429 additions & 290 deletions
Large diffs are not rendered by default.

docs/best_practices.md

Lines changed: 464 additions & 0 deletions
Large diffs are not rendered by default.

docs/cli.md

Lines changed: 498 additions & 74 deletions
Large diffs are not rendered by default.

docs/commands.md

Lines changed: 468 additions & 46 deletions
Large diffs are not rendered by default.

docs/configuration.md

Lines changed: 315 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,334 @@
1-
# Configuration
1+
# Pipenv Configuration
22

3-
## Configuration With Environment Variables
3+
This document covers the various ways to configure Pipenv's behavior through environment variables, configuration files, and command-line options.
44

5-
Pipenv comes with a handful of options that can be set via shell environment
6-
variables.
5+
## Environment Variables
76

8-
To enable boolean options, create the variable in your shell and assign to it a
9-
true value. Allowed values are: `"1", "true", "yes", "on"`
7+
Pipenv can be customized through environment variables, which is particularly useful for CI/CD pipelines, team-wide settings, or personal preferences.
108

11-
$ PIPENV_IGNORE_VIRTUALENVS=1
9+
### Setting Environment Variables
1210

13-
To explicitly disable a boolean option, assign to it a false value (i.e. `"0"`).
11+
#### Temporary (Session-Only)
1412

15-
```{eval-rst}
16-
.. autoclass:: pipenv.environments.Setting
17-
:members:
13+
```bash
14+
# Unix/Linux/macOS
15+
$ export PIPENV_VENV_IN_PROJECT=1
16+
$ pipenv install
17+
18+
# Windows (Command Prompt)
19+
> set PIPENV_VENV_IN_PROJECT=1
20+
> pipenv install
21+
22+
# Windows (PowerShell)
23+
> $env:PIPENV_VENV_IN_PROJECT=1
24+
> pipenv install
25+
```
26+
27+
#### Permanent
28+
29+
For Unix/Linux/macOS, add to your shell profile (e.g., `~/.bashrc`, `~/.zshrc`):
30+
31+
```bash
32+
export PIPENV_VENV_IN_PROJECT=1
33+
```
34+
35+
For Windows, set through System Properties > Environment Variables.
36+
37+
### Boolean Options
38+
39+
To enable boolean options, set the variable to a true value: `"1"`, `"true"`, `"yes"`, or `"on"`.
40+
41+
To disable a boolean option, set it to a false value: `"0"`, `"false"`, `"no"`, or `"off"`.
42+
43+
### Available Environment Variables
44+
45+
#### Virtual Environment
46+
47+
| Variable | Description | Default |
48+
|----------|-------------|---------|
49+
| `PIPENV_VENV_IN_PROJECT` | Create virtualenv in project directory | `0` |
50+
| `PIPENV_IGNORE_VIRTUALENVS` | Ignore active virtualenvs | `0` |
51+
| `PIPENV_CUSTOM_VENV_NAME` | Use custom virtualenv name | None |
52+
| `PIPENV_VIRTUALENV` | Path to virtualenv executable | Detected from system |
53+
| `PIPENV_PYTHON` | Path to Python executable | Detected from system |
54+
| `PIPENV_DEFAULT_PYTHON_VERSION` | Default Python version to use | System default |
55+
| `VIRTUAL_ENV` | Current active virtualenv | None |
56+
57+
#### Installation and Dependencies
58+
59+
| Variable | Description | Default |
60+
|----------|-------------|---------|
61+
| `PIPENV_INSTALL_DEPENDENCIES` | Install package dependencies | `1` |
62+
| `PIPENV_RESOLVE_VCS` | Resolve VCS dependencies | `1` |
63+
| `PIPENV_SKIP_LOCK` | Skip lock when installing | `0` |
64+
| `PIPENV_PYPI_MIRROR` | PyPI mirror URL | None |
65+
| `PIPENV_MAX_DEPTH` | Maximum depth for dependency resolution | `10` |
66+
| `PIPENV_TIMEOUT` | Timeout for pip operations | `15` |
67+
| `PIPENV_INSTALL_TIMEOUT` | Timeout for package installation | `900` |
68+
69+
#### File Locations
70+
71+
| Variable | Description | Default |
72+
|----------|-------------|---------|
73+
| `PIPENV_PIPFILE` | Custom Pipfile location | `./Pipfile` |
74+
| `PIPENV_CACHE_DIR` | Custom cache directory | `~/.cache/pipenv` |
75+
| `PIPENV_DOTENV_LOCATION` | Custom .env file location | `./.env` |
76+
77+
#### Behavior
78+
79+
| Variable | Description | Default |
80+
|----------|-------------|---------|
81+
| `PIPENV_DONT_LOAD_ENV` | Don't load .env files | `0` |
82+
| `PIPENV_DONT_USE_PYENV` | Don't use pyenv | `0` |
83+
| `PIPENV_DONT_USE_ASDF` | Don't use asdf | `0` |
84+
| `PIPENV_SHELL_FANCY` | Use fancy shell | `0` |
85+
| `PIPENV_NOSPIN` | Disable spinner animation | `0` |
86+
| `PIPENV_QUIET` | Quiet mode | `0` |
87+
| `PIPENV_VERBOSE` | Verbose mode | `0` |
88+
| `PIPENV_YES` | Yes to all prompts | `0` |
89+
| `PIPENV_IGNORE_PIPFILE` | Ignore Pipfile, use only lock | `0` |
90+
| `PIPENV_REQUESTS_TIMEOUT` | Timeout for HTTP requests | `10` |
91+
| `PIPENV_CLEAR` | Clear caches on run | `0` |
92+
| `PIPENV_SITE_PACKAGES` | Enable site-packages for virtualenv | `0` |
93+
94+
#### Security
95+
96+
| Variable | Description | Default |
97+
|----------|-------------|---------|
98+
| `PIPENV_PYUP_API_KEY` | PyUp.io API key for security checks | None |
99+
100+
### Examples
101+
102+
#### Store virtualenvs in the project directory
103+
104+
```bash
105+
export PIPENV_VENV_IN_PROJECT=1
106+
```
107+
108+
This creates a `.venv` directory in your project, making it easier to manage and find the virtualenv.
109+
110+
#### Use a custom Python version by default
111+
112+
```bash
113+
export PIPENV_DEFAULT_PYTHON_VERSION=3.10
114+
```
115+
116+
This sets Python 3.10 as the default when creating new environments.
117+
118+
#### Skip lock file generation during development
119+
120+
```bash
121+
export PIPENV_SKIP_LOCK=1
122+
```
123+
124+
This speeds up installation during development, but should not be used in production environments.
125+
126+
#### Use a PyPI mirror
127+
128+
```bash
129+
export PIPENV_PYPI_MIRROR=https://mirrors.aliyun.com/pypi/simple/
130+
```
131+
132+
This is useful in regions where accessing the official PyPI might be slow.
133+
134+
#### Increase timeout for large packages
135+
136+
```bash
137+
export PIPENV_INSTALL_TIMEOUT=1800
138+
```
139+
140+
This increases the timeout to 30 minutes for installing large packages.
141+
142+
## Configuration with pip
143+
144+
Pipenv uses pip under the hood, so you can also use pip's configuration options. These can be set through:
145+
146+
1. Environment variables (e.g., `PIP_TIMEOUT`, `PIP_INDEX_URL`)
147+
2. pip configuration files (`pip.conf` or `pip.ini`)
148+
149+
### Common pip Environment Variables
150+
151+
| Variable | Description |
152+
|----------|-------------|
153+
| `PIP_INDEX_URL` | Base URL of the Python Package Index |
154+
| `PIP_EXTRA_INDEX_URL` | Additional index URLs |
155+
| `PIP_TRUSTED_HOST` | Mark a host as trusted |
156+
| `PIP_RETRIES` | Number of retries for network operations |
157+
| `PIP_TIMEOUT` | Timeout for HTTP requests |
158+
| `PIP_DEFAULT_TIMEOUT` | Default timeout for HTTP requests |
159+
| `PIP_FIND_LINKS` | Additional locations to find packages |
160+
| `PIP_NO_CACHE_DIR` | Disable the cache |
161+
| `PIP_CACHE_DIR` | Cache directory |
162+
163+
### Examples
164+
165+
#### Using a private package index
166+
167+
```bash
168+
export PIP_INDEX_URL=https://private-repo.example.com/simple
169+
export PIP_TRUSTED_HOST=private-repo.example.com
170+
```
171+
172+
#### Passing additional options to pip
173+
174+
```bash
175+
export PIP_INSTALL_OPTION="--no-deps"
176+
```
177+
178+
#### Combining with Pipenv options
179+
180+
```bash
181+
export PIP_INDEX_URL=https://private-repo.example.com/simple
182+
export PIPENV_TIMEOUT=60
183+
pipenv install requests
184+
```
185+
186+
## Project-Specific Configuration
187+
188+
### Using .env Files
189+
190+
Pipenv automatically loads environment variables from `.env` files in your project directory. This is useful for project-specific settings:
191+
192+
```
193+
# .env file
194+
PIPENV_VENV_IN_PROJECT=1
195+
PIP_INDEX_URL=https://private-repo.example.com/simple
196+
```
197+
198+
### Custom .env Location
199+
200+
You can specify a custom location for your `.env` file:
201+
202+
```bash
203+
export PIPENV_DOTENV_LOCATION=/path/to/custom/.env
204+
pipenv shell
205+
```
206+
207+
### Disabling .env Loading
208+
209+
If you don't want Pipenv to load `.env` files:
210+
211+
```bash
212+
export PIPENV_DONT_LOAD_ENV=1
213+
pipenv shell
214+
```
215+
216+
## Command-Line Options
217+
218+
Many configuration options can also be set directly via command-line arguments, which take precedence over environment variables:
219+
220+
```bash
221+
pipenv install --python 3.9 --site-packages
222+
```
223+
224+
## Advanced Configuration
225+
226+
### Changing Cache Location
227+
228+
The default cache location is `~/.cache/pipenv` on Unix/Linux/macOS and `%LOCALAPPDATA%\pipenv\Cache` on Windows. You can change this:
229+
230+
```bash
231+
export PIPENV_CACHE_DIR=/path/to/custom/cache
18232
```
19233

20-
Also note that `pip` supports additional [environment variables](https://pip.pypa.io/en/stable/user_guide/#environment-variables), if you need additional customization.
234+
This is useful when:
235+
- You have limited space in your home directory
236+
- You want to share the cache across users
237+
- You're working in an environment with restricted permissions
238+
239+
### Network Configuration in Restricted Environments
240+
241+
For environments with network restrictions:
242+
243+
```bash
244+
# Increase timeout for slow connections
245+
export PIPENV_TIMEOUT=60
246+
export PIP_TIMEOUT=60
247+
248+
# Use a proxy
249+
export HTTP_PROXY=http://proxy.example.com:8080
250+
export HTTPS_PROXY=http://proxy.example.com:8080
251+
252+
# Specify trusted hosts that don't need HTTPS
253+
export PIP_TRUSTED_HOST=internal-repo.example.com
254+
```
255+
256+
### CI/CD Pipeline Configuration
257+
258+
For continuous integration environments:
259+
260+
```bash
261+
# Non-interactive mode
262+
export PIPENV_YES=1
263+
export PIPENV_NOSPIN=1
264+
export PIPENV_QUIET=1
265+
266+
# Fail if lock file is out of date
267+
pipenv install --deploy
268+
```
269+
270+
### Development vs. Production Settings
271+
272+
#### Development
273+
274+
```bash
275+
# Development environment
276+
export PIPENV_VENV_IN_PROJECT=1 # Keep virtualenv with project
277+
export PIPENV_MAX_DEPTH=20 # Allow deeper dependency resolution
278+
```
279+
280+
#### Production
281+
282+
```bash
283+
# Production environment
284+
export PIPENV_IGNORE_PIPFILE=1 # Use only the lock file
285+
export PIPENV_NOSPIN=1 # Disable spinner for cleaner logs
286+
pipenv install --deploy # Fail if lock file is out of date
287+
```
288+
289+
## Troubleshooting Configuration Issues
290+
291+
### Checking Current Configuration
292+
293+
To see what environment variables Pipenv is using:
294+
295+
```bash
296+
pipenv --support
297+
```
298+
299+
This shows all active Pipenv-related environment variables and their values.
300+
301+
### Common Configuration Problems
302+
303+
#### Virtualenv Creation Fails
21304

22-
For example:
305+
If virtualenv creation fails, check:
306+
- `PIPENV_PYTHON` points to a valid Python executable
307+
- You have permissions to write to the virtualenv directory
308+
- `PIPENV_VENV_IN_PROJECT=1` if you're in a directory with restricted permissions
23309

24-
$ PIP_INSTALL_OPTION="-- -DCMAKE_BUILD_TYPE=Release" pipenv install -e .
310+
#### Package Installation Timeouts
25311

26-
## Changing Cache Location
312+
If package installations time out:
313+
- Increase `PIPENV_TIMEOUT` and `PIPENV_INSTALL_TIMEOUT`
314+
- Check network connectivity to PyPI or your custom index
315+
- Consider using a PyPI mirror with `PIPENV_PYPI_MIRROR`
27316

28-
You can force pipenv to use a different cache location by setting the environment variable `PIPENV_CACHE_DIR` to the location you wish.
29-
This is useful in the same situations that you would change `PIP_CACHE_DIR` to a different directory.
317+
#### Lock File Generation Issues
30318

31-
## Changing Default Python Versions
319+
If lock file generation fails:
320+
- Ensure there are no conflicting dependencies
321+
- Try `PIPENV_RESOLVE_VCS=0` if you have VCS dependencies causing issues
322+
- Increase `PIPENV_MAX_DEPTH` for complex dependency trees
32323

33-
By default, pipenv will initialize a project using whatever version of python the system has as default.
34-
Besides starting a project with the `--python` flag, you can also use `PIPENV_DEFAULT_PYTHON_VERSION` to specify what version to use when starting a project when `--python` isn't used.
324+
## Best Practices
35325

36-
## Environments with network issues
326+
1. **Version Control**: Don't commit environment-specific settings to version control. Use `.env` files that are excluded via `.gitignore`.
37327

38-
If you are trying to use pipenv in an environment with network issues, you may be able to try modifying
39-
the following settings when you encounter errors related to network connectivity.
328+
2. **Documentation**: Document required environment variables in your project's README.
40329

41-
### REQUESTS_TIMEOUT
330+
3. **Consistency**: Use the same configuration across development, testing, and production environments when possible.
42331

43-
Default is 10 seconds. You can increase it by setting `PIPENV_REQUESTS_TIMEOUT` environment variable.
332+
4. **Minimal Configuration**: Only set the variables you need to change from defaults.
44333

45-
Please notice that this setting only affects pipenv itself, not additional packages such as [safety](advanced.rst).
334+
5. **Security**: Be careful with security-sensitive settings like API keys. Use environment variables rather than committing them to files.

0 commit comments

Comments
 (0)