File: command_ref.rst

package info (click to toggle)
virtualenvwrapper 3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,140 kB
  • sloc: sh: 3,801; python: 991; makefile: 27
file content (739 lines) | stat: -rw-r--r-- 22,864 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
.. Quick reference documentation for virtualenvwrapper command line functions
    Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com)

..
    #################
    Command Reference
    #################

.. _command:

####################
コマンドリファレンス
####################

..
    All of the commands below are to be used on the Terminal command line.

全てのコマンドは次のようにターミナル上で使用されます。

..
    =====================
    Managing Environments
    =====================

==================
仮想環境を管理する
==================

.. _command-mkvirtualenv:

mkvirtualenv
------------

..
    Create a new environment, in the WORKON_HOME.

WORKON_HOME に新たな仮想環境を作成します。

..
    Syntax::

構文::

    mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME

..
    All command line options except ``-a``, ``-i``, ``-r``, and ``-h`` are passed
    directly to ``virtualenv``.  The new environment is automatically
    activated after being initialized.

``-a``, ``-i``, ``-r``, ``-h`` を除いた全てのコマンドラインオプションは ``virtualenv`` へ直接的に渡されます。新しい仮想環境は初期化された後に自動的にアクティブ化されます。

::

    $ workon
    $ mkvirtualenv mynewenv
    New python executable in mynewenv/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (mynewenv)$ workon
    mynewenv
    (mynewenv)$ 

..
    The ``-a`` option can be used to associate an existing project
    directory with the new environment.

``-a`` オプションは、既存のプロジェクトディレクトリに新しい環境を関連付けるのに使います。

..
    The ``-i`` option can be used to install one or more packages (by
    repeating the option) after the environment is created.

``-i`` オプションは、その環境を作成した後に指定したパッケージをインストールできます (このオプションを繰り返し使うことで複数のパッケージもインストールできます) 。

..
    The ``-r`` option can be used to specify a text file listing packages
    to be installed. The argument value is passed to ``pip -r`` to be
    installed.

``-r`` オプションは、インストールしたいパッケージ一覧を保存したテキストファイルを指定するのに使います。この引数のファイル名は ``pip -r`` へ渡されてインストールが行われます。

.. seealso::

   * :ref:`scripts-premkvirtualenv`
   * :ref:`scripts-postmkvirtualenv`
   * `requirements ファイルのフォーマット`_

.. _requirements file format: http://www.pip-installer.org/en/latest/requirement-format.html
.. _requirements ファイルのフォーマット: http://www.pip-installer.org/en/latest/requirements.html#the-requirements-file-format

.. _command-mktmpenv:

mktmpenv
--------

..
    Create a new virtualenv in the ``WORKON_HOME`` directory.

``WORKON_HOME`` ディレクトリに新しい環境を作成します。

..
    Syntax::

構文::

    mktmpenv [VIRTUALENV_OPTIONS]

..
    A unique virtualenv name is generated.

一意な名前をもつ virtualenv 環境が生成されます。

::

    $ mktmpenv
    Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7'
    New python executable in 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/bin/python
    Overwriting 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/lib/python2.7/distutils/__init__.py 
    with new content
    Installing distribute...............................................
    ....................................................................
    .................................................................done.
    This is a temporary environment. It will be deleted when deactivated.
    (1e513ac6-616e-4d56-9aa5-9d0a3b305e20) $

.. _command-lsvirtualenv:

lsvirtualenv
------------

..
    List all of the environments.

全ての仮想環境を表示します。

..
    Syntax::

構文::

    lsvirtualenv [-b] [-l] [-h]

-b
  ブリーフモード、冗長な出力を無効にする

.. Brief mode, disables verbose output.

-l
  ロングモード、冗長な出力を有効にする(デフォルト)

.. Long mode, enables verbose output.  Default.

-h
  lsvirtualenv のヘルプを表示する

.. Print the help for lsvirtualenv.

.. seealso::

   * :ref:`scripts-get_env_details`

.. _command-showvirtualenv:

showvirtualenv
--------------

..
    Show the details for a single virtualenv.

1つの仮想環境の詳細を表示します。

..
    Syntax::

構文::

    showvirtualenv [env]

.. seealso::

   * :ref:`scripts-get_env_details`

.. _command-rmvirtualenv:

rmvirtualenv
------------

..
    Remove an environment, in the WORKON_HOME.

WORKON_HOME の仮想環境を削除します。

..
    Syntax::

構文::

    rmvirtualenv ENVNAME

..
    You must use :ref:`command-deactivate` before removing the current
    environment.

カレントの仮想環境を削除する前に :ref:`command-deactivate` を実行しなければなりません。

::

    (mynewenv)$ deactivate
    $ rmvirtualenv mynewenv
    $ workon
    $

.. seealso::

   * :ref:`scripts-prermvirtualenv`
   * :ref:`scripts-postrmvirtualenv`

.. _command-cpvirtualenv:

cpvirtualenv
------------

..
    Duplicate an environment, in the WORKON_HOME.

WORKON_HOME の仮想環境を複製します。

..
    Syntax::

構文::

    cpvirtualenv ENVNAME TARGETENVNAME

.. note::

   .. The environment created by the copy operation is made `relocatable
      <http://virtualenv.openplans.org/#making-environments-relocatable>`__.

   コピー操作で作成された仮想環境は `再配置可能 <http://virtualenv.openplans.org/#making-environments-relocatable>`__ です。

::

    $ workon 
    $ mkvirtualenv source
    New python executable in source/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (source)$ cpvirtualenv source dest
    Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative
    Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative
    Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative
    Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python)
    Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python)
    Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python)
    Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python)
    (dest)$ workon 
    dest
    source
    (dest)$ 

.. seealso::

   * :ref:`scripts-precpvirtualenv`
   * :ref:`scripts-postcpvirtualenv`
   * :ref:`scripts-premkvirtualenv`
   * :ref:`scripts-postmkvirtualenv`

..
    ==================================
    Controlling the Active Environment
    ==================================

==============================
アクティブな仮想環境を制御する
==============================

workon
------

..
    List or change working virtual environments

作業する仮想環境を変更、または表示します。

..
    Syntax::

構文::

    workon [environment_name]

..
    If no ``environment_name`` is given the list of available environments
    is printed to stdout.

``environment_name`` が与えられない場合は標準出力に利用可能な仮想環境を表示します。

::

    $ workon 
    $ mkvirtualenv env1
      New python executable in env1/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env1)$ mkvirtualenv env2
    New python executable in env2/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env2)$ workon 
    env1
    env2
    (env2)$ workon env1
    (env1)$ echo $VIRTUAL_ENV
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1
    (env1)$ workon env2
    (env2)$ echo $VIRTUAL_ENV
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2
    (env2)$ 


.. seealso::

   * :ref:`scripts-predeactivate`
   * :ref:`scripts-postdeactivate`
   * :ref:`scripts-preactivate`
   * :ref:`scripts-postactivate`

.. _command-deactivate:

deactivate
----------

..
    Switch from a virtual environment to the system-installed version of
    Python.

仮想環境からシステムにインストールされた Python のバージョンに切り替えます。

..
    Syntax::

構文::

    deactivate

.. note::

    .. This command is actually part of virtualenv, but is wrapped to
       provide before and after hooks, just as workon does for activate.

    このコマンドは、実際は virtualenv の一部ですが、まさに workon が行うようにアクティブ化のために、処理の前後にフック機能を提供するためにラップされます。

::

    $ workon 
    $ echo $VIRTUAL_ENV

    $ mkvirtualenv env1
    New python executable in env1/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env1)$ echo $VIRTUAL_ENV
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1
    (env1)$ deactivate
    $ echo $VIRTUAL_ENV

    $ 

.. seealso::

   * :ref:`scripts-predeactivate`
   * :ref:`scripts-postdeactivate`

..
    ==================================
    Quickly Navigating to a virtualenv
    ==================================

========================
仮想環境へ簡単に移動する
========================

..
    There are two functions to provide shortcuts to navigate into the
    currently-active virtualenv.

カレントのアクティブ化された仮想環境内へ移動するためのショートカットを提供する2つの機能があります。

cdvirtualenv
------------

..
    Change the current working directory to ``$VIRTUAL_ENV``.

``$VIRTUAL_ENV`` へカレントワークディレクトリを移動します。

..
    Syntax::

構文::

    cdvirtualenv [subdir]

..
    Calling ``cdvirtualenv`` changes the current working directory to the
    top of the virtualenv (``$VIRTUAL_ENV``).  An optional argument is
    appended to the path, allowing navigation directly into a
    subdirectory.

``cdvirtualenv`` を呼び出すと、カレントワークディレクトリを仮想環境(``$VIRTUAL_ENV``)のトップへ移動します。オプションの引数はそのパスに追加されて、サブディレクトリへ直接的に移動することもできます。

::

    $ mkvirtualenv env1
    New python executable in env1/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env1)$ echo $VIRTUAL_ENV
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1
    (env1)$ cdvirtualenv
    (env1)$ pwd
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1
    (env1)$ cdvirtualenv bin
    (env1)$ pwd
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin

cdsitepackages
--------------

..
    Change the current working directory to the ``site-packages`` for
    ``$VIRTUAL_ENV``.

``$VIRTUAL_ENV`` の ``site-packages`` へカレントワークディレクトリを移動します。

..
    Syntax::

構文::

    cdsitepackages [subdir]

..
    Because the exact path to the site-packages directory in the
    virtualenv depends on the version of Python, ``cdsitepackages`` is
    provided as a shortcut for ``cdvirtualenv
    lib/python${pyvers}/site-packages``. An optional argument is also
    allowed, to specify a directory hierarchy within the ``site-packages``
    directory to change into.

仮想環境の site-packages ディレクトリへの正確なパスは Python のバージョンに依存するので、 ``cdsitepackages`` は ``cdvirtualenv lib/python${pyvers}/site-packages`` のショートカットです。さらにオプションの引数は直接移動する ``site-packages`` 内の階層構造のディレクトリを指定することもできます。

::

    $ mkvirtualenv env1
    New python executable in env1/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env1)$ echo $VIRTUAL_ENV
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1
    (env1)$ cdsitepackages PyMOTW/bisect/
    (env1)$ pwd
    /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect

lssitepackages
--------------

..
    Calling ``lssitepackages`` shows the content of the ``site-packages``
    directory of the currently-active virtualenv.

``lssitepackages`` を呼び出すと、カレントのアクティブ化された仮想環境の ``site-packages`` ディレクトリのコンテンツを表示します。

..
    Syntax::

構文::

    lssitepackages

::

    $ mkvirtualenv env1
    New python executable in env1/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env1)$ $ workon env1
    (env1)$ lssitepackages 
    distribute-0.6.10-py2.6.egg     pip-0.6.3-py2.6.egg
    easy-install.pth                setuptools.pth

..
    ===============
    Path Management
    ===============

========
パス管理
========

add2virtualenv
--------------

..
    Adds the specified directories to the Python path for the
    currently-active virtualenv.

カレントのアクティブ化された仮想環境の Python パスへ指定したディレクトリを追加します。

..
    Syntax::

構文::

    add2virtualenv directory1 directory2 ...

..
    Sometimes it is desirable to share installed packages that are not in
    the system ``site-pacakges`` directory and which should not be
    installed in each virtualenv.  One possible solution is to symlink the
    source into the environment ``site-packages`` directory, but it is
    also easy to add extra directories to the PYTHONPATH by including them
    in a ``.pth`` file inside ``site-packages`` using ``add2virtualenv``.

システムの ``site-pacakges`` ディレクトリに存在しないインストール済みのパッケージやそれぞれの仮想環境にインストールしたくないパッケージを共有したいときがあります。1つの解決方法はその仮想環境の ``site-packages`` ディレクトリへシンボリックリンクを張ることです。しかし、 ``add2virtualenv`` を使用して ``site-packages`` 内の ``.pth`` ファイルへそういったパッケージを含めることで、PYTHONPATH へ拡張ディレクトリを追加することも簡単です。

..
    1. Check out the source for a big project, such as Django.
    2. Run: ``add2virtualenv path_to_source``.
    3. Run: ``add2virtualenv``.
    4. A usage message and list of current "extra" paths is printed.

1. Django のような、大きなプロジェクトのソースをチェックアウトする
2. ``add2virtualenv path_to_source`` を実行する
3. ``add2virtualenv`` を実行する
4. 使用方法とカレントの "拡張された" パスリストが表示される

..
    The directory names are added to a path file named
    ``virtualenv_path_extensions.pth`` inside the site-packages directory
    for the environment.

site-packages ディレクトリ内の ``virtualenv_path_extensions.pth`` と名付けられたパスファイルへそのディレクトリ名が追加されます。

..
    *Based on a contribution from James Bennett and Jannis Leidel.*

*James Bennett と Jannis Leidel から提供されたものに基づいています。*

.. _command-toggleglobalsitepackages:

toggleglobalsitepackages
------------------------

..
    Controls whether the active virtualenv will access the packages in the
    global Python ``site-packages`` directory.

アクティブな virtualenv が、グローバルの Python ``site-packages`` ディレクトリにあるパッケージにアクセスさせるかどうかを制御します。

..
    Syntax::

構文::

    toggleglobalsitepackages [-q]

..
    Outputs the new state of the virtualenv. Use the ``-q`` switch to turn off all
    output.

実行すると virtualenv の更新後の状態を表示します。非表示にするには ``-q`` を指定してください。

::

    $ mkvirtualenv env1
    New python executable in env1/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    (env1)$ toggleglobalsitepackages
    Disabled global site-packages
    (env1)$ toggleglobalsitepackages
    Enabled global site-packages
    (env1)$ toggleglobalsitepackages -q
    (env1)$

..
    ============================
    Project Directory Management
    ============================

==============================
プロジェクトディレクトリの管理
==============================

.. seealso::

   :ref:`project-management`

.. _command-mkproject:

mkproject
---------

..
    Create a new virtualenv in the WORKON_HOME and project directory in
    PROJECT_HOME.

PROJECT_HOME にプロジェクトディレクトリと WORKON_HOME に新しい virtualenv を作成します。

..
    Syntax::

構文::

    mkproject [-t template] [virtualenv_options] ENVNAME

..
    The template option may be repeated to have several templates used to
    create a new project.  The templates are applied in the order named on
    the command line.  All other options are passed to ``mkvirtualenv`` to
    create a virtual environment with the same name as the project.

テンプレートオプションは、新しいプロジェクトを作成するのに使うテンプレートを複数指定できます。テンプレートはコマンドラインで指定した順番で適用されます。その他の全てのオプションは、プロジェクトと同じ名前をもつ仮想環境を作成するために ``mkvirtualenv`` に渡されます。

::

    $ mkproject myproj
    New python executable in myproj/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    Creating /Users/dhellmann/Devel/myproj
    (myproj)$ pwd
    /Users/dhellmann/Devel/myproj
    (myproj)$ echo $VIRTUAL_ENV
    /Users/dhellmann/Envs/myproj
    (myproj)$ 

.. seealso::

  * :ref:`scripts-premkproject`
  * :ref:`scripts-postmkproject`

.. _command-setvirtualenvproject:

setvirtualenvproject
--------------------

..
    Bind an existing virtualenv to an existing project.

既存の virtualenv を既存のプロジェクトに束縛します。

..
    Syntax::

構文::

  setvirtualenvproject [virtualenv_path project_path]

..
    The arguments to ``setvirtualenvproject`` are the full paths to the
    virtualenv and project directory.  An association is made so that when
    ``workon`` activates the virtualenv the project is also activated.

``setvirtualenvproject`` への引数は、virtualenv とプロジェクトディレクトリへのフルパスです。仮想環境のアクティブ化を ``workon`` で行うときに、そのプロジェクトもアクティブ化されるように連携します。

::

    $ mkproject myproj
    New python executable in myproj/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    Creating /Users/dhellmann/Devel/myproj
    (myproj)$ mkvirtualenv myproj_new_libs
    New python executable in myproj/bin/python
    Installing distribute.............................................
    ..................................................................
    ..................................................................
    done.
    Creating /Users/dhellmann/Devel/myproj
    (myproj_new_libs)$ setvirtualenvproject $VIRTUAL_ENV $(pwd)

..
    When no arguments are given, the current virtualenv and current
    directory are assumed.

引数を指定しない場合は、カレントの virtualenv とカレントディレクトリが指定されたと見なします。

..
    Any number of virtualenvs can refer to the same project directory,
    making it easy to switch between versions of Python or other
    dependencies for testing.

任意の数の virtualenv が、Python またはその他のテスト向けの依存関係をもったバージョン間で切り替えやすいように、同じプロジェクトディレクトリを参照できます。

.. _command-cdproject:

cdproject
---------

..
    Change the current working directory to the one specified as the
    project directory for the active virtualenv.

カレントのワークディレクトリから、アクティブな virtualenv のプロジェクトディレクトリとして指定したディレクトリに変更します。

..
    Syntax::

構文::


  cdproject