Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of PYTHONSTARTUP environment variable #235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

paschembri
Copy link

When creating the python interpreter, it will load PYTHONSTARTUP if available

	When creating the python interpreter, it will load PYTHONSTARTUP if available
	Make variable name explicit
	Delete variable
	Use "with" statement
	Delete _f after 'with' block
@paschembri
Copy link
Author

Squashed commits from #233

@tseaver
Copy link
Contributor

tseaver commented Apr 12, 2015

Can you add a test and an entry in CHANGES.rst?

@reinout
Copy link
Contributor

reinout commented Jun 11, 2015

For adding a test, look in the easy_install.txt next to the easy_install.py. Somewhere around line 500 you'll see a >>> cat(bin, 'demo') that prints out a generated file. Perhaps duplicate those lines and save the existing os.environ and modify it, run buildout again, check the output and restore the old os.environ.

@paschembri
Copy link
Author

Thanks for the info. Actually, after testing the feature and using it, I am not sure it is a good idea to load PYTHONSTARTUP within the python interpreter generated.
It is quite implicit and has no warning. So if a user has some paths in its PYTHONSTARTUP file it may go against the idea of a buildout for isolated environment.

I think adding a parameter to explicitely allow the use of PYTHONSTARTUP may be a better idea. What do you think ?

@gotcha
Copy link
Member

gotcha commented Jun 11, 2015

@paschembri I agree with your last comment and proposal.

@reinout
Copy link
Contributor

reinout commented Jun 11, 2015

(Note: I haven't used PYTHONSTARTUP myself, so I'm mostly brainstorming here).

There might still be a mismatch between PYTHONSTARTUP (something individual users might want, and then they want it for all their buildouts) and the buildout config (which is used by multiple users, and not every one of them uses PYTHONSTARTUP in a buildout-compatible way).

So switching on the option in a buildout enables it for all the users. You rather want to enable it per user and not per buildout.

Would it help to document it as something you'd generally want to enable (or disable) in ~/.buildout/default.cfg? Instead of in a specific project's buildout? In that case, a use_pythonstartup=true option in the [buildout] part might be a good idea.

@paschembri
Copy link
Author

OK, let's do that.

@paschembri
Copy link
Author

After digging into the source files, adding an option to generate the python interpreter script requires the
modification of the 'scripts' function signature (https://github.com/buildout/buildout/blob/master/src/zc/buildout/easy_install.py#L960) to pass buildout options.

The script function signature would be changed from

def scripts(reqs, working_set, executable, dest=None,
        scripts=None,
        extra_paths=(),
        arguments='',
        interpreter=None,
        initialization='',
        relative_paths=False,
        )

to

def scripts(reqs, working_set, executable, dest=None,
        scripts=None,
        extra_paths=(),
        arguments='',
        interpreter=None,
        initialization='',
        relative_paths=False,
        use_pythonstartup=False,
        )

Other internal functions may be changed but with minor modifications.

Finally, using the 'initialization' variable is too limited to do something clean (no indentation possible !).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants