Skip to content

Commit ee20596

Browse files
Merge branch 'master' into gitarchive-exportignore
2 parents e182fad + fc824aa commit ee20596

File tree

12 files changed

+255
-138
lines changed

12 files changed

+255
-138
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
language: python
22
sudo: false
33
python:
4-
- '2.6'
54
- '2.7'
6-
- '3.3'
75
- '3.4'
86
- '3.5'
97
- '3.6'
8+
#- '3.7'
109
env:
1110
- TOXENV=py-test
1211

1312
matrix:
1413
include:
15-
- python: '2.7'
16-
env: TOXENV=flake8
1714
- python: '3.5'
1815
env: TOXENV=flake8
16+
- python: '3.5'
17+
env: TOXENV=check_readme
1918
- python: '2.7'
2019
env: SELFINSTALL=1
2120
- python: '3.5'

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
v1.15.7
22
======
33

4-
* fix #174 by normalizing windows path using windows apis
4+
* Fix #174 with #207: Re-use samefile backport as developed in
5+
jaraco.windows, and only use the backport where samefile is
6+
not available.
57

68
v1.15.6
79
=======

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ To use setuptools_scm just modify your project's setup.py file like this:
6161
Programmatic usage
6262
------------------
6363

64-
In order to use ``setuptools_scm`` from code that one directory deeper
64+
In order to use ``setuptools_scm`` from code that is one directory deeper
6565
than the project's root, you can use:
6666

6767
.. code:: python

appveyor.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ environment:
66
- PYTHON: "C:\\Python27-x64"
77
TOX_ENV: "py-test"
88

9-
- PYTHON: "C:\\Python33"
10-
TOX_ENV: "py-test"
11-
12-
- PYTHON: "C:\\Python33-x64"
13-
TOX_ENV: "py-test"
14-
159
- PYTHON: "C:\\Python34"
1610
TOX_ENV: "py-test"
1711

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,18 @@ def parse(root):
9090
9191
[setuptools_scm.local_scheme]
9292
node-and-date = setuptools_scm.version:get_local_node_and_date
93+
node-and-timestamp = \
94+
setuptools_scm.version:get_local_node_and_timestamp
9395
dirty-tag = setuptools_scm.version:get_local_dirty_tag
9496
""",
9597
classifiers=[
9698
'Development Status :: 4 - Beta',
9799
'Intended Audience :: Developers',
98100
'License :: OSI Approved :: MIT License',
99101
'Programming Language :: Python',
102+
'Programming Language :: Python :: 2',
100103
'Programming Language :: Python :: 3',
101-
'Programming Language :: Python :: 2.6',
102104
'Programming Language :: Python :: 2.7',
103-
'Programming Language :: Python :: 3.3',
104105
'Programming Language :: Python :: 3.4',
105106
'Programming Language :: Python :: 3.5',
106107
'Programming Language :: Python :: 3.6',
@@ -109,6 +110,7 @@ def parse(root):
109110
'Topic :: System :: Software Distribution',
110111
'Topic :: Utilities',
111112
],
113+
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
112114
)
113115

114116
if __name__ == '__main__':

setuptools_scm/git.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .utils import do_ex, trace, has_command, _normalized
1+
from .utils import do_ex, trace, has_command
22
from .version import meta
33

44
from os.path import isfile, join
@@ -7,6 +7,13 @@
77
import tarfile
88
import warnings
99

10+
11+
try:
12+
from os.path import samefile
13+
except ImportError:
14+
from .win_py31_compat import samefile
15+
16+
1017
FILES_COMMAND = sys.executable + ' -m setuptools_scm.git'
1118
DEFAULT_DESCRIBE = 'git describe --dirty --tags --long --match *.*'
1219

@@ -25,7 +32,7 @@ def from_potential_worktree(cls, wd):
2532
if ret:
2633
return
2734
trace('real root', real_wd)
28-
if _normalized(real_wd) != _normalized(wd):
35+
if not samefile(real_wd, wd):
2936
return
3037

3138
return cls(real_wd)

setuptools_scm/hg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
2525
def parse(root):
2626
if not has_command('hg'):
2727
return
28-
l = do('hg id -i -t', root).split()
29-
if not l:
28+
identity_data = do('hg id -i -t', root).split()
29+
if not identity_data:
3030
return
31-
node = l.pop(0)
32-
tags = tags_to_versions(l)
31+
node = identity_data.pop(0)
32+
tags = tags_to_versions(identity_data)
3333
# filter tip in degraded mode on old setuptools
3434
tags = [x for x in tags if x != 'tip']
3535
dirty = node[-1] == '+'

setuptools_scm/utils.py

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import shlex
88
import subprocess
99
import os
10-
from os.path import abspath, normcase, realpath
1110
import io
1211
import platform
1312

@@ -27,7 +26,7 @@ def ensure_stripped_str(str_or_bytes):
2726
if isinstance(str_or_bytes, str):
2827
return str_or_bytes.strip()
2928
else:
30-
return str_or_bytes.decode('utf-8', 'surogate_escape').strip()
29+
return str_or_bytes.decode('utf-8', 'surrogateescape').strip()
3130

3231

3332
def _always_strings(env_dict):
@@ -108,59 +107,3 @@ def has_command(name):
108107
if not res:
109108
warnings.warn("%r was not found" % name)
110109
return res
111-
112-
113-
def _normalized(path):
114-
if IS_WINDOWS:
115-
path = get_windows_long_path_name(path)
116-
return normcase(abspath(realpath(path)))
117-
118-
119-
if IS_WINDOWS:
120-
from ctypes import create_unicode_buffer, windll, WinError
121-
from ctypes.wintypes import MAX_PATH, LPCWSTR, LPWSTR, DWORD
122-
123-
GetLongPathNameW = windll.kernel32.GetLongPathNameW
124-
GetLongPathNameW.argtypes = [LPCWSTR, LPWSTR, DWORD]
125-
GetLongPathNameW.restype = DWORD
126-
127-
def get_windows_long_path_name(path):
128-
"""
129-
Converts the specified path from short (MS-DOS style) to long form
130-
using the 'GetLongPathNameW' function from Windows API.
131-
132-
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364980(v=vs.85).aspx
133-
"""
134-
if PY2:
135-
# decode path using filesystem encoding on python2; on python3
136-
# it is already a unicode string
137-
path = unicode(path, sys.getfilesystemencoding()) # noqa
138-
139-
pathlen = MAX_PATH + 1
140-
if DEBUG:
141-
# test reallocation logic
142-
pathlen = 1
143-
144-
for _ in range(2):
145-
buf = create_unicode_buffer(pathlen)
146-
retval = GetLongPathNameW(path, buf, pathlen)
147-
148-
if retval == 0:
149-
# if the function fails for any reason (e.g. file does not
150-
# exist), the return value is zero
151-
raise WinError()
152-
153-
if retval <= pathlen:
154-
# the function succeeded: the return value is the length of
155-
# the string copied to the buffer
156-
if PY2:
157-
# re-encode to native 'str' type (i.e. bytes) on python2
158-
return buf.value.encode(sys.getfilesystemencoding())
159-
return buf.value
160-
161-
# if the buffer is too small to contain the result, the return
162-
# value is the size of the buffer required to hold the path and
163-
# the terminating NULL char; we retry using a large enough buffer
164-
pathlen = retval
165-
166-
raise RuntimeError("Failed to get long path name: {!r}".format(path))

setuptools_scm/version.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ def get_local_node_and_date(version):
144144
return version.format_choice("+{node}", "+{node}.d{time:%Y%m%d}")
145145

146146

147+
def get_local_node_and_timestamp(version, fmt='%Y%m%d%H%M%S'):
148+
if version.exact or version.node is None:
149+
return version.format_choice("",
150+
"+d{time:"
151+
+ "{fmt}".format(fmt=fmt)
152+
+ "}")
153+
else:
154+
return version.format_choice("+{node}",
155+
"+{node}"
156+
+ ".d{time:"
157+
+ "{fmt}".format(fmt=fmt)
158+
+ "}")
159+
160+
147161
def get_local_dirty_tag(version):
148162
return version.format_choice('', '+dirty')
149163

0 commit comments

Comments
 (0)