Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
42211426
Commit
42211426
authored
May 26, 2012
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressed some buildbot errors and comments on the checkin by Antoine on python-dev.
parent
072b1e14
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
58 deletions
+51
-58
Lib/distutils/sysconfig.py
Lib/distutils/sysconfig.py
+2
-1
Lib/sysconfig.py
Lib/sysconfig.py
+2
-1
Lib/test/test_venv.py
Lib/test/test_venv.py
+5
-22
Lib/venv/__init__.py
Lib/venv/__init__.py
+42
-34
No files found.
Lib/distutils/sysconfig.py
View file @
42211426
...
@@ -47,7 +47,8 @@ def _is_python_source_dir(d):
...
@@ -47,7 +47,8 @@ def _is_python_source_dir(d):
return
True
return
True
return
False
return
False
_sys_home
=
getattr
(
sys
,
'_home'
,
None
)
_sys_home
=
getattr
(
sys
,
'_home'
,
None
)
if
_sys_home
and
os
.
name
==
'nt'
and
_sys_home
.
lower
().
endswith
(
'pcbuild'
):
if
_sys_home
and
os
.
name
==
'nt'
and
\
_sys_home
.
lower
().
endswith
((
'pcbuild'
,
'pcbuild
\
\
amd64'
)):
_sys_home
=
os
.
path
.
dirname
(
_sys_home
)
_sys_home
=
os
.
path
.
dirname
(
_sys_home
)
def
_python_build
():
def
_python_build
():
if
_sys_home
:
if
_sys_home
:
...
...
Lib/sysconfig.py
View file @
42211426
...
@@ -104,7 +104,8 @@ def _is_python_source_dir(d):
...
@@ -104,7 +104,8 @@ def _is_python_source_dir(d):
return
False
return
False
_sys_home
=
getattr
(
sys
,
'_home'
,
None
)
_sys_home
=
getattr
(
sys
,
'_home'
,
None
)
if
_sys_home
and
os
.
name
==
'nt'
and
_sys_home
.
lower
().
endswith
(
'pcbuild'
):
if
_sys_home
and
os
.
name
==
'nt'
and
\
_sys_home
.
lower
().
endswith
((
'pcbuild'
,
'pcbuild
\
\
amd64'
)):
_sys_home
=
os
.
path
.
dirname
(
_sys_home
)
_sys_home
=
os
.
path
.
dirname
(
_sys_home
)
def
is_python_build
(
check_home
=
False
):
def
is_python_build
(
check_home
=
False
):
...
...
Lib/test/test_venv.py
View file @
42211426
#!/usr/bin/env python
"""
#
Test harness for the venv module.
# Copyright 2011 by Vinay Sajip. All Rights Reserved.
#
Copyright (C) 2011-2012 Vinay Sajip.
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""Test harness for the venv module. Run all tests.
Copyright (C) 2011 Vinay Sajip. All Rights Reserved.
"""
"""
import
os
import
os
...
@@ -93,7 +76,7 @@ class BasicTest(BaseTest):
...
@@ -93,7 +76,7 @@ class BasicTest(BaseTest):
data
=
self
.
get_text_file_contents
(
self
.
bindir
,
self
.
ps3name
)
data
=
self
.
get_text_file_contents
(
self
.
bindir
,
self
.
ps3name
)
self
.
assertTrue
(
data
.
startswith
(
'#!%s%s'
%
(
self
.
env_dir
,
os
.
sep
)))
self
.
assertTrue
(
data
.
startswith
(
'#!%s%s'
%
(
self
.
env_dir
,
os
.
sep
)))
fn
=
self
.
get_env_file
(
self
.
bindir
,
self
.
exe
)
fn
=
self
.
get_env_file
(
self
.
bindir
,
self
.
exe
)
self
.
assertTrue
(
os
.
path
.
exists
(
fn
))
self
.
assertTrue
(
os
.
path
.
exists
(
fn
)
,
'File %r exists'
%
fn
)
def
test_overwrite_existing
(
self
):
def
test_overwrite_existing
(
self
):
"""
"""
...
...
Lib/venv/__init__.py
View file @
42211426
# Copyright (C) 2011-2012 Vinay Sajip.
"""
#
Virtual environment (venv) package for Python. Based on PEP 405.
# Use with a Python executable built from the Python fork at
#
Copyright (C) 20011-2012 Vinay Sajip. All Rights Reserved.
# https://bitbucket.org/vinay.sajip/pythonv/ as follows:
#
usage: python -m venv [-h] [--no-distribute] [--system-site-packages]
# python -m venv env_dir
[--symlinks] [--clear] [--upgrade]
#
ENV_DIR [ENV_DIR ...]
# You'll need an Internet connection (needed to download distribute_setup.py).
#
Creates virtual Python environments in one or more target directories.
# The script will change to the environment's binary directory and run
#
positional arguments:
# ./python distribute_setup.py
ENV_DIR A directory to create the environment in.
#
# after which you can change to the environment's directory and do some
optional arguments:
# installations, e.g.
-h, --help show this help message and exit
#
--no-distribute Don't install Distribute in the virtual environment.*
# source bin/activate.sh
--system-site-packages
# pysetup3 install setuptools-git
Give the virtual environment access to the system
# pysetup3 install Pygments
site-packages dir.
# pysetup3 install Jinja2
--symlinks Attempt to symlink rather than copy.
# pysetup3 install SQLAlchemy
--clear Delete the environment directory if it already exists.
# pysetup3 install coverage
If not specified and the directory exists, an error is
#
raised.
# Note that on Windows, distributions which include C extensions (e.g. coverage)
--upgrade Upgrade the environment directory to use this version
# may fail due to lack of a suitable C compiler.
of Python, assuming Python has been upgraded in-place.
#
*Note: Distribute support will be available during the alpha phase to
facilitate testing third-party packages with venvs created using this package.
This support will be removed after the alpha phase.
"""
import
base64
import
base64
import
io
import
io
import
logging
import
logging
...
@@ -32,13 +36,17 @@ import os
...
@@ -32,13 +36,17 @@ import os
import
os.path
import
os.path
import
shutil
import
shutil
import
sys
import
sys
try
:
import
threading
except
ImportError
:
threading
=
None
import
zipfile
import
zipfile
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
Context
:
class
Context
:
"""
"""
Holds information about a current v
irtualisation
request.
Holds information about a current v
env creation/upgrade
request.
"""
"""
pass
pass
...
@@ -353,6 +361,7 @@ class DistributeEnvBuilder(EnvBuilder):
...
@@ -353,6 +361,7 @@ class DistributeEnvBuilder(EnvBuilder):
being processed.
being processed.
"""
"""
if
not
self
.
nodist
:
if
not
self
.
nodist
:
if
threading
:
self
.
install_distribute
(
context
)
self
.
install_distribute
(
context
)
def
reader
(
self
,
stream
,
context
):
def
reader
(
self
,
stream
,
context
):
...
@@ -381,7 +390,6 @@ class DistributeEnvBuilder(EnvBuilder):
...
@@ -381,7 +390,6 @@ class DistributeEnvBuilder(EnvBuilder):
being processed.
being processed.
"""
"""
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
from
threading
import
Thread
from
urllib.request
import
urlretrieve
from
urllib.request
import
urlretrieve
url
=
'http://python-distribute.org/distribute_setup.py'
url
=
'http://python-distribute.org/distribute_setup.py'
...
@@ -398,9 +406,9 @@ class DistributeEnvBuilder(EnvBuilder):
...
@@ -398,9 +406,9 @@ class DistributeEnvBuilder(EnvBuilder):
# Install Distribute in the env
# Install Distribute in the env
args
=
[
context
.
env_exe
,
'distribute_setup.py'
]
args
=
[
context
.
env_exe
,
'distribute_setup.py'
]
p
=
Popen
(
args
,
stdout
=
PIPE
,
stderr
=
PIPE
,
cwd
=
binpath
)
p
=
Popen
(
args
,
stdout
=
PIPE
,
stderr
=
PIPE
,
cwd
=
binpath
)
t1
=
Thread
(
target
=
self
.
reader
,
args
=
(
p
.
stdout
,
'stdout'
))
t1
=
threading
.
Thread
(
target
=
self
.
reader
,
args
=
(
p
.
stdout
,
'stdout'
))
t1
.
start
()
t1
.
start
()
t2
=
Thread
(
target
=
self
.
reader
,
args
=
(
p
.
stderr
,
'stderr'
))
t2
=
threading
.
Thread
(
target
=
self
.
reader
,
args
=
(
p
.
stderr
,
'stderr'
))
t2
.
start
()
t2
.
start
()
p
.
wait
()
p
.
wait
()
t1
.
join
()
t1
.
join
()
...
@@ -478,8 +486,8 @@ def main(args=None):
...
@@ -478,8 +486,8 @@ def main(args=None):
parser
.
add_argument
(
'--upgrade'
,
default
=
False
,
action
=
'store_true'
,
parser
.
add_argument
(
'--upgrade'
,
default
=
False
,
action
=
'store_true'
,
dest
=
'upgrade'
,
help
=
'Upgrade the environment '
dest
=
'upgrade'
,
help
=
'Upgrade the environment '
'directory to use this version '
'directory to use this version '
'of Python, assuming
it has bee
n '
'of Python, assuming
Pytho
n '
'upgraded in-place.'
)
'
has been
upgraded in-place.'
)
options
=
parser
.
parse_args
(
args
)
options
=
parser
.
parse_args
(
args
)
if
options
.
upgrade
and
options
.
clear
:
if
options
.
upgrade
and
options
.
clear
:
raise
ValueError
(
'you cannot supply --upgrade and --clear together.'
)
raise
ValueError
(
'you cannot supply --upgrade and --clear together.'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment