Repository: facebookresearch/nevergrad

Issue:
Setup adds files directly to the root of sys.prefix
The arguments to `setup.py` add files directly to the root of `sys.prefix`, instead of in a nevergrad-specific subsubdirectory.

## Steps to reproduce

```console
jwnimmer@call-cc:~/issue$ python3 -m virtualenv --python python3 scratch
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/jwnimmer/issue/scratch/bin/python3
Also creating executable in /home/jwnimmer/issue/scratch/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

jwnimmer@call-cc:~/issue$ scratch/bin/pip install 'nevergrad == 0.2.2'
Collecting nevergrad==0.2.2
  Downloading https://files.pythonhosted.org/packages/46/04/b2f4673771fbd2fd07143f44a4f2880f8cbaa08a0cc32bdf287eef99c1d7/nevergrad-0.2.2-py3-none-any.whl (170kB)
... etc ...
... etc ...
Installing collected packages: typing-extensions, numpy, scipy, joblib, scikit-learn, bayesian-optimization, cma, six, python-dateutil, pytz, pandas, nevergrad
Successfully installed bayesian-optimization-1.0.1 cma-2.7.0 joblib-0.13.2 nevergrad-0.2.2 numpy-1.16.4 pandas-0.24.2 python-dateutil-2.8.0 pytz-2019.1 scikit-learn-0.21.2 scipy-1.3.0 six-1.12.0 typing-extensions-3.7.4

jwnimmer@call-cc:~/issue$ ls -l scratch
total 80
-rw-rw-r-- 1 jwnimmer jwnimmer   84 Jul 23 14:08 bench.txt
drwxrwxr-x 2 jwnimmer jwnimmer 4096 Jul 23 14:08 bin
-rw-rw-r-- 1 jwnimmer jwnimmer  102 Jul 23 14:08 dev.txt
drwxrwxr-x 2 jwnimmer jwnimmer 4096 Jul 23 14:07 include
drwxrwxr-x 3 jwnimmer jwnimmer 4096 Jul 23 14:07 lib
-rw-rw-r-- 1 jwnimmer jwnimmer 1086 Jul 23 14:08 LICENSE
-rw-rw-r-- 1 jwnimmer jwnimmer   94 Jul 23 14:08 main.txt
drwxrwxr-x 3 jwnimmer jwnimmer 4096 Jul 23 14:08 nevergrad
-rw-rw-r-- 1 jwnimmer jwnimmer   59 Jul 23 14:07 pip-selfcheck.json
drwxrwxr-x 3 jwnimmer jwnimmer 4096 Jul 23 14:07 share
```

## Observed Results

The `sys.prefix` contains spurious files:
```
LICENSE
bench.txt
dev.txt
main.txt
nevergrad/*
```

## Expected Results

Only standardized files and folders (bin, lib, share, ...) exist in the root of `sys.prefix`.

## Relevant Code

https://github.com/facebookresearch/nevergrad/blob/aabb4475b04fc10e668cd1ed6783d24107c72390/setup.py#L68-L70

## Additional thoughts

I am sure why the `LICENSE` or `*.txt` files are being explicitly installed in the first place.  I believe that information is already available in the metadata.  If they are to be installed, they should be in a nevergrad-specific subfolder.

I suspect the nevergrad examples are probably better installed using `packages=` or `package_data=` argument, not `data_files=`.


Discussion:
Hi,
Thanks for pointing this out.

I'd rather the LICENSE file be explicitly kept since we need it when distributing source code (whithout the `data_files` trick it would not be present in the tar.gz files on pypi).

However the location seems weird indeed. I'll have a look when I can, but have to focus on another project until end of august so it may take a while :s (or if you or anybody else wants to propose a PR they'll be more than welcome ;) as long as the LICENSE file remains included)

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -65,11 +65,9 @@ def _replace_relative_links(regex: Match[str]) -> str:
                  "Intended Audience :: Science/Research",
                  "Topic :: Scientific/Engineering",
                  "Programming Language :: Python"],
-    data_files=[("", ["LICENSE", "requirements/main.txt", "requirements/dev.txt", "requirements/bench.txt"]),
-                ("nevergrad", ["nevergrad/benchmark/additional/example.py",
-                               "nevergrad/instrumentation/examples/script.py"])],
     install_requires=requirements["main"],
     extras_require={"all": requirements["dev"] + requirements["bench"],
                     "dev": requirements["dev"],
-                    "benchmark": requirements["bench"]}
+                    "benchmark": requirements["bench"]},
+    package_data={"nevergrad": ["py.typed", "*.csv", "*.py", "functions/photonics/src/*"]},
 )


Test patch: