The environment created in this post can be built with https://bitbucket.org/toruuetani/venv_base
.
Running hg clone
and running cmd.bat
builds a virtualenv environment with Fabric installed.
It is another windows PC that develops on a windows PC and runs it. However, the PC works in an offline environment.
Because pip cannot be installed from binary. Non-pure python packages have to be compiled from source, but unlike linux, windows often doesn't have a C compiler, so you can't install them. Therefore, a binary package is available for windows (such as XXX-1.2.1.win32-py2.7.exe). This binary package works fine with easy_install, but not with pip. So no matter how much pip evolved, it was easy_install for windows.
The above situation has been improved with the advent of the wheel. The wheel format also includes binaries, so with the exception of special packages (pywin32, psycopg2, py2exe, etc.), you can do it with just pip.
2014/02/14 postscript -> Here, but wininst2wheel makes it easier to migrate from easy_install to pip.
I can't think of an environment that doesn't use virtualenv at the moment, so I'll use it.
The following directories are used in the following explanations.
If you download virtualenv-1.11.2.tar.gz from https://pypi.python.org/pypi/virtualenv/ and unzip it, the following file will be created, so use this.
python virtualenv.py %VENV_DIR%
Now you can use easy_install and pip.
Download and use wheel-0.22.0.tar.gz from https://pypi.python.org/pypi/wheel/.
pip install wheel-0.22.0.tar.gz
Now you can use the wheel format.
By convention, wheels are stored in a directory called wheelhouse, so follow this.
pip wheel %PACKAGE_NAME% -w "%WHEELHOUSE_DIR%"
For example, to create a wheel of Fabric, do as follows.
pip wheel Fabric -w "%WHEELHOUSE_DIR%"
It will resolve the dependencies and create a wheel for you.
(Note) There is a bug in pip at the moment, so it will not be created if it is registered in PyPI. Therefore, only Fabric-1.8.1-py2.py3-none-any.whl is downloaded from PyPI.
pip wheel
only creates a wheel, so to actually install it using pip install
pip install "%WHEELHOUSE_DIR%\Fabric-1.8.1-py2.py3-none-any.whl"
To do. If you do pip freeze
in this state, the currently installed packages will be displayed.
> pip freeze
Fabric==1.8.1
ecdsa==0.10
paramiko==1.12.1
pycrypto==2.6.1
wheel==0.22.0
pip has a mechanism to install packages based on the result of pip freeze
. If you save the above result as requirements.txt, you can install the packages at once. Since the wheel has already been created and there is no need to search for PyPI, add --no-index
.
If you have a certain number of packages, this method will be convenient.
pip install -r requirements.txt -f "%WHEELHOUSE_DIR%" --no-index
If you have a wheel stored in a wheelhouse, you can build an environment even in an offline environment. At the moment, I still have to rely on easy_install for some, but it's practical enough.
Recommended Posts