Repository: getpelican/pelican

Issue:
No tests in bdist
Discussion from IRC:

```
18:38 <ionelmc> can you stop including the tests in the installed package?
18:39 <+justmay> Fine with me. Care to submit a PR that addresses that?
18:39 <ionelmc> sure
18:47 <ionelmc> justmay: is `.mailmap` a stray file?
18:47 <ionelmc> look like your sdist is incomplete
18:48 <ionelmc> doesn't include all the docs and test conf
18:50 <ionelmc> justmay: oh snap. i have to move out the tests to fix this :-)
18:51 <ionelmc> because include_package_data is used any included data file overlaying the package is going into the bdist
18:51 <+justmay> ionelmc: .mailmap is there by design. See "Mapping Authors": https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html
18:52 <ionelmc> mkay
18:52 <ionelmc> justmay: you're not going to have a problem with the tests dir at the same level as pelican package right?
18:53 → e-Flex joined (~e-Flex@h-62-241.a259.priv.bahnhof.se)
18:54 <+justmay> There's no other way to prevent inclusion of tests in the installed package?
18:55 <ionelmc> justmay: there are two horrible ways
18:55 <ionelmc> don't include it in the sdist (highly undesirable)
18:55 <ionelmc> or
18:55 <ionelmc> manually specify package_data 
18:55 <ionelmc> which i can do it correctly for you know, but it will be error prone to maintain
18:56 <ionelmc> s/know/now/
18:56 <ionelmc> i think that's also not desirable
18:56 <ionelmc> that's why i think moving them out is ok
18:57 <ionelmc> i'll fix the test configuration to work that way
18:57 <ionelmc> justmay: agree? :-)
18:59 <+justmay> ionelmc: Quite honestly, I don't have the bandwidth this morning to dig deeply enough into this topic. Would you submit an issue so we (i.e., the community) can discuss this and come to a consensus?
19:00 <ionelmc> justmay: there's already https://github.com/getpelican/pelican/issues/1409 - i seriously doubt a new issue will help in any way
19:01 <winlu> ionelmc: justs prune tests and be done with it
19:01 <ionelmc> justmay: it's either the relocation or manual package_data, make a choice :-)
19:01 <ionelmc> winlu: pruning the tests will remove them from sdist
```

Closes #1609. Closes #1545. Closes #1409.



Discussion:
@ionelmc: With these changes, it would seem that [Travis is not running tests](https://travis-ci.org/getpelican/pelican/builds/49962641). _(Hat tip to @Avaris for noticing this!)_

Good catch but Coveralls does this automatically for you :wink: 

If you enable it I'll add configuration for it.

Mkay, there are some merge conflicts ....

Rebased now. @justinmayer seems coveralls isn't reporting any build status. Can you check? Maybe you just need to reauth with coveralls.

the move to a more traditional split of packages is what mainly does it for me, i.e. move tests out of the pelican directory.
If you look at other python projects it would be even more expected to not have pelican_tests but just tests.

the changes to the sdists and bdists also would also help the ongoing effort to make pelican play nice with windows.

@justinmayer Any updates here? It's not clear what you're waiting for.

I've been thinking, maybe we should have something like this: https://bitbucket.org/pypa/setuptools/pull-request/133/dont-install-tests-in-site-packages/diff

this won't be looked at until it at least confirms with what we require of pull requests: http://pelican.readthedocs.org/en/latest/contribute.html#using-git-and-github

It's not clear what you're asking of.

On Thursday, May 28, 2015, winlu notifications@github.com wrote:

> this won't be looked at until it at least confirms with what we require of
> pull requests:
> http://pelican.readthedocs.org/en/latest/contribute.html#using-git-and-github
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/getpelican/pelican/pull/1618#issuecomment-106199264.

## 

Thanks,
-- Ionel Cristian Mărieș, http://blog.ionelmc.ro

@ionelmc: Is there an advantage to relocating the tests to `/pelican_tests` as opposed to `/tests`? The latter appears to be a more common pattern.

@justinmayer The advantage was me not having to rework all the imports in the tests :-)

I can redo this, and have them in a `tests` directory but you have to pledge that you merge this.

Already planning on merging it, as noted by the 3.6.1 milestone I added last week. When you rebase on current master and make your changes, would you take a moment to squash into discrete commits?

Really appreciate all your help with this. It'll be nice to resolve the aforementioned problems related to this issue.

I don't think I can rebase this. Git not smart enough to deal with renames in rebase - I have to redo it.

Good point. Thanks again for all your assistance with this effort.

Hi @ionelmc. Just checking in... Any chance you might find the time to implement the changes we talked about a couple weeks ago?


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,7 @@
 #!/usr/bin/env python
+from os import walk
+from os.path import join, relpath, dirname
+
 from setuptools import setup
 
 requires = ['feedgenerator >= 1.6', 'jinja2 >= 2.7', 'pygments', 'docutils',
@@ -14,11 +17,9 @@
     ]
 }
 
-
 README = open('README.rst').read()
 CHANGELOG = open('docs/changelog.rst').read()
 
-
 setup(
     name="pelican",
     version="3.6.1.dev",
@@ -29,7 +30,19 @@
                 "Markdown input files.",
     long_description=README + '\n' + CHANGELOG,
     packages=['pelican', 'pelican.tools'],
-    include_package_data=True,
+    package_data={
+        # we manually collect the package data, as opposed to using include_package_data=True
+        # because we don't want the tests to be included automatically as package data
+        # (MANIFEST.in is too greedy)
+        'pelican': [
+            relpath(join(root, name), 'pelican')
+            for root, _, names in walk(join('pelican', 'themes')) for name in names
+        ],
+        'pelican.tools': [
+            relpath(join(root, name), join('pelican', 'tools'))
+            for root, _, names in walk(join('pelican', 'tools', 'templates')) for name in names
+        ],
+    },
     install_requires=requires,
     entry_points=entry_points,
     classifiers=[


Test patch: