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

verify installation of a dummy Python package before actually installing a Python package #475

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

boegel
Copy link
Member

@boegel boegel commented Sep 12, 2014

After spending about 2h on trying to figure out why a particular setuptools installation was blatently ignoring --prefix, I was sufficiently frustrated to come up with this: a verification of whether whichever setuptools is active honors --prefix before actually installing a Python package with it.

Up until now, I've run into two different ways of making setuptools blatently ignore --prefix:

  • via the distutils.cfg or $HOME/.pydistutils.cfg configuration files which effectively override any specified --prefix comand line option (cfr. https://docs.python.org/2/install/#distutils-configuration-files)
  • by using a setuptools installation that was installed with --user into $HOME/.local, causing it to install everything to $HOME/.local regardless of what --prefix specifies (yes, you read that right)

Since there's little we can do to prevent the use of a (basically broken) setuptools installation (there's no way I'm aware of in which we can install our own and be 100% sure it'll be used), we better have a way of verifying whether the active setuptools does the right thing.

related: easybuilders/easybuild#31, #373 and last nights discussion with @kcgthb on the #easybuild IRC channel

@stdweird, @JensTimmerman: thoughts on this?

cc: @kcgthb, @chwilk, @DimitriSteyaert, @pforai, @ocaisa

}
run_cmd(cmd, log_all=True, simple=True)

# setuptools stubbornly replaces the shebang line in scripts with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch setuptools? (the one used is one EB installed right?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, move in separate method

# setuptools stubbornly replaces the shebang line in scripts with
# the full path to the Python interpreter used to install;
# we change it (back) to '#!/usr/bin/env python' here
shebang_re = re.compile("^#!/.*python")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define in the if block

script = os.path.join(bindir, script)
if os.path.isfile(script):
try:
txt = open(script, 'r').read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use filehandle, so you'll open it only once (and close it explicitly)
second, don't read in the whole file, use readline or eg first 4k bytes.
after the read and match if found, don't forget to fh.seek(0) before reading the whole script.
although i'd prefer fileinput thoe all this....

@boegel boegel mentioned this pull request Mar 11, 2015
8 tasks
@boegel boegel added this to the v2.3 milestone Jul 15, 2015
@boegel boegel modified the milestones: v2.4.0, v2.5.0 Nov 6, 2015
@boegel boegel modified the milestones: v2.5.0, v2.6.0 Dec 14, 2015
@boegel boegel modified the milestones: v2.7.0, v2.6.0 Jan 23, 2016
@boegel boegel modified the milestones: v2.7.0, v2.x Mar 9, 2016
@boegel boegel modified the milestones: 3.x, 4.x Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants