Codebase list setuptools-scm / 18c06c9
New upstream version 1.17.0 Julien Puydt 6 years ago
25 changed file(s) with 1276 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
0 ### JetBrains template
1 # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
2
3 *.iml
4
5 ## Directory-based project format:
6 .idea/
7
8 ### Other editors
9 .*.swp
10
11
12 ### Python template
13 # Byte-compiled / optimized
14 __pycache__/
15 *.py[cod]
16 *$py.class
17
18
19 # Distribution / packaging
20 .env/
21 env/
22 build/
23 dist/
24 .eggs/
25 lib/
26 lib64/
27 *.egg-info/
28
29 # Installer logs
30 pip-log.txt
31 pip-delete-this-directory.txt
32
33 # Unit test / coverage reports
34 htmlcov/
35 .tox/
36 .coverage
37 .coverage.*
38 .cache
39 nosetests.xml
40 coverage.xml
41 *,cover
42
43 # Sphinx documentation
44 docs/_build/
0 language: python
1 sudo: false
2 python:
3 - '2.7'
4 - '3.4'
5 - '3.5'
6 - '3.6'
7 #- '3.7'
8 env:
9 - TOXENV=py-test
10
11 matrix:
12 include:
13 - python: '3.5'
14 env: TOXENV=flake8
15 - python: '3.5'
16 env: TOXENV=check_readme
17 - python: '2.7'
18 env: SELFINSTALL=1
19 - python: '3.5'
20 env: SELFINSTALL=1
21 cache:
22 files:
23 - $HOME/.pip/cache
24 - $Home/.cache/pip
25 install: pip install tox
26 script:
27 - python testing/runtests_travis.py
28
29
30
31 credentials:
32 - &pypi
33 provider: pypi
34 user: ronny
35 password:
36 secure: QGJhDXmfFDKysMJJV/ONGaHHzG/aImhU3DdhEP63d657iQSn/Cb4EG/l9YmVnRzpJ94nSDXZB8YwptR7rid0bOtidb32lxN8n6UiWILCXWeAN2FE+tT9/0xIct4HUJZ8OttD1gft/Di722Gy+s9PzFwjwrV4efkxCzgjfYOjkMeq3aO6NoG3ur0iZXJh7ODwLp4sRFep2NpIEaXm2qMdnnXpck6bJ1q/NtvPx9CAZivd9HYa0evg5j1ENTz1mXXafhgF+0vRCBXA33xJuysO6CKtk+2mizL1QHfosOERiKl9+zPyZw+VvSchbCVwgxrMSiRcpGag+4SegyHrj1M/2YqfFzMF/yuFGcqXl2VkEqlnBQOVMNW3Kdcmnm+caNbddnv+M384WFz4nV8nWjcsD5l27+XlMWfuvskDIvZKtVCXmmbtqgwM4tqoYd6uxbnooRfwINTGx8sNzKP10xkaesB3ZBCEpecOKA1AXUAZ74RfYWWExv6eIuVGwyIJmOcD8M/17N8g58GxxO+88gx50EuhyNiRjYZDUipfVydfJwBwpD+p695NixUMITuksucQftjHsQp+laGWJlDIPvFwI85wDJUYAyrzn6L1W+smkm1bGomuliW2MJfxeSZAmSk4CE5VOpIWQTBmDLR3pxBhcaqzwdd4mAWvMi/fpM4yJJI=
37
38 deploy:
39 - <<: *pypi
40 on:
41 tags: true
42 python: '2.7'
43 distributions: "sdist bdist_wheel"
44 - <<: *pypi
45 on:
46 tags: true
47 distributions: "bdist_egg"
0 v1.17.0
1 ========
2
3 * fix regression in git support - use a function to ensure it works in egg isntalled mode
4 * actually fail if file finding fails in order to see broken setups instead of generating broken dists
5
6 (thanks Mehdi ABAAKOUK for both)
7
8
9 v1.16.2
10 ========
11
12 * fix regression in handling git export ignores
13 (thanks Mehdi ABAAKOUK)
14
15 v1.16.1
16 =======
17
18 * fix regression in support for old setuptools versions
19 (thanks Marco Clemencic)
20
21
22 v1.16.0
23 =======
24
25 * drop support for eol python versions
26 * #214 - fix missuse in surogate-escape api
27 * add the node-and-timestamp local version sheme
28 * respect git export ignores
29 * avoid shlex.split on windows
30 * fix #218 - better handling of mercurial edge-cases with tag commits
31 being considered as the tagged commit
32 * fix #223 - remove the dependency on the interal SetupttoolsVersion
33 as it was removed after long-standing deprecation
34
35 v1.15.7
36 ======
37
38 * Fix #174 with #207: Re-use samefile backport as developed in
39 jaraco.windows, and only use the backport where samefile is
40 not available.
41
42 v1.15.6
43 =======
44
45 * fix #171 by unpinning the py version to allow a fixed one to get installed
46
47 v1.15.5
48 =======
49
50 * fix #167 by correctly respecting preformatted version metadata
51 from PKG-INFO/EGG-INFO
52
53 v1.15.4
54 =======
55
56 * fix issue #164: iterate all found entry points to avoid erros when pip remakes egg-info
57 * enhance self-use to enable pip install from github again
58
59 v1.15.3
60 =======
61
62 * bring back correctly getting our version in the own sdist, finalizes #114
63 * fix issue #150: strip local components of tags
64
65 v1.15.2
66 =======
67
68 * fix issue #128: return None when a scm specific parse fails in a worktree to ease parse reuse
69
70
71 v1.15.1
72 =======
73
74 * fix issue #126: the local part of any tags is discarded
75 when guessing new versions
76 * minor performance optimization by doing fewer git calls
77 in the usual cases
78
79
80 v1.15.0
81 =======
82
83 * more sophisticated ignoring of mercurial tag commits
84 when considering distance in commits
85 (thanks Petre Mierlutiu)
86 * fix issue #114: stop trying to be smart for the sdist
87 and ensure its always correctly usign itself
88 * update trove classifiers
89 * fix issue #84: document using the installed package metadata for sphinx
90 * fix issue #81: fail more gracious when git/hg are missing
91 * address issue #93: provide an experimental api to customize behaviour on shallow git repos
92 a custom parse function may pick pre parse actions to do when using git
93
94
95 v1.14.1
96 =======
97
98 * fix #109: when detecting a dirty git workdir
99 don't consider untracked file
100 (this was a regression due to #86 in v1.13.1)
101 * consider the distance 0 when the git node is unknown
102 (happens when you haven't commited anything)
103
104 v1.14.0
105 =======
106
107 * publish bdist_egg for python 2.6, 2.7 and 3.3-3.5
108 * fix issue #107 - dont use node if it is None
109
110 v1.13.1
111 =======
112
113 * fix issue #86 - detect dirty git workdir without tags
114
115 v1.13.0
116 =======
117
118 * fix regression caused by the fix of #101
119 * assert types for version dumping
120 * strictly pass all versions trough parsed version metadata
121
122 v1.12.0
123 =======
124
125 * fix issue #97 - add support for mercurial plugins
126 * fix issue #101 - write version cache even for pretend version
127 (thanks anarcat for reporting and fixing)
128
129 v1.11.1
130 ========
131
132 * fix issue #88 - better docs for sphinx usage (thanks Jason)
133 * fix issue #89 - use normpath to deal with windows
134 (thanks Te-jé Rodgers for reporting and fixing)
135
136 v1.11.0
137 =======
138
139 * always run tag_to_version so in order to handle prefixes on old setuptools
140 (thanks to Brian May)
141 * drop support for python 3.2
142 * extend the error message on missing scm metadata
143 (thanks Markus Unterwaditzer)
144 * fix bug when using callable version_scheme
145 (thanks Esben Haabendal)
146
147 v1.10.1
148 =======
149
150 * fix issue #73 - in hg pre commit merge, consider parent1 instead of failing
151
152 v1.10.0
153 =======
154
155 * add support for overriding the version number via the
156 environment variable SETUPTOOLS_SCM_PRETEND_VERSION
157
158 * fix isssue #63 by adding the --match parameter to the git describe call
159 and prepare the possibility of passing more options to scm backends
160
161 * fix issue #70 and #71 by introducing the parse keyword
162 to specify custom scm parsing, its an expert feature,
163 use with caution
164
165 this change also introduces the setuptools_scm.parse_scm_fallback
166 entrypoint which can be used to register custom archive fallbacks
167
168
169 v1.9.0
170 ======
171
172 * Add :code:`relative_to` parameter to :code:`get_version` function;
173 fixes #44 per #45.
174
175 v1.8.0
176 ======
177
178 * fix issue with setuptools wrong version warnings being printed to standard
179 out. User is informed now by distutils-warnings.
180 * restructure root finding, we now reliably ignore outer scm
181 and prefer PKG-INFO over scm, fixes #43 and #45
182
183 v1.7.0
184 ======
185
186 * correct the url to github
187 thanks David Szotten
188 * enhance scm not found errors with a note on git tarballs
189 thanks Markus
190 * add support for :code:`write_to_template`
191
192 v1.6.0
193 ======
194
195 * bail out early if the scm is missing
196
197 this brings issues with git tarballs and
198 older devpi-client releases to light,
199 before we would let the setup stay at version 0.0,
200 now there is a ValueError
201
202 * propperly raise errors on write_to missuse (thanks Te-jé Rodgers)
203
204 v1.5.5
205 ======
206
207 * Fix bug on Python 2 on Windows when environment has unicode fields.
208
209 v1.5.4
210 ======
211
212 * Fix bug on Python 2 when version is loaded from existing metadata.
213
214 v1.5.3
215 ======
216
217 * #28: Fix decoding error when PKG-INFO contains non-ASCII.
218
219 v1.5.2
220 ======
221
222 * add zip_safe flag
223
224 v1.5.1
225 ======
226
227 * fix file access bug i missed in 1.5
228
229 v1.5.0
230 ======
231
232 * moved setuptools integration related code to own file
233 * support storing version strings into a module/text file
234 using the :code:`write_to` coniguration parameter
235
236 v1.4.0
237 ======
238
239 * propper handling for sdist
240 * fix file-finder failure from windows
241 * resuffle docs
242
243 v1.3.0
244 ======
245
246 * support setuptools easy_install egg creation details
247 by hardwireing the version in the sdist
248
249 v1.2.0
250 ======
251
252 * enhance self-use
253
254 v1.1.0
255 ======
256
257 * enable self-use
258
259 v1.0.0
260 ======
261
262 * documentation enhancements
263
264 v0.26
265 =====
266
267 * rename to setuptools_scm
268 * split into package, add lots of entry points for extension
269 * pluggable version schemes
270
271 v0.25
272 =====
273
274 * fix pep440 support
275 this reshuffles the complete code for version guessing
276
277 v0.24
278 =====
279
280 * dont drop dirty flag on node finding
281 * fix distance for dirty flagged versions
282 * use dashes for time again,
283 its normalisation with setuptools
284 * remove the own version attribute,
285 it was too fragile to test for
286 * include file finding
287 * handle edge cases around dirty tagged versions
288
289 v0.23
290 =====
291
292 * windows compatibility fix (thanks stefan)
293 drop samefile since its missing in
294 some python2 versions on windows
295 * add tests to the source tarballs
296
297
298 v0.22
299 =====
300
301 * windows compatibility fix (thanks stefan)
302 use samefile since it does path normalisation
303
304 v0.21
305 =====
306
307 * fix the own version attribute (thanks stefan)
308
309 v0.20
310 =====
311
312 * fix issue 11: always take git describe long format
313 to avoid the source of the ambiguity
314 * fix issue 12: add a __version__ attribute via pkginfo
315
316 v0.19
317 =====
318
319 * configurable next version guessing
320 * fix distance guessing (thanks stefan)
0 Permission is hereby granted, free of charge, to any person obtaining a copy
1 of this software and associated documentation files (the "Software"), to deal
2 in the Software without restriction, including without limitation the rights
3 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4 copies of the Software, and to permit persons to whom the Software is
5 furnished to do so, subject to the following conditions:
6
7 The above copyright notice and this permission notice shall be included in
8 all copies or substantial portions of the Software.
9
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16 THE SOFTWARE.
0 Metadata-Version: 1.1
0 Metadata-Version: 1.2
11 Name: setuptools_scm
2 Version: 1.15.7
2 Version: 1.17.0
33 Summary: the blessed package to manage your versions by scm tags
44 Home-page: https://github.com/pypa/setuptools_scm/
55 Author: Ronny Pfannschmidt
66 Author-email: opensource@ronnypfannschmidt.de
77 License: MIT
8 Description-Content-Type: UNKNOWN
98 Description: setuptools_scm
109 ===============
1110
314313 Classifier: Intended Audience :: Developers
315314 Classifier: License :: OSI Approved :: MIT License
316315 Classifier: Programming Language :: Python
316 Classifier: Programming Language :: Python :: 2
317317 Classifier: Programming Language :: Python :: 3
318 Classifier: Programming Language :: Python :: 2.6
319318 Classifier: Programming Language :: Python :: 2.7
320 Classifier: Programming Language :: Python :: 3.3
321319 Classifier: Programming Language :: Python :: 3.4
322320 Classifier: Programming Language :: Python :: 3.5
323321 Classifier: Programming Language :: Python :: 3.6
325323 Classifier: Topic :: Software Development :: Version Control
326324 Classifier: Topic :: System :: Software Distribution
327325 Classifier: Topic :: Utilities
326 Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
0 environment:
1 matrix:
2 - PYTHON: "C:\\Python27"
3 TOX_ENV: "py-test"
4
5 - PYTHON: "C:\\Python27-x64"
6 TOX_ENV: "py-test"
7
8 - PYTHON: "C:\\Python34"
9 TOX_ENV: "py-test"
10
11 - PYTHON: "C:\\Python34-x64"
12 TOX_ENV: "py-test"
13
14 init:
15 - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
16
17 - ECHO "Updating Environment"
18 - python -m pip install -U setuptools
19 - python -m pip install -U pip
20 - python -m pip install -U wheel
21 - python -m pip install -U tox
22
23
24 install:
25 # Check that we have the expected version and architecture for Python
26 - python -c "import sys, os;sys.stdout.write(str(sys.version) + os.linesep)"
27 - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
28 - python -m pip list
29
30 build: false # Not a C# project, build stuff at the test step instead.
31
32 test_script:
33 # Build the compiled extension and run the project tests
34 - python -m tox -e %TOX_ENV%"
35
36 after_test:
37 # If tests are successful, create a whl package for the project.
38 - "%CMD_IN_ENV% python setup.py bdist_wheel"
39 - ps: "ls dist"
40
41 artifacts:
42 # Archive the generated wheel package in the ci.appveyor.com build report.
43 - path: dist\*
44
0 {pkgs ? import <nixpkgs> {}}:
1 with pkgs.pythonPackages;
2 buildPythonPackage {
3 name = "setuptools_scm";
4 src = ./.;
5 version = "git";
6 buildInputs = [
7 setuptools
8 pip
9 pytest
10 pkgs.git
11 pkgs.mercurial
12 ];
13 }
14
8181
8282 [setuptools_scm.files_command]
8383 .hg = setuptools_scm.hg:FILES_COMMAND
84 .git = setuptools_scm.git:FILES_COMMAND
84 .git = setuptools_scm.git:list_files_in_archive
8585
8686 [setuptools_scm.version_scheme]
8787 guess-next-dev = setuptools_scm.version:guess_next_dev_version
8989
9090 [setuptools_scm.local_scheme]
9191 node-and-date = setuptools_scm.version:get_local_node_and_date
92 node-and-timestamp = \
93 setuptools_scm.version:get_local_node_and_timestamp
9294 dirty-tag = setuptools_scm.version:get_local_dirty_tag
9395 """,
9496 classifiers=[
9698 'Intended Audience :: Developers',
9799 'License :: OSI Approved :: MIT License',
98100 'Programming Language :: Python',
101 'Programming Language :: Python :: 2',
99102 'Programming Language :: Python :: 3',
100 'Programming Language :: Python :: 2.6',
101103 'Programming Language :: Python :: 2.7',
102 'Programming Language :: Python :: 3.3',
103104 'Programming Language :: Python :: 3.4',
104105 'Programming Language :: Python :: 3.5',
105106 'Programming Language :: Python :: 3.6',
108109 'Topic :: System :: Software Distribution',
109110 'Topic :: Utilities',
110111 ],
112 python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
111113 )
112114
113115 if __name__ == '__main__':
00 from .utils import do_ex, trace, has_command
11 from .version import meta
2
23 from os.path import isfile, join
4 import subprocess
5 import tarfile
36 import warnings
7
48
59 try:
610 from os.path import samefile
812 from .win_py31_compat import samefile
913
1014
11 FILES_COMMAND = 'git ls-files'
1215 DEFAULT_DESCRIBE = 'git describe --dirty --tags --long --match *.*'
1316
1417
115118 return meta(tag, distance=number, node=node, dirty=dirty)
116119 else:
117120 return meta(tag, node=node, dirty=dirty)
121
122
123 def list_files_in_archive(path):
124 """List the files that 'git archive' generates.
125 """
126 cmd = ['git', 'archive', 'HEAD']
127 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, cwd=path)
128 tf = tarfile.open(fileobj=proc.stdout, mode='r|*')
129 return [member.name for member in tf.getmembers()
130 if member.type != tarfile.DIRTYPE]
77 def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
88 dirty = node.endswith('+')
99 node = 'h' + node.strip('+')
10 revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')"
11 " - tag({tag!r}))").format(tag=tag)
10
11 # Detect changes since the specified tag
12 revset = ("(branch(.)" # look for revisions in this branch only
13 " and tag({tag!r})::." # after the last tag
14 # ignore commits that only modify .hgtags and nothing else:
15 " and (merge() or file('re:^(?!\.hgtags).*$'))"
16 " and not tag({tag!r}))" # ignore the tagged commit itself
17 ).format(tag=tag)
1218 if tag != '0.0':
1319 commits = do(['hg', 'log', '-r', revset, '--template', '{node|short}'],
1420 root)
3535 else:
3636 return command(path)
3737 except Exception:
38 import traceback
3938 print("File Finder Failed for %s" % ep)
40 traceback.print_exc()
41 return []
39 raise
4240
4341 else:
4442 return []
2525 if isinstance(str_or_bytes, str):
2626 return str_or_bytes.strip()
2727 else:
28 return str_or_bytes.decode('utf-8', 'surogate_escape').strip()
28 return str_or_bytes.decode('utf-8', 'surrogateescape').strip()
2929
3030
3131 def _always_strings(env_dict):
6060
6161 def do_ex(cmd, cwd='.'):
6262 trace('cmd', repr(cmd))
63 if not isinstance(cmd, (list, tuple)):
63 if os.name == "posix" and not isinstance(cmd, (list, tuple)):
6464 cmd = shlex.split(cmd)
6565
6666 p = _popen_pipes(cmd, cwd)
66 from pkg_resources import iter_entry_points
77
88 from distutils import log
9 from pkg_resources import parse_version
910
10 try:
11 from pkg_resources import parse_version, SetuptoolsVersion
12 except ImportError as e:
13 parse_version = SetuptoolsVersion = None
11
12 def _get_version_class():
13 modern_version = parse_version("1.0")
14 if isinstance(modern_version, tuple):
15 return None
16 else:
17 return type(modern_version)
18
19
20 VERSION_CLASS = _get_version_class()
1421
1522
1623 def _warn_if_setuptools_outdated():
17 if parse_version is None:
24 if VERSION_CLASS is None:
1825 log.warn("your setuptools is too old (<12)")
1926 log.warn("setuptools_scm functionality is degraded")
2027
3946 # also required for old versions of setuptools
4047
4148 version = tag.rsplit('-', 1)[-1].lstrip('v')
42 if parse_version is None:
49 if VERSION_CLASS is None:
4350 return version
4451 version = parse_version(version)
4552 trace('version', repr(version))
46 if isinstance(version, SetuptoolsVersion):
53 if isinstance(version, VERSION_CLASS):
4754 return version
4855
4956
9198 def _parse_tag(tag, preformatted):
9299 if preformatted:
93100 return tag
94 if SetuptoolsVersion is None or not isinstance(tag, SetuptoolsVersion):
101 if VERSION_CLASS is None or not isinstance(tag, VERSION_CLASS):
95102 tag = tag_to_version(tag)
96103 return tag
97104
143150 return version.format_choice("+{node}", "+{node}.d{time:%Y%m%d}")
144151
145152
153 def get_local_node_and_timestamp(version, fmt='%Y%m%d%H%M%S'):
154 if version.exact or version.node is None:
155 return version.format_choice("",
156 "+d{time:"
157 + "{fmt}".format(fmt=fmt)
158 + "}")
159 else:
160 return version.format_choice("+{node}",
161 "+{node}"
162 + ".d{time:"
163 + "{fmt}".format(fmt=fmt)
164 + "}")
165
166
146167 def get_local_dirty_tag(version):
147168 return version.format_choice('', '+dirty')
148169
0 Metadata-Version: 1.1
0 Metadata-Version: 1.2
11 Name: setuptools-scm
2 Version: 1.15.7
2 Version: 1.17.0
33 Summary: the blessed package to manage your versions by scm tags
44 Home-page: https://github.com/pypa/setuptools_scm/
55 Author: Ronny Pfannschmidt
66 Author-email: opensource@ronnypfannschmidt.de
77 License: MIT
8 Description-Content-Type: UNKNOWN
98 Description: setuptools_scm
109 ===============
1110
314313 Classifier: Intended Audience :: Developers
315314 Classifier: License :: OSI Approved :: MIT License
316315 Classifier: Programming Language :: Python
316 Classifier: Programming Language :: Python :: 2
317317 Classifier: Programming Language :: Python :: 3
318 Classifier: Programming Language :: Python :: 2.6
319318 Classifier: Programming Language :: Python :: 2.7
320 Classifier: Programming Language :: Python :: 3.3
321319 Classifier: Programming Language :: Python :: 3.4
322320 Classifier: Programming Language :: Python :: 3.5
323321 Classifier: Programming Language :: Python :: 3.6
325323 Classifier: Topic :: Software Development :: Version Control
326324 Classifier: Topic :: System :: Software Distribution
327325 Classifier: Topic :: Utilities
326 Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
0 .gitignore
1 .travis.yml
2 CHANGELOG.rst
3 LICENSE
04 README.rst
5 appveyor.yml
6 default.nix
17 setup.cfg
28 setup.py
9 tox.ini
310 setuptools_scm/__init__.py
411 setuptools_scm/__main__.py
512 setuptools_scm/discover.py
1522 setuptools_scm.egg-info/dependency_links.txt
1623 setuptools_scm.egg-info/entry_points.txt
1724 setuptools_scm.egg-info/top_level.txt
18 setuptools_scm.egg-info/zip-safe
25 setuptools_scm.egg-info/zip-safe
26 testing/conftest.py
27 testing/runtests_travis.py
28 testing/test_basic_api.py
29 testing/test_functions.py
30 testing/test_git.py
31 testing/test_main.py
32 testing/test_mercurial.py
33 testing/test_regressions.py
1515
1616 [setuptools_scm.files_command]
1717 .hg = setuptools_scm.hg:FILES_COMMAND
18 .git = setuptools_scm.git:FILES_COMMAND
18 .git = setuptools_scm.git:list_files_in_archive
1919
2020 [setuptools_scm.version_scheme]
2121 guess-next-dev = setuptools_scm.version:guess_next_dev_version
2323
2424 [setuptools_scm.local_scheme]
2525 node-and-date = setuptools_scm.version:get_local_node_and_date
26 node-and-timestamp = setuptools_scm.version:get_local_node_and_timestamp
2627 dirty-tag = setuptools_scm.version:get_local_dirty_tag
2728
0 import os
1 import itertools
2 import pytest
3
4 os.environ['SETUPTOOLS_SCM_DEBUG'] = '1'
5 VERSION_PKGS = ['setuptools', 'setuptools_scm']
6
7
8 def pytest_report_header():
9 import pkg_resources
10 res = []
11 for pkg in VERSION_PKGS:
12 version = pkg_resources.get_distribution(pkg).version
13 res.append('%s version %s' % (pkg, version))
14 return res
15
16
17 class Wd(object):
18 commit_command = None
19 add_command = None
20
21 def __init__(self, cwd):
22 self.cwd = cwd
23 self.__counter = itertools.count()
24
25 def __call__(self, cmd, **kw):
26 if kw:
27 cmd = cmd.format(**kw)
28 from setuptools_scm.utils import do
29 return do(cmd, self.cwd)
30
31 def write(self, name, value, **kw):
32 filename = self.cwd.join(name)
33 if kw:
34 value = value.format(**kw)
35 filename.write(value)
36 return filename
37
38 def _reason(self, given_reason):
39 if given_reason is None:
40 return 'number-{c}'.format(c=next(self.__counter))
41 else:
42 return given_reason
43
44 def commit(self, reason=None):
45 reason = self._reason(reason)
46 self(self.commit_command, reason=reason)
47
48 def commit_testfile(self, reason=None):
49 reason = self._reason(reason)
50 self.write('test.txt', 'test {reason}', reason=reason)
51 self(self.add_command)
52 self.commit(reason=reason)
53
54 def get_version(self, **kw):
55 __tracebackhide__ = True
56 from setuptools_scm import get_version
57 version = get_version(root=str(self.cwd), **kw)
58 print(version)
59 return version
60
61 @property
62 def version(self):
63 __tracebackhide__ = True
64 return self.get_version()
65
66
67 @pytest.yield_fixture(autouse=True)
68 def debug_mode():
69 from setuptools_scm import utils
70 utils.DEBUG = True
71 yield
72 utils.DEBUG = False
73
74
75 @pytest.fixture
76 def wd(tmpdir):
77 return Wd(tmpdir.ensure('wd', dir=True))
0
1 from subprocess import call
2
3 import os
4
5 if os.environ.get('TOXENV'):
6 # normal tox run, lets jsut have tox do its job
7 import tox
8 tox.cmdline()
9 elif os.environ.get('SELFINSTALL'):
10 # self install testing needs some clarity
11 # so its being executed without any other tools running
12 call('python setup.py sdist', shell=True)
13 call('easy_install dist/*', shell=True)
14 import pkg_resources
15 dist = pkg_resources.get_distribution('setuptools_scm')
16 assert set(dist.version) == set(".0"), dist.version
0 import os
1 import py
2 import pytest
3
4 import setuptools_scm
5 from setuptools_scm import dump_version
6
7 from setuptools_scm.utils import data_from_mime, do
8
9
10 @pytest.mark.parametrize('cmd', ['ls', 'dir'])
11 def test_do(cmd, tmpdir):
12 if not py.path.local.sysfind(cmd):
13 pytest.skip(cmd + ' not found')
14 do(cmd, str(tmpdir))
15
16
17 def test_data_from_mime(tmpdir):
18 tmpfile = tmpdir.join('test.archival')
19 tmpfile.write('name: test\nrevision: 1')
20
21 res = data_from_mime(str(tmpfile))
22 assert res == {
23 'name': 'test',
24 'revision': '1',
25 }
26
27
28 def test_version_from_pkginfo(wd):
29 wd.write('PKG-INFO', 'Version: 0.1')
30 assert wd.version == '0.1'
31
32 # replicate issue 167
33 assert wd.get_version(version_scheme="1.{0.distance}.0".format) == '0.1'
34
35
36 def assert_root(monkeypatch, expected_root):
37 """
38 Patch version_from_scm to simply assert that root is expected root
39 """
40 def assertion(root, unused_parse):
41 assert root == expected_root
42 monkeypatch.setattr(setuptools_scm, '_do_parse', assertion)
43
44
45 def test_root_parameter_creation(monkeypatch):
46 assert_root(monkeypatch, os.getcwd())
47 setuptools_scm.get_version()
48
49
50 def test_root_parameter_pass_by(monkeypatch, tmpdir):
51 assert_root(monkeypatch, tmpdir)
52 setuptools_scm.get_version(root=tmpdir.strpath)
53
54
55 def test_pretended(monkeypatch):
56 pretense = '2345'
57 monkeypatch.setenv(setuptools_scm.PRETEND_KEY, pretense)
58 assert setuptools_scm.get_version() == pretense
59
60
61 def test_root_relative_to(monkeypatch, tmpdir):
62 assert_root(monkeypatch, tmpdir.join('alt').strpath)
63 __file__ = tmpdir.join('module/file.py').strpath
64 setuptools_scm.get_version(root='../alt', relative_to=__file__)
65
66
67 def test_dump_version(tmpdir):
68 sp = tmpdir.strpath
69
70 dump_version(sp, '1.0', 'first.txt')
71 assert tmpdir.join('first.txt').read() == '1.0'
72 dump_version(sp, '1.0', 'first.py')
73 content = tmpdir.join('first.py').read()
74 assert repr('1.0') in content
75 import ast
76 ast.parse(content)
77
78
79 def test_parse_plain(recwarn):
80 def parse(root):
81 return 'tricked you'
82 assert setuptools_scm.get_version(parse=parse) == 'tricked you'
83 assert str(recwarn.pop().message) == \
84 'version parse result was a string\nplease return a parsed version'
0 import pytest
1 import sys
2 import pkg_resources
3 from setuptools_scm import dump_version, get_version, PRETEND_KEY
4 from setuptools_scm.version import guess_next_version, meta, format_version
5 from setuptools_scm.utils import has_command
6
7 PY3 = sys.version_info > (2,)
8
9
10 class MockTime(object):
11 def __format__(self, *k):
12 return 'time'
13
14
15 @pytest.mark.parametrize('tag, expected', [
16 ('1.1', '1.2.dev0'),
17 ('1.2.dev', '1.2.dev0'),
18 ('1.1a2', '1.1a3.dev0'),
19 ('23.24.post2+deadbeef', '23.24.post3.dev0'),
20 ])
21 def test_next_tag(tag, expected):
22 version = pkg_resources.parse_version(tag)
23 assert guess_next_version(version, 0) == expected
24
25
26 VERSIONS = {
27 'exact': meta('1.1', None, False),
28 'zerodistance': meta('1.1', 0, False),
29 'dirty': meta('1.1', None, True),
30 'distance': meta('1.1', 3, False),
31 'distancedirty': meta('1.1', 3, True),
32 }
33
34
35 @pytest.mark.parametrize('version,scheme,expected', [
36 ('exact', 'guess-next-dev node-and-date', '1.1'),
37 ('zerodistance', 'guess-next-dev node-and-date', '1.2.dev0'),
38 ('dirty', 'guess-next-dev node-and-date', '1.2.dev0+dtime'),
39 ('distance', 'guess-next-dev node-and-date', '1.2.dev3'),
40 ('distancedirty', 'guess-next-dev node-and-date', '1.2.dev3+dtime'),
41 ('exact', 'post-release node-and-date', '1.1'),
42 ('zerodistance', 'post-release node-and-date', '1.1.post0'),
43 ('dirty', 'post-release node-and-date', '1.1.post0+dtime'),
44 ('distance', 'post-release node-and-date', '1.1.post3'),
45 ('distancedirty', 'post-release node-and-date', '1.1.post3+dtime'),
46 ])
47 def test_format_version(version, monkeypatch, scheme, expected):
48 version = VERSIONS[version]
49 monkeypatch.setattr(version, 'time', MockTime())
50 vs, ls = scheme.split()
51 assert format_version(
52 version,
53 version_scheme=vs,
54 local_scheme=ls) == expected
55
56
57 def test_dump_version_doesnt_bail_on_value_error(tmpdir):
58 write_to = "VERSION"
59 version = str(VERSIONS['exact'].tag)
60 with pytest.raises(ValueError) as exc_info:
61 dump_version(tmpdir.strpath, version, write_to)
62 assert str(exc_info.value).startswith("bad file format:")
63
64
65 def test_dump_version_works_with_pretend(tmpdir, monkeypatch):
66 monkeypatch.setenv(PRETEND_KEY, '1.0')
67 get_version(write_to=str(tmpdir.join('VERSION.txt')))
68 assert tmpdir.join('VERSION.txt').read() == '1.0'
69
70
71 def test_has_command(recwarn):
72 assert not has_command('yadayada_setuptools_aint_ne')
73 msg = recwarn.pop()
74 assert 'yadayada' in str(msg.message)
0 from setuptools_scm import integration
1 from setuptools_scm.utils import do
2 from setuptools_scm import git
3 import pytest
4 from datetime import date
5
6
7 @pytest.fixture
8 def wd(wd):
9 wd('git init')
10 wd('git config user.email test@example.com')
11 wd('git config user.name "a test"')
12 wd.add_command = 'git add .'
13 wd.commit_command = 'git commit -m test-{reason}'
14 return wd
15
16
17 def test_version_from_git(wd):
18 assert wd.version == '0.1.dev0'
19
20 wd.commit_testfile()
21 assert wd.version.startswith('0.1.dev1+g')
22 assert not wd.version.endswith('1-')
23
24 wd('git tag v0.1')
25 assert wd.version == '0.1'
26
27 wd.write('test.txt', 'test2')
28 assert wd.version.startswith('0.2.dev0+g')
29
30 wd.commit_testfile()
31 assert wd.version.startswith('0.2.dev1+g')
32
33 wd('git tag version-0.2')
34 assert wd.version.startswith('0.2')
35
36 wd.commit_testfile()
37 wd('git tag version-0.2.post210+gbe48adfpost3+g0cc25f2')
38 assert wd.version.startswith('0.2')
39
40
41 @pytest.mark.issue(179)
42 def test_unicode_version_scheme(wd):
43 scheme = b'guess-next-dev'.decode('ascii')
44 assert wd.get_version(version_scheme=scheme)
45
46
47 @pytest.mark.issue(108)
48 @pytest.mark.issue(109)
49 def test_git_worktree(wd):
50 wd.write('test.txt', 'test2')
51 # untracked files dont change the state
52 assert wd.version == '0.1.dev0'
53 wd('git add test.txt')
54 assert wd.version.startswith('0.1.dev0+d')
55
56
57 @pytest.mark.issue(86)
58 def test_git_dirty_notag(wd):
59 wd.commit_testfile()
60 wd.write('test.txt', 'test2')
61 wd("git add test.txt")
62 assert wd.version.startswith('0.1.dev1')
63 today = date.today()
64 # we are dirty, check for the tag
65 assert today.strftime('.d%Y%m%d') in wd.version
66
67
68 @pytest.fixture
69 def shallow_wd(wd, tmpdir):
70 wd.commit_testfile()
71 wd.commit_testfile()
72 wd.commit_testfile()
73 target = tmpdir.join('wd_shallow')
74 do(['git', 'clone', "file://%s" % wd.cwd, str(target,), '--depth=1'])
75 return target
76
77
78 def test_git_parse_shallow_warns(shallow_wd, recwarn):
79 git.parse(str(shallow_wd))
80 msg = recwarn.pop()
81 assert 'is shallow and may cause errors' in str(msg.message)
82
83
84 def test_git_parse_shallow_fail(shallow_wd):
85 with pytest.raises(ValueError) as einfo:
86 git.parse(str(shallow_wd), pre_parse=git.fail_on_shallow)
87
88 assert 'git fetch' in str(einfo.value)
89
90
91 def test_git_shallow_autocorrect(shallow_wd, recwarn):
92 git.parse(str(shallow_wd), pre_parse=git.fetch_on_shallow)
93 msg = recwarn.pop()
94 assert 'git fetch was used to rectify' in str(msg.message)
95 git.parse(str(shallow_wd), pre_parse=git.fail_on_shallow)
96
97
98 def test_find_files_stop_at_root_git(wd):
99 wd.commit_testfile()
100 wd.cwd.ensure('project/setup.cfg')
101 assert integration.find_files(str(wd.cwd/'project')) == []
102
103
104 @pytest.mark.issue(128)
105 def test_parse_no_worktree(tmpdir):
106 ret = git.parse(str(tmpdir))
107 assert ret is None
108
109
110 def test_alphanumeric_tags_match(wd):
111 wd.commit_testfile()
112 wd('git tag newstyle-development-started')
113 assert wd.version.startswith('0.1.dev1+g')
114
115
116 def test_git_archive_export_ignore(wd):
117 wd.write('test1.txt', 'test')
118 wd.write('test2.txt', 'test')
119 wd.write('.git/info/attributes',
120 # Explicitly include test1.txt so that the test is not affected by
121 # a potentially global gitattributes file on the test machine.
122 '/test1.txt -export-ignore\n/test2.txt export-ignore')
123 wd('git add test1.txt test2.txt')
124 wd.commit()
125 assert integration.find_files(str(wd.cwd)) == ['test1.txt']
126
127
128 @pytest.mark.issue(228)
129 def test_git_archive_subdirectory(wd):
130 wd('mkdir foobar')
131 wd.write('foobar/test1.txt', 'test')
132 wd('git add foobar')
133 wd.commit()
134 assert integration.find_files(str(wd.cwd)) == ['foobar/test1.txt']
0 import os.path
1
2
3 def test_main():
4 mainfile = os.path.join(
5 os.path.dirname(__file__), "..", "setuptools_scm", "__main__.py")
6 with open(mainfile) as f:
7 code = compile(f.read(), "__main__.py", 'exec')
8 exec(code)
0 from setuptools_scm import format_version
1 from setuptools_scm.hg import archival_to_version, parse
2 from setuptools_scm import integration
3
4 import pytest
5
6
7 @pytest.fixture
8 def wd(wd):
9 wd('hg init')
10 wd.add_command = 'hg add .'
11 wd.commit_command = 'hg commit -m test-{reason} -u test -d "0 0"'
12 return wd
13
14
15 archival_mapping = {
16 '1.0': {'tag': '1.0'},
17 '1.1.dev3+h000000000000': {
18 'latesttag': '1.0',
19 'latesttagdistance': '3',
20 'node': '0'*20,
21 },
22 '0.0': {
23 'node': '0'*20,
24 },
25 '1.2.2': {'tag': 'release-1.2.2'},
26 '1.2.2.dev0': {'tag': 'release-1.2.2.dev'},
27
28 }
29
30
31 @pytest.mark.parametrize('expected,data', sorted(archival_mapping.items()))
32 def test_archival_to_version(expected, data):
33 version = archival_to_version(data)
34 assert format_version(
35 version,
36 version_scheme='guess-next-dev',
37 local_scheme='node-and-date') == expected
38
39
40 def test_find_files_stop_at_root_hg(wd):
41 wd.commit_testfile()
42 wd.cwd.ensure('project/setup.cfg')
43 assert integration.find_files(str(wd.cwd/'project')) == []
44
45
46 # XXX: better tests for tag prefixes
47 def test_version_from_hg_id(wd):
48 assert wd.version == '0.0'
49
50 wd.commit_testfile()
51 assert wd.version.startswith('0.1.dev2+')
52
53 # tagging commit is considered the tag
54 wd('hg tag v0.1 -u test -d "0 0"')
55 assert wd.version == '0.1'
56
57 wd.commit_testfile()
58 assert wd.version.startswith('0.2.dev2')
59
60 wd('hg up v0.1')
61 assert wd.version == '0.1'
62
63 # commit originating from the taged revision
64 # that is not a actual tag
65 wd.commit_testfile()
66 assert wd.version.startswith('0.2.dev1+')
67
68 # several tags
69 wd('hg up')
70 wd('hg tag v0.2 -u test -d "0 0"')
71 wd('hg tag v0.3 -u test -d "0 0" -r v0.2')
72 assert wd.version == '0.3'
73
74
75 def test_version_from_archival(wd):
76 # entrypoints are unordered,
77 # cleaning the wd ensure this test wont break randomly
78 wd.cwd.join('.hg').remove()
79 wd.write(
80 '.hg_archival.txt',
81 'node: 000000000000\n'
82 'tag: 0.1\n'
83 )
84 assert wd.version == '0.1'
85
86 wd.write(
87 '.hg_archival.txt',
88 'node: 000000000000\n'
89 'latesttag: 0.1\n'
90 'latesttagdistance: 3\n'
91 )
92
93 assert wd.version == '0.2.dev3+h000000000000'
94
95
96 @pytest.mark.issue('#72')
97 def test_version_in_merge(wd):
98 wd.commit_testfile()
99 wd.commit_testfile()
100 wd('hg up 0')
101 wd.commit_testfile()
102 wd('hg merge --tool :merge')
103 assert wd.version is not None
104
105
106 @pytest.mark.issue(128)
107 def test_parse_no_worktree(tmpdir):
108 ret = parse(str(tmpdir))
109 assert ret is None
110
111
112 @pytest.fixture
113 def version_1_0(wd):
114 wd('hg branch default')
115 wd.commit_testfile()
116 wd('hg tag 1.0 -u test -d "0 0"')
117 return wd
118
119
120 @pytest.fixture
121 def pre_merge_commit_after_tag(wd, version_1_0):
122 wd('hg branch testbranch')
123 wd.write('branchfile', 'branchtext')
124 wd(wd.add_command)
125 wd.commit()
126 wd('hg update default')
127 wd('hg merge testbranch')
128 return wd
129
130
131 @pytest.mark.usefixtures("pre_merge_commit_after_tag")
132 def test_version_bump_before_merge_commit(wd):
133 assert wd.version.startswith('1.1.dev1+')
134
135
136 @pytest.mark.issue(219)
137 @pytest.mark.usefixtures("pre_merge_commit_after_tag")
138 def test_version_bump_from_merge_commit(wd):
139 wd.commit()
140 assert wd.version.startswith('1.1.dev3+') # issue 219
141
142
143 @pytest.mark.usefixtures("version_1_0")
144 def test_version_bump_from_commit_including_hgtag_mods(wd):
145 """ Test the case where a commit includes changes to .hgtags and other files
146 """
147 with wd.cwd.join('.hgtags').open('a') as tagfile:
148 tagfile.write('0 0\n')
149 wd.write('branchfile', 'branchtext')
150 wd(wd.add_command)
151 assert wd.version.startswith('1.1.dev1+') # bump from dirty version
152 wd.commit() # commits both the testfile _and_ .hgtags
153 assert wd.version.startswith('1.1.dev2+')
0 import sys
1 import subprocess
2
3 from setuptools_scm import get_version
4 from setuptools_scm.git import parse
5 from setuptools_scm.utils import do_ex, do
6
7 import pytest
8
9
10 def test_pkginfo_noscmroot(tmpdir, monkeypatch):
11 """if we are indeed a sdist, the root does not apply"""
12 monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
13
14 # we should get the version from pkg-info if git is broken
15 p = tmpdir.ensure('sub/package', dir=1)
16 tmpdir.mkdir('.git')
17 p.join('setup.py').write(
18 'from setuptools import setup;'
19 'setup(use_scm_version={"root": ".."})')
20
21 _, stderr, ret = do_ex((sys.executable, 'setup.py', '--version'), p)
22 assert 'setuptools-scm was unable to detect version for' in stderr
23 assert ret == 1
24
25 p.join("PKG-INFO").write('Version: 1.0')
26 res = do((sys.executable, 'setup.py', '--version'), p)
27 assert res == '1.0'
28
29 do('git init', p.dirpath())
30 res = do((sys.executable, 'setup.py', '--version'), p)
31 assert res == '1.0'
32
33
34 def test_pip_egg_info(tmpdir, monkeypatch):
35 """if we are indeed a sdist, the root does not apply"""
36
37 # we should get the version from pkg-info if git is broken
38 p = tmpdir.ensure('sub/package', dir=1)
39 tmpdir.mkdir('.git')
40 p.join('setup.py').write(
41 'from setuptools import setup;'
42 'setup(use_scm_version={"root": ".."})')
43
44 with pytest.raises(LookupError):
45 get_version(root=p.strpath)
46
47 p.ensure('pip-egg-info/random.egg-info/PKG-INFO').write('Version: 1.0')
48 assert get_version(root=p.strpath) == '1.0'
49
50
51 @pytest.mark.issue(164)
52 def test_pip_download(tmpdir, monkeypatch):
53 monkeypatch.chdir(tmpdir)
54 subprocess.check_call([
55 sys.executable, '-c',
56 'import pip;pip.main()', 'download', 'lz4==0.9.0',
57 ])
58
59
60 def test_use_scm_version_callable(tmpdir, monkeypatch):
61 """use of callable as use_scm_version argument"""
62 monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
63
64 p = tmpdir.ensure('sub/package', dir=1)
65 p.join('setup.py').write(
66 '''from setuptools import setup
67 def vcfg():
68 from setuptools_scm.version import guess_next_dev_version
69 def vs(v):
70 return guess_next_dev_version(v)
71 return {"version_scheme": vs}
72 setup(use_scm_version=vcfg)
73 ''')
74 p.join("PKG-INFO").write('Version: 1.0')
75
76 res = do((sys.executable, 'setup.py', '--version'), p)
77 assert res == '1.0'
78
79
80 @pytest.mark.skipif(sys.platform != 'win32',
81 reason="this bug is only valid on windows")
82 def test_case_mismatch_on_windows_git(tmpdir):
83 """Case insensitive path checks on Windows"""
84 p = tmpdir.ensure("CapitalizedDir", dir=1)
85
86 do('git init', p)
87 res = parse(str(p).lower())
88 assert res is not None
0 [tox]
1 envlist=py{27,34,35,36,37}-test,flake8,check_readme
2
3 [flake8]
4 max-complexity = 10
5
6
7 [testenv]
8 usedevelop=True
9 deps=
10 pytest
11 commands=
12 test: py.test []
13
14 [testenv:flake8]
15 skip_install=True
16 deps=
17 flake8
18 mccabe
19 commands =
20 flake8 setuptools_scm/ testing/ setup.py --exclude=setuptools_scm/win_py31_compat.py
21
22 [testenv:check_readme]
23 skip_install=True
24 deps=
25 readme
26 commands=
27 python setup.py check -r -s
28 rst2html.py README.rst {envlogdir}/README.html --strict []
29
30 [testenv:upload]
31 deps=
32 wheel
33 twine
34 commands=
35 python setup.py clean --all rotate -k - -m .whl,.tar.gz,.zip
36 python setup.py -q egg_info
37 python setup.py -q sdist --formats zip bdist_wheel register
38
39
40
41 [testenv:dist]
42 deps= wheel
43 whitelist_externals = rm
44 commands=
45 python setup.py -q clean --all
46 python setup.py -q rotate -k 0 -m .egg,.zip,.whl,.tar.gz
47 python setup.py -q egg_info
48 python setup.py -q sdist --formats zip,bztar bdist_wheel upload
49
50 [testenv:devpi]
51 deps=
52 devpi-client
53 commands =
54 python setup.py -q egg_info
55 devpi upload --from-dir dist
56
57 #XXX: envs for hg versions