Pippi
Pippi

Reputation: 2571

How do I write a setup.py and other installation files in Python that set path?

I have several packages in folder Top. The path is set at the command prompt such that each package contains some python files that use other packages' modules.

I have the following files in Top directory: setup.py, MANIFEST, MANIFEST.in, README. I wish to modify the setup files such that the path is set during installation. Does PYTHONPATH set it, and does it need to go into a new file?

Upvotes: 1

Views: 48

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83438

The appropriate actions here are

  • Packages do not mess with PYTHONPATH. Never.

  • Instead, you write an setup.py entry point to your command line scripts

  • When the user installs the package using pip install the command line script is automatically added to user's PATH, which is hopefully inside virtualenv

  • This command line script is generated during the install, so that it points to the PYTHONPATH of virtualenv or system-wide Python installation. The path is hardcoded at the script head, pointing to the current Python interpreter.

More info

Upvotes: 1

Related Questions