1

I would to like to distribute a python package using my setup.py, where the user is able to choose which modules will be installed.

In my case, I have the test module, where It's useful in only few cases, so it doesn't make sense distribute that module.

I can exclude the module easily by packages=find_packages(exclude=("conans.test*",)). However, I can't distribute it dynamically.

My idea is, package all files, but only install according the pip command. I would like to install the test module, only when the extra is configured:

pip install package[test]

Otherwise, it will not install the test module.

When I say test module, it means a folder with all those tests, not the requirements_test.txt file.

Is it possible using setuptools?

Regards!

uilianries
  • 3,363
  • 15
  • 28
  • [solution](https://stackoverflow.com/questions/3779915/why-does-python-setup-py-sdist-create-unwanted-project-egg-info-in-project-r) follow this solution , by jathanism , create a class which do the thing you want and for that taskk create a cli argument in cmdclass – sahasrara62 Mar 14 '19 at 18:12
  • 1
    A package is atomic and can't be reduced any further. Split your project into two dists, `conans` and `conans_tests` (optionally with `conans` being a namespace package). Extras are for reducing only the set of dependencies, not the codebase to install. – hoefling Mar 15 '19 at 00:01

1 Answers1

1

Thanks to hoefling!

Since it's possible create a dynamic package, the best that I found is run a script after install the package:

https://github.com/uilianries/conan-ldap-authentication/blob/master/setup.py#L40

uilianries
  • 3,363
  • 15
  • 28