summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/command')
-rw-r--r--Lib/distutils/command/bdist_wininst.py6
-rw-r--r--Lib/distutils/command/build_ext.py23
-rw-r--r--Lib/distutils/command/build_py.py3
-rw-r--r--Lib/distutils/command/build_scripts.py7
-rw-r--r--Lib/distutils/command/install.py2
-rw-r--r--Lib/distutils/command/register.py4
-rw-r--r--Lib/distutils/command/sdist.py2
-rw-r--r--Lib/distutils/command/upload.py61
-rw-r--r--Lib/distutils/command/wininst-10.0-amd64.exebin0 -> 222208 bytes
-rw-r--r--Lib/distutils/command/wininst-10.0.exebin0 -> 190976 bytes
10 files changed, 58 insertions, 50 deletions
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index e3ed3ad..959a8bf 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -265,11 +265,11 @@ class bdist_wininst(Command):
cfgdata = cfgdata + b"\0"
if self.pre_install_script:
# We need to normalize newlines, so we open in text mode and
- # convert back to bytes. "latin1" simply avoids any possible
+ # convert back to bytes. "latin-1" simply avoids any possible
# failures.
with open(self.pre_install_script, "r",
- encoding="latin1") as script:
- script_data = script.read().encode("latin1")
+ encoding="latin-1") as script:
+ script_data = script.read().encode("latin-1")
cfgdata = cfgdata + script_data + b"\n\0"
else:
# empty pre-install script
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 64f634c..bc6a23f 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -8,6 +8,7 @@ import sys, os, re
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
+from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
@@ -159,6 +160,11 @@ class build_ext(Command):
if isinstance(self.include_dirs, str):
self.include_dirs = self.include_dirs.split(os.pathsep)
+ # If in a virtualenv, add its include directory
+ # Issue 16116
+ if sys.exec_prefix != sys.base_exec_prefix:
+ self.include_dirs.append(os.path.join(sys.exec_prefix, 'include'))
+
# Put the Python "system" include dir at the end, so that
# any local include dirs take precedence.
self.include_dirs.append(py_include)
@@ -189,6 +195,8 @@ class build_ext(Command):
# must be the *native* platform. But we don't really support
# cross-compiling via a binary install anyway, so we let it go.
self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
+ if sys.base_exec_prefix != sys.prefix: # Issue 16116
+ self.library_dirs.append(os.path.join(sys.base_exec_prefix, 'libs'))
if self.debug:
self.build_temp = os.path.join(self.build_temp, "Debug")
else:
@@ -196,8 +204,11 @@ class build_ext(Command):
# Append the source distribution include and library directories,
# this allows distutils on windows to work in the source tree
- self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
- if MSVC_VERSION == 9:
+ self.include_dirs.append(os.path.dirname(get_config_h_filename()))
+ _sys_home = getattr(sys, '_home', None)
+ if _sys_home:
+ self.library_dirs.append(_sys_home)
+ if MSVC_VERSION >= 9:
# Use the .lib files for the correct architecture
if self.plat_name == 'win32':
suffix = ''
@@ -236,12 +247,10 @@ class build_ext(Command):
# building python standard extensions
self.library_dirs.append('.')
- # for extensions under Linux or Solaris with a shared Python library,
+ # For building extensions with a shared Python library,
# Python's library directory must be appended to library_dirs
- sysconfig.get_config_var('Py_ENABLE_SHARED')
- if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')
- or sys.platform.startswith('sunos'))
- and sysconfig.get_config_var('Py_ENABLE_SHARED')):
+ # See Issues: #1600860, #4366
+ if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
# building third party extensions
self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py
index 1371b3d..d48eb69 100644
--- a/Lib/distutils/command/build_py.py
+++ b/Lib/distutils/command/build_py.py
@@ -127,7 +127,8 @@ class build_py (Command):
# Each pattern has to be converted to a platform-specific path
filelist = glob(os.path.join(src_dir, convert_path(pattern)))
# Files that match more than one pattern are only added once
- files.extend([fn for fn in filelist if fn not in files])
+ files.extend([fn for fn in filelist if fn not in files
+ and os.path.isfile(fn)])
return files
def build_package_data(self):
diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py
index ec43477..4b5b22e 100644
--- a/Lib/distutils/command/build_scripts.py
+++ b/Lib/distutils/command/build_scripts.py
@@ -126,10 +126,9 @@ class build_scripts(Command):
"The shebang ({!r}) is not decodable "
"from the script encoding ({})"
.format(shebang, encoding))
- outf = open(outfile, "wb")
- outf.write(shebang)
- outf.writelines(f.readlines())
- outf.close()
+ with open(outfile, "wb") as outf:
+ outf.write(shebang)
+ outf.writelines(f.readlines())
if f:
f.close()
else:
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 9b1c36a..3c675d1 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -545,7 +545,7 @@ class install(Command):
self.extra_dirs = extra_dirs
def change_roots(self, *names):
- """Change the install direcories pointed by name using root."""
+ """Change the install directories pointed by name using root."""
for name in names:
attr = "install_" + name
setattr(self, attr, change_root(self.root, getattr(self, attr)))
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index 99545af..b49f86f 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -87,7 +87,7 @@ class register(PyPIRCCommand):
'''
url = self.repository+'?:action=list_classifiers'
response = urllib.request.urlopen(url)
- log.info(response.read())
+ log.info(self._read_pypi_response(response))
def verify_metadata(self):
''' Send the metadata to the package index server to be checked.
@@ -300,5 +300,5 @@ Your selection [default 1]: ''', log.INFO)
result = 200, 'OK'
if self.show_response:
dashes = '-' * 75
- self.announce('%s%s%s' % (dashes, data, dashes))
+ self.announce('%s%r%s' % (dashes, data, dashes))
return result
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index a9429a4..116f67e 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -175,7 +175,7 @@ class sdist(Command):
depends on the user's options.
"""
# new behavior when using a template:
- # the file list is recalculated everytime because
+ # the file list is recalculated every time because
# even if MANIFEST.in or setup.py are not changed
# the user might have added some files in the tree that
# need to be included.
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 8b36851..e30c189 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -10,10 +10,9 @@ import sys
import os, io
import socket
import platform
-import configparser
-import http.client as httpclient
from base64 import standard_b64encode
-import urllib.parse
+from urllib.request import urlopen, Request, HTTPError
+from urllib.parse import urlparse
# this keeps compatibility for 2.3 and 2.4
if sys.version < "2.5":
@@ -66,6 +65,15 @@ class upload(PyPIRCCommand):
self.upload_file(command, pyversion, filename)
def upload_file(self, command, pyversion, filename):
+ # Makes sure the repository URL is compliant
+ schema, netloc, url, params, query, fragments = \
+ urlparse(self.repository)
+ if params or query or fragments:
+ raise AssertionError("Incompatible url %s" % self.repository)
+
+ if schema not in ('http', 'https'):
+ raise AssertionError("unsupported schema " + schema)
+
# Sign if requested
if self.sign:
gpg_args = ["gpg", "--detach-sign", "-a", filename]
@@ -162,41 +170,32 @@ class upload(PyPIRCCommand):
self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
# build the Request
- # We can't use urllib since we need to send the Basic
- # auth right with the first request
- # TODO(jhylton): Can we fix urllib?
- schema, netloc, url, params, query, fragments = \
- urllib.parse.urlparse(self.repository)
- assert not params and not query and not fragments
- if schema == 'http':
- http = httpclient.HTTPConnection(netloc)
- elif schema == 'https':
- http = httpclient.HTTPSConnection(netloc)
- else:
- raise AssertionError("unsupported schema "+schema)
-
- data = ''
- loglevel = log.INFO
+ headers = {'Content-type':
+ 'multipart/form-data; boundary=%s' % boundary,
+ 'Content-length': str(len(body)),
+ 'Authorization': auth}
+
+ request = Request(self.repository, data=body,
+ headers=headers)
+ # send the data
try:
- http.connect()
- http.putrequest("POST", url)
- http.putheader('Content-type',
- 'multipart/form-data; boundary=%s'%boundary)
- http.putheader('Content-length', str(len(body)))
- http.putheader('Authorization', auth)
- http.endheaders()
- http.send(body)
+ result = urlopen(request)
+ status = result.getcode()
+ reason = result.msg
except socket.error as e:
self.announce(str(e), log.ERROR)
return
+ except HTTPError as e:
+ status = e.code
+ reason = e.msg
- r = http.getresponse()
- if r.status == 200:
- self.announce('Server response (%s): %s' % (r.status, r.reason),
+ if status == 200:
+ self.announce('Server response (%s): %s' % (status, reason),
log.INFO)
else:
- self.announce('Upload failed (%s): %s' % (r.status, r.reason),
+ self.announce('Upload failed (%s): %s' % (status, reason),
log.ERROR)
if self.show_response:
- msg = '\n'.join(('-' * 75, r.read(), '-' * 75))
+ text = self._read_pypi_response(result)
+ msg = '\n'.join(('-' * 75, text, '-' * 75))
self.announce(msg, log.INFO)
diff --git a/Lib/distutils/command/wininst-10.0-amd64.exe b/Lib/distutils/command/wininst-10.0-amd64.exe
new file mode 100644
index 0000000..6fa0dce
--- /dev/null
+++ b/Lib/distutils/command/wininst-10.0-amd64.exe
Binary files differ
diff --git a/Lib/distutils/command/wininst-10.0.exe b/Lib/distutils/command/wininst-10.0.exe
new file mode 100644
index 0000000..afc3bc6
--- /dev/null
+++ b/Lib/distutils/command/wininst-10.0.exe
Binary files differ