pycbc
pycbc copied to clipboard
Examples files missing from source distribution
Running pytest
against a version of PyCBC built from the source distribution (tarball) fails because (at least) examples/distributions/example.ini
isn't in the distribution:
Pytest traceback
___________________________________________ TestDistributions.test_pdf_logpdf ____________________________________________
self = <test_distributions.TestDistributions testMethod=test_pdf_logpdf>
def setUp(self):
# set random seed
numpy.random.seed(1024)
# path to example configuration file for testing
config_path = "/".join([os.path.dirname(os.path.realpath(__file__)),
"../examples/distributions/example.ini"])
# get a set of simulated command line options for
# configuration file reading
class Arguments(object):
config_overrides = []
config_delete = []
config_files = [config_path]
self.opts = Arguments()
# read configuration files
> self.cp = WorkflowConfigParser.from_cli(self.opts)
test/test_distributions.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pycbc/types/config.py:210: in from_cli
return cls(opts.config_files, overrides, deleteTuples=deletes)
pycbc/workflow/configuration.py:238: in __init__
configFiles = [
pycbc/workflow/configuration.py:239: in <listcomp>
resolve_url(cFile, copy_to_cwd=copy_to_cwd)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = '/home/duncan/git/pycbc/dist/PyCBC-0.0a8421/test/../examples/distributions/example.ini', directory = None
permissions = None, copy_to_cwd = False
def resolve_url(url, directory=None, permissions=None, copy_to_cwd=True):
"""Resolves a URL to a local file, and returns the path to that file.
If a URL is given, the file will be copied to the current working
directory. If a local file path is given, the file will only be copied
to the current working directory if ``copy_to_cwd`` is ``True``
(the default).
"""
u = urlparse(url)
# determine whether the file exists locally
islocal = u.scheme == "" or u.scheme == "file"
if not islocal or copy_to_cwd:
# create the name of the destination file
if directory is None:
directory = os.getcwd()
filename = os.path.join(directory, os.path.basename(u.path))
else:
filename = u.path
if islocal:
# check that the file exists
if not os.path.isfile(u.path):
errmsg = "Cannot open file %s from URL %s" % (u.path, url)
> raise ValueError(errmsg)
E ValueError: Cannot open file /home/duncan/git/pycbc/dist/PyCBC-0.0a8421/test/../examples/distributions/example.ini from URL /home/duncan/git/pycbc/dist/PyCBC-0.0a8421/test/../examples/distributions/example.ini
pycbc/workflow/configuration.py:65: ValueError
Dist contents
$ tar -tf dist/PyCBC-0.0a8421.tar.gz | grep "\.ini"
PyCBC-0.0a8421/pytest.ini
PyCBC-0.0a8421/tox.ini
To reproduce
. $(conda info --base)/etc/profile.d/conda.sh
conda create -n pycbc -y "python=3.9" build pip mkl pytest
conda activate pycbc
git clean -dfX
python3 -m build --sdist
cd dist
tar -xf PyCBC-*.tar.*
cd PyCBC-*/
python3 -m pip install --editable .
python3 -m pytest
Patch
diff --git a/MANIFEST.in b/MANIFEST.in
index 84fc07f4d..d8882f41d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,7 +3,7 @@ include bin/*
include tox.ini
include pytest.ini
include README.md
-recursive-include examples *py *sh *xml
+recursive-include examples *ini *py *sh *xml
recursive-include tools *py
recursive-include pycbc *cpp
include LICENSE