mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
Import changes from ruby-build v20151028
This commit is contained in:
parent
e7b0d99601
commit
f62ee1a4db
4 changed files with 185 additions and 132 deletions
20
plugins/python-build/LICENSE
Normal file
20
plugins/python-build/LICENSE
Normal file
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2013 Yamashita, Yuu
|
||||
Copyright (c) 2012-2013 Sam Stephenson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,11 +1,14 @@
|
|||
# python-build
|
||||
|
||||
python-build is a [pyenv](https://github.com/yyuu/pyenv) plugin
|
||||
that provides a `pyenv install` command to compile and install
|
||||
different versions of Python on UNIX-like systems.
|
||||
python-build is a [pyenv](https://github.com/yyuu/pyenv) plugin that
|
||||
provides a `pyenv install` command to compile and install different versions
|
||||
of Python on UNIX-like systems.
|
||||
|
||||
You can also use python-build without pyenv in environments where you
|
||||
need precise control over Python version installation.
|
||||
You can also use python-build without pyenv in environments where you need
|
||||
precise control over Python version installation.
|
||||
|
||||
See the [list of releases](https://github.com/yyuu/pyenv/releases)
|
||||
for changes in each version.
|
||||
|
||||
|
||||
## Installation
|
||||
|
@ -17,95 +20,134 @@ default.
|
|||
|
||||
### Installing as a standalone program (advanced)
|
||||
|
||||
Installing python-build as a standalone program will give you access to
|
||||
the `python-build` command for precise control over Python version
|
||||
installation. If you have pyenv installed, you will also be able to
|
||||
use the `pyenv install` command.
|
||||
Installing python-build as a standalone program will give you access to the
|
||||
`python-build` command for precise control over Python version installation. If you
|
||||
have pyenv installed, you will also be able to use the `pyenv install` command.
|
||||
|
||||
git clone git://github.com/yyuu/pyenv.git
|
||||
cd pyenv/plugins/python-build
|
||||
./install.sh
|
||||
|
||||
This will install python-build into `/usr/local`. If you do not have
|
||||
write permission to `/usr/local`, you will need to run `sudo
|
||||
./install.sh` instead. You can install to a different prefix by
|
||||
setting the `PREFIX` environment variable.
|
||||
This will install python-build into `/usr/local`. If you do not have write
|
||||
permission to `/usr/local`, you will need to run `sudo ./install.sh` instead.
|
||||
You can install to a different prefix by setting the `PREFIX` environment
|
||||
variable.
|
||||
|
||||
To update python-build after it has been installed, run `git pull` in
|
||||
your cloned copy of the repository, then re-run the install script.
|
||||
To update python-build after it has been installed, run `git pull` in your cloned
|
||||
copy of the repository, then re-run the install script.
|
||||
|
||||
### Installing with Homebrew (for OS X users)
|
||||
|
||||
Mac OS X users can install python-build with the [Homebrew](http://brew.sh)
|
||||
package manager. This will give you access to the `python-build` command. If you
|
||||
have pyenv installed, you will also be able to use the `pyenv install` command.
|
||||
|
||||
*This is the recommended method of installation if you installed pyenv with
|
||||
Homebrew.*
|
||||
|
||||
brew install pyenv
|
||||
|
||||
Or, if you would like to install the latest development release:
|
||||
|
||||
brew install --HEAD pyenv
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Before you begin, you should ensure that your build environment has the proper
|
||||
system dependencies for compiling the wanted Python Version (see our [recommendations](https://github.com/yyuu/pyenv/wiki#suggested-build-environment)).
|
||||
|
||||
### Using `pyenv install` with pyenv
|
||||
|
||||
To install a Python version for use with pyenv, run `pyenv install` with
|
||||
the exact name of the version you want to install. For example,
|
||||
exact name of the version you want to install. For example,
|
||||
|
||||
pyenv install 2.7.4
|
||||
|
||||
Python versions will be installed into a directory of the same name
|
||||
under `~/.pyenv/versions`.
|
||||
Python versions will be installed into a directory of the same name under
|
||||
`~/.pyenv/versions`.
|
||||
|
||||
To see a list of all available Python versions, run `pyenv install --list`.
|
||||
You may also tab-complete available Python
|
||||
versions if your pyenv installation is properly configured.
|
||||
To see a list of all available Python versions, run `pyenv install --list`. You
|
||||
may also tab-complete available Python versions if your pyenv installation is
|
||||
properly configured.
|
||||
|
||||
### Using `python-build` standalone
|
||||
|
||||
If you have installed python-build as a standalone program, you can use
|
||||
the `python-build` command to compile and install Python versions into
|
||||
specific locations.
|
||||
If you have installed python-build as a standalone program, you can use the
|
||||
`python-build` command to compile and install Python versions into specific
|
||||
locations.
|
||||
|
||||
Run the `python-build` command with the exact name of the version you
|
||||
want to install and the full path where you want to install it. For
|
||||
example,
|
||||
Run the `python-build` command with the exact name of the version you want to
|
||||
install and the full path where you want to install it. For example,
|
||||
|
||||
python-build 2.7.4 ~/local/python-2.7.4
|
||||
|
||||
To see a list of all available Python versions, run `python-build
|
||||
--definitions`.
|
||||
To see a list of all available Python versions, run `python-build --definitions`.
|
||||
|
||||
Pass the `-v` or `--verbose` flag to `python-build` as the first
|
||||
argument to see what's happening under the hood.
|
||||
Pass the `-v` or `--verbose` flag to `python-build` as the first argument to see
|
||||
what's happening under the hood.
|
||||
|
||||
### Custom definitions
|
||||
|
||||
Both `pyenv install` and `python-build` accept a path to a custom
|
||||
definition file in place of a version name. Custom definitions let you
|
||||
develop and install versions of Python that are not yet supported by
|
||||
python-build.
|
||||
Both `pyenv install` and `python-build` accept a path to a custom definition file
|
||||
in place of a version name. Custom definitions let you develop and install
|
||||
versions of Python that are not yet supported by python-build.
|
||||
|
||||
See the [python-build built-in
|
||||
definitions](https://github.com/yyuu/pyenv/tree/master/plugins/python-build/share/python-build)
|
||||
as a starting point for custom definition files.
|
||||
See the [python-build built-in definitions](https://github.com/yyuu/pyenv/tree/master/plugins/python-build/share/python-build) as a starting point for
|
||||
custom definition files.
|
||||
|
||||
[definitions]: https://github.com/yyuu/pyenv/tree/master/plugins/python-build/share/python-build
|
||||
|
||||
### Special environment variables
|
||||
|
||||
You can set certain environment variables to control the build
|
||||
process.
|
||||
You can set certain environment variables to control the build process.
|
||||
|
||||
* `TMPDIR` sets the location where python-build stores temporary files.
|
||||
* `PYTHON_BUILD_BUILD_PATH` sets the location in which sources are
|
||||
downloaded and built. By default, this is a subdirectory of
|
||||
`TMPDIR`.
|
||||
* `PYTHON_BUILD_CACHE_PATH`, if set, specifies a directory to use for
|
||||
caching downloaded package files.
|
||||
* `PYTHON_BUILD_MIRROR_URL` overrides the default mirror URL root to one
|
||||
of your choosing.
|
||||
* `PYTHON_BUILD_SKIP_MIRROR`, if set, forces python-build to download
|
||||
packages from their original source URLs instead of using a mirror.
|
||||
* `PYTHON_BUILD_BUILD_PATH` sets the location in which sources are downloaded and
|
||||
built. By default, this is a subdirectory of `TMPDIR`.
|
||||
* `PYTHON_BUILD_CACHE_PATH`, if set, specifies a directory to use for caching
|
||||
downloaded package files.
|
||||
* `PYTHON_BUILD_MIRROR_URL` overrides the default mirror URL root to one of your
|
||||
choosing.
|
||||
* `PYTHON_BUILD_SKIP_MIRROR`, if set, forces python-build to download packages from
|
||||
their original source URLs instead of using a mirror.
|
||||
* `PYTHON_BUILD_ROOT` overrides the default location from where build definitions
|
||||
in `share/python-build/` are looked up.
|
||||
* `PYTHON_BUILD_DEFINITIONS` can be a list of colon-separated paths that get
|
||||
additionally searched when looking up build definitions.
|
||||
* `CC` sets the path to the C compiler.
|
||||
* `PYTHON_CFLAGS` lets you pass additional options to the default `CFLAGS`. Use
|
||||
this to override, for instance, the `-O3` option.
|
||||
* `CONFIGURE_OPTS` lets you pass additional options to `./configure`.
|
||||
* `MAKE` lets you override the command to use for `make`. Useful for
|
||||
specifying GNU make (`gmake`) on some systems.
|
||||
* `MAKE_OPTS` (or `MAKEOPTS`) lets you pass additional options to
|
||||
`make`.
|
||||
* `PYTHON_CONFIGURE_OPTS` and `PYTHON_MAKE_OPTS` allow you to specify
|
||||
configure and make options for buildling CPython. These variables will
|
||||
be passed to Python only, not any dependent packages (e.g. libyaml).
|
||||
* `MAKE` lets you override the command to use for `make`. Useful for specifying
|
||||
GNU make (`gmake`) on some systems.
|
||||
* `MAKE_OPTS` (or `MAKEOPTS`) lets you pass additional options to `make`.
|
||||
* `MAKE_INSTALL_OPTS` lets you pass additional options to `make install`.
|
||||
* `PYTHON_CONFIGURE_OPTS` and `PYTHON_MAKE_OPTS` and `PYTHON_MAKE_INSTALL_OPTS` allow
|
||||
you to specify configure and make options for buildling CPython. These variables
|
||||
will be passed to Python only, not any dependent packages (e.g. libyaml).
|
||||
|
||||
### Building as `--enable-shared`
|
||||
### Applying patches to Python before compiling
|
||||
|
||||
Both `pyenv install` and `python-build` support the `--patch` (`-p`) flag that
|
||||
signals that a patch from stdin should be applied to Python, Jython or PyPy
|
||||
source code before the `./configure` and compilation steps.
|
||||
|
||||
Example usage:
|
||||
|
||||
```sh
|
||||
# applying a single patch
|
||||
$ pyenv install --patch 2.7.10 < /path/to/python.patch
|
||||
|
||||
# applying a patch from HTTP
|
||||
$ pyenv install --patch 2.7.10 < <(curl -sSL http://git.io/python.patch)
|
||||
|
||||
# applying multiple patches
|
||||
$ cat fix1.patch fix2.patch | pyenv install --patch 2.7.10
|
||||
```
|
||||
|
||||
|
||||
### Building with `--enable-shared`
|
||||
|
||||
You can build CPython with `--enable-shared` to install a version with
|
||||
shared object.
|
||||
|
@ -121,93 +163,60 @@ $ env PYTHON_CONFIGURE_OPTS="--enable-shared` pyenv install 2.7.9
|
|||
|
||||
### Checksum verification
|
||||
|
||||
If you have the `shasum`, `openssl`, or `sha256sum` tool installed,
|
||||
python-build will automatically verify the SHA2 checksum of each
|
||||
downloaded package before installing it.
|
||||
If you have the `shasum`, `openssl`, or `sha256sum` tool installed, python-build will
|
||||
automatically verify the SHA2 checksum of each downloaded package before
|
||||
installing it.
|
||||
|
||||
Checksums are optional and specified as anchors on the package URL in
|
||||
each definition. (All bundled definitions include checksums.)
|
||||
Checksums are optional and specified as anchors on the package URL in each
|
||||
definition. (All bundled definitions include checksums.)
|
||||
|
||||
### Package download mirrors
|
||||
|
||||
python-build will first attempt to download package files from a mirror
|
||||
hosted on Amazon CloudFront. If a package is not available on the
|
||||
mirror, if the mirror is down, or if the download is corrupt,
|
||||
python-build will fall back to the official URL specified in the
|
||||
defintion file.
|
||||
python-build will first attempt to download package files from a mirror hosted on
|
||||
GitHub Pages. If a package is not available on the mirror, if the mirror
|
||||
is down, or if the download is corrupt, python-build will fall back to the
|
||||
official URL specified in the defintion file.
|
||||
|
||||
You can point python-build to another mirror by specifying the
|
||||
`PYTHON_BUILD_MIRROR_URL` environment variable--useful if you'd like to
|
||||
run your own local mirror, for example. Package mirror URLs are
|
||||
constructed by joining this variable with the SHA2 checksum of the
|
||||
package file.
|
||||
`PYTHON_BUILD_MIRROR_URL` environment variable--useful if you'd like to run your
|
||||
own local mirror, for example. Package mirror URLs are constructed by joining
|
||||
this variable with the SHA2 checksum of the package file.
|
||||
|
||||
If you don't have an SHA2 program installed, python-build will skip the
|
||||
download mirror and use official URLs instead. You can force
|
||||
python-build to bypass the mirror by setting the
|
||||
`PYTHON_BUILD_SKIP_MIRROR` environment variable.
|
||||
If you don't have an SHA2 program installed, python-build will skip the download
|
||||
mirror and use official URLs instead. You can force python-build to bypass the
|
||||
mirror by setting the `PYTHON_BUILD_SKIP_MIRROR` environment variable.
|
||||
|
||||
The official python-build download mirror is provided by [Git Hub Pages](http://yyuu.github.io/pythons/).
|
||||
The official python-build download mirror is provided by
|
||||
[GitHub Pages](http://yyuu.github.io/pythons/).
|
||||
|
||||
### Package download caching
|
||||
|
||||
You can instruct python-build to keep a local cache of downloaded
|
||||
package files by setting the `PYTHON_BUILD_CACHE_PATH` environment
|
||||
variable. When set, package files will be kept in this directory after
|
||||
the first successful download and reused by subsequent invocations of
|
||||
`python-build` and `pyenv install`.
|
||||
You can instruct python-build to keep a local cache of downloaded package files
|
||||
by setting the `PYTHON_BUILD_CACHE_PATH` environment variable. When set, package
|
||||
files will be kept in this directory after the first successful download and
|
||||
reused by subsequent invocations of `python-build` and `pyenv install`.
|
||||
|
||||
The `pyenv install` command defaults this path to `~/.pyenv/cache`, so
|
||||
in most cases you can enable download caching simply by creating that
|
||||
directory.
|
||||
The `pyenv install` command defaults this path to `~/.pyenv/cache`, so in most
|
||||
cases you can enable download caching simply by creating that directory.
|
||||
|
||||
### Keeping the build directory after installation
|
||||
|
||||
Both `python-build` and `pyenv install` accept the `-k` or `--keep`
|
||||
flag, which tells python-build to keep the downloaded source after
|
||||
installation. This can be useful if you need to use `gdb` and
|
||||
`memprof` with Python.
|
||||
Both `python-build` and `pyenv install` accept the `-k` or `--keep` flag, which
|
||||
tells python-build to keep the downloaded source after installation. This can be
|
||||
useful if you need to use `gdb` and `memprof` with Python.
|
||||
|
||||
Source code will be kept in a parallel directory tree
|
||||
`~/.pyenv/sources` when using `--keep` with the `pyenv install`
|
||||
command. You should specify the location of the source code with the
|
||||
`PYTHON_BUILD_BUILD_PATH` environment variable when using `--keep` with
|
||||
`python-build`.
|
||||
Source code will be kept in a parallel directory tree `~/.pyenv/sources` when
|
||||
using `--keep` with the `pyenv install` command. You should specify the
|
||||
location of the source code with the `PYTHON_BUILD_BUILD_PATH` environment
|
||||
variable when using `--keep` with `python-build`.
|
||||
|
||||
|
||||
## Getting Help
|
||||
|
||||
Please see the [python-build
|
||||
wiki](https://github.com/yyuu/pyenv/wiki) for solutions to
|
||||
common problems.
|
||||
Please see the [pyenv wiki](https://github.com/yyuu/pyenv/wiki) for solutions to common problems.
|
||||
|
||||
[wiki]: https://github.com/yyuu/pyenv/wiki
|
||||
|
||||
If you can't find an answer on the wiki, open an issue on the [issue
|
||||
tracker](https://github.com/yyuu/pyenv/issues). Be sure to
|
||||
include the full build log for build failures.
|
||||
|
||||
|
||||
### License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
* Copyright (c) 2013 Yamashita, Yuu
|
||||
* Copyright (c) 2012 Sam Stephenson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
tracker](https://github.com/yyuu/pyenv/issues). Be sure to include
|
||||
the full build log for build failures.
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
# -g/--debug Build a debug version
|
||||
#
|
||||
|
||||
PYTHON_BUILD_VERSION="20150818"
|
||||
PYTHON_BUILD_VERSION="20151028"
|
||||
|
||||
OLDIFS="$IFS"
|
||||
|
||||
set -E
|
||||
exec 3<&2 # preserve original stderr at fd 3
|
||||
|
@ -103,6 +105,7 @@ os_information() {
|
|||
osx_version() {
|
||||
local -a ver
|
||||
IFS=. ver=( `sw_vers -productVersion` )
|
||||
IFS="$OLDIFS"
|
||||
echo $(( ${ver[0]}*100 + ${ver[1]} ))
|
||||
}
|
||||
|
||||
|
@ -518,6 +521,8 @@ fetch_svn() {
|
|||
|
||||
if type svn &>/dev/null; then
|
||||
svn co -r "$svn_rev" "$svn_url" "${package_name}" >&4 2>&1
|
||||
elif type svnlite &>/dev/null; then
|
||||
svnlite co -r "$svn_rev" "$svn_url" "${package_name}" >&4 2>&1
|
||||
else
|
||||
echo "error: please install Subversion and try again" >&2
|
||||
exit 1
|
||||
|
@ -682,7 +687,7 @@ build_package_standard() {
|
|||
export CC=clang
|
||||
fi
|
||||
${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" \
|
||||
$CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}"
|
||||
$CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}" || return 1
|
||||
) >&4 2>&1
|
||||
|
||||
{ "$MAKE" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} "${!PACKAGE_MAKE_OPTS_ARRAY}"
|
||||
|
@ -1101,6 +1106,7 @@ require_gcc() {
|
|||
locate_gcc() {
|
||||
local gcc gccs
|
||||
IFS=: gccs=($(gccs_in_path))
|
||||
IFS="$OLDIFS"
|
||||
|
||||
verify_gcc "$CC" ||
|
||||
verify_gcc "$(command -v gcc || true)" || {
|
||||
|
@ -1116,6 +1122,7 @@ gccs_in_path() {
|
|||
local gcc path paths
|
||||
local gccs=()
|
||||
IFS=: paths=($PATH)
|
||||
IFS="$OLDIFS"
|
||||
|
||||
shopt -s nullglob
|
||||
for path in "${paths[@]}"; do
|
||||
|
@ -1334,11 +1341,16 @@ build_package_verify_openssl() {
|
|||
|
||||
# Ensure that directories listed in LDFLAGS exist
|
||||
build_package_ldflags_dirs() {
|
||||
local arg
|
||||
for arg in $LDFLAGS; do
|
||||
case "$arg" in
|
||||
-L* ) mkdir -p "${arg#-L}" ;;
|
||||
local arg dir
|
||||
set - $LDFLAGS
|
||||
while [ $# -gt 0 ]; do
|
||||
dir=""
|
||||
case "$1" in
|
||||
-L ) dir="$2" ;;
|
||||
-L* ) dir="${1#-L}" ;;
|
||||
esac
|
||||
[ -z "$dir" ] || mkdir -p "$dir"
|
||||
shift 1
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -1646,7 +1658,6 @@ unset IPV6
|
|||
|
||||
PYTHON_BUILD_INSTALL_PREFIX="$(abs_dirname "$0")/.."
|
||||
|
||||
OLDIFS="$IFS"
|
||||
IFS=: PYTHON_BUILD_DEFINITIONS=($PYTHON_BUILD_DEFINITIONS ${PYTHON_BUILD_ROOT:-$PYTHON_BUILD_INSTALL_PREFIX}/share/python-build)
|
||||
IFS="$OLDIFS"
|
||||
|
||||
|
|
|
@ -489,3 +489,16 @@ OUT
|
|||
run python-build "${TMP}/build-definition" "$INSTALL_ROOT"
|
||||
assert_failure "python-build: TMPDIR=$TMPDIR is set to a non-accessible location"
|
||||
}
|
||||
|
||||
@test "initializes LDFLAGS directories" {
|
||||
cached_tarball "Python-3.2.1"
|
||||
|
||||
export LDFLAGS="-L ${BATS_TEST_DIRNAME}/what/evs"
|
||||
run_inline_definition <<DEF
|
||||
install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz" ldflags_dirs
|
||||
DEF
|
||||
assert_success
|
||||
|
||||
assert [ -d "${INSTALL_ROOT}/lib" ]
|
||||
assert [ -d "${BATS_TEST_DIRNAME}/what/evs" ]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue