0

I've a got a question over setup.py/pip install installation directories. I've written a setup.py script that should copy some files during installation. I've done this via setup.py script strings:

setup(name='funny_package',
      ....
      data_files=[('destination_dir1',
                    ['file1']),
                  ('destination_dir2',
                   ['file2'])],
      ...
      )

And files are copied. But when i run package's modules it is found out that modules are run from virtualenv_name/lib/site-packages/python3.5/funny_package and package itself is installed at virtualenv_name/funny_package.

The question is how to make setup.py/pip install to copy necessary files also to virtualenv_name/lib/site-packages/python3.5/funny_package not only to virtualenv_name/funny_package ???

UPD. file1 and file2 are generated during installation.

UPD2. The difference between the question is that my files that should be stored were generated during installation stage. But the problem is quite similar to that without MANIFEST.

SOLUTION. Solution is to use package_data. thanks to @AlexanderReynolds

  • Why do you want to move files on install? Python can resolve their paths easily. So I'm unclear what your usecase is. – The Pjot Feb 18 '19 at 09:33
  • This? https://python-packaging.readthedocs.io/en/latest/non-code-files.html – tripleee Feb 18 '19 at 10:03
  • My goal is to make files accessible from installed python pacakge code. I think that if i add them as `data_files` argument in `setup.py`, they will be accessible. – Ywi 4ebyrawi Feb 18 '19 at 10:06
  • @tripleee this could be a variant, but files are being generated during installation – Ywi 4ebyrawi Feb 18 '19 at 10:08
  • I just learned this the other day myself. `data_files` are not exactly meant to be data files that are specific to your library that you're installing, but your Python environment. As such Python installs them into the environment root (your venv, in this case). This isn't what you want. You want `package_data`. – alkasm Feb 18 '19 at 10:16
  • 2
    Possible duplicate of [How can I include package\_data without a MANIFEST.in file?](https://stackoverflow.com/questions/29036937/how-can-i-include-package-data-without-a-manifest-in-file) – alkasm Feb 18 '19 at 10:17
  • @AlexanderReynolds thanks, data_files helped me. – Ywi 4ebyrawi Feb 18 '19 at 12:48

0 Answers0