Skip to content

Commit

Permalink
Support setuptools_scm
Browse files Browse the repository at this point in the history
Closes #68.
  • Loading branch information
mgedmin committed Apr 12, 2018
1 parent d1fdd10 commit aa61c68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Expand Up @@ -7,6 +7,13 @@ Changelog

- Drop Python 3.3 support.

- Support packages using ``setuptools_scm``
(`#68 <https://github.com/mgedmin/check-manifest/issues/68>`__).

Note that ``setuptools_scm`` usually makes MANIFEST.in files obsolete.
Having one is helpful only if you intend to build an sdist and then use that
sdist to perform further builds, instead of building from a source checkout.


0.36 (2017-11-21)
-----------------
Expand Down
10 changes: 10 additions & 0 deletions check_manifest.py
Expand Up @@ -788,6 +788,14 @@ def is_package(source_tree='.'):
return os.path.exists(os.path.join(source_tree, 'setup.py'))


def extract_version_from_filename(filename):

This comment has been minimized.

Copy link
@RonnyPfannschmidt

RonnyPfannschmidt Sep 11, 2021

this returns incorrect data for distribution names that use dashes

this triggers pypa/setuptools_scm#630

the version should always asked from the setup.py of the project and/or the pkg_info metadata

This comment has been minimized.

Copy link
@mgedmin

mgedmin Sep 13, 2021

Author Owner

Oh darn, it's wheels that normalize - to _, sdists retain them.

This comment has been minimized.

Copy link
@mgedmin

mgedmin Sep 13, 2021

Author Owner

I see you've already filed #145 for this.

"""Extract version number from sdist filename."""
filename = os.path.splitext(os.path.basename(filename))[0]
if filename.endswith('.tar'):
filename = os.path.splitext(filename)[0]
return filename.partition('-')[2]


def check_manifest(source_tree='.', create=False, update=False,
python=sys.executable):
"""Compare a generated source distribution with list of files in a VCS.
Expand Down Expand Up @@ -816,6 +824,7 @@ def check_manifest(source_tree='.', create=False, update=False,
sdist_files = sorted(normalize_names(strip_sdist_extras(
strip_toplevel_name(get_archive_file_list(sdist_filename)))))
info_continue(": %d files and directories" % len(sdist_files))
version = extract_version_from_filename(sdist_filename)
existing_source_files = list(filter(os.path.exists, all_source_files))
missing_source_files = sorted(set(all_source_files) - set(existing_source_files))
if missing_source_files:
Expand All @@ -840,6 +849,7 @@ def check_manifest(source_tree='.', create=False, update=False,
info_begin("building a clean sdist")
with cd(tempsourcedir):
with mkdtemp('-sdist') as tempdir:
os.environ['SETUPTOOLS_SCM_PRETEND_VERSION'] = version
run([python, 'setup.py', 'sdist', '-d', tempdir])
sdist_filename = get_one_file_in(tempdir)
info_continue(": %s" % os.path.basename(sdist_filename))
Expand Down
5 changes: 5 additions & 0 deletions tests.py
Expand Up @@ -449,6 +449,11 @@ def test_is_package(self):
self.assertTrue(is_package('a'))
self.assertFalse(is_package('b'))

def test_extract_version_from_filename(self):
from check_manifest import extract_version_from_filename as e
self.assertEqual(e('dist/foo_bar-1.2.3.dev4+g12345.zip'), '1.2.3.dev4+g12345')
self.assertEqual(e('dist/foo_bar-1.2.3.dev4+g12345.tar.gz'), '1.2.3.dev4+g12345')

def test_glob_to_regexp(self):
from check_manifest import _glob_to_regexp as g2r
sep = os.path.sep.replace('\\', '\\\\')
Expand Down

0 comments on commit aa61c68

Please sign in to comment.