-
Notifications
You must be signed in to change notification settings - Fork 27
minimal tweaks to update for python3 #83
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
Changes from all commits
90bafff
3f3859c
285642d
a5b3a5e
6368499
a92dc63
91dac2c
c2df954
afa842e
0decdda
5da06fb
e5b4c9d
3599e6b
4ba00fd
5e331a4
396b9fa
ef56770
51914fe
807e265
b0a4417
274f65a
f3f0427
e9021d2
853ff24
4a77bbb
cc061a9
494be1d
4494f7e
4236d18
9306613
34d5b78
e30416f
31ea2e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,14 +30,21 @@ | |
| @author: Stijn De Weirdt (Ghent University) | ||
| @author: Andy Georges (Ghent University) | ||
| """ | ||
| import __builtin__ | ||
|
|
||
| from __future__ import print_function | ||
| import sys | ||
|
|
||
| if sys.version_info < (3, 0): | ||
| import __builtin__ | ||
| else: | ||
| import builtins as __builtin__ # make builtins accessible via same way as in Python 3 | ||
|
|
||
| import glob | ||
| import hashlib | ||
| import inspect | ||
| import json | ||
| import os | ||
| import shutil | ||
| import sys | ||
| import re | ||
|
|
||
| import setuptools.command.test | ||
|
|
@@ -109,7 +116,7 @@ def _log(self, level, msg, args): | |
| try: | ||
| return self._orig_log(self, level, newmsg, args) | ||
| except Exception: | ||
| print newmsg % args | ||
| print(newmsg % args) | ||
|
|
||
| log.Log = NewLog | ||
| log._global_log = NewLog() | ||
|
|
@@ -148,7 +155,7 @@ def _log(self, level, msg, args): | |
|
|
||
| RELOAD_VSC_MODS = False | ||
|
|
||
| VERSION = '0.10.32' | ||
| VERSION = '0.11.00' | ||
|
|
||
| log.info('This is (based on) vsc.install.shared_setup %s' % VERSION) | ||
|
|
||
|
|
@@ -361,13 +368,15 @@ def get_name_url(self, filename=None, version=None, license_name=None): | |
| if len(res) != 3: | ||
| raise Exception("Cannot determine name, url and download url from filename %s: got %s" % (filename, res)) | ||
| else: | ||
| keepers = {} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of curiosity, why is this modified?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous strategy was starting with a dictionary, res, and removing items from it as it was being iterated through. This triggers errors with testing, and generally isn't a good idea! To fix, I decided to add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify: this is required because in Python 3
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx! |
||
| for name, value in res.items(): | ||
| if value is None: | ||
| log.info('Removing None %s' % name) | ||
| res.pop(name) | ||
| else: | ||
| keepers[name] = value | ||
|
|
||
| log.info('get_name_url returns %s' % res) | ||
| return res | ||
| log.info('get_name_url returns %s' % keepers) | ||
| return keepers | ||
|
|
||
| def rel_gitignore(self, paths, base_dir=None): | ||
| """ | ||
|
|
@@ -1047,7 +1056,7 @@ def finalize_options(self): | |
|
|
||
| def _print(self, cmd): | ||
| """Print is evil, cmd is list""" | ||
| print ' '.join(cmd) | ||
| print(' '.join(cmd)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add the future print_function import to this module, since we're doing print here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, added to import! Please take a look and let me know if this is what you had in mind. And apologies for the delay - I was flying through the sky!! |
||
|
|
||
| def git_tag(self): | ||
| """Tag the version in git""" | ||
|
|
@@ -1182,8 +1191,12 @@ def sanitize(name): | |
| name starts with 'vsc' | ||
| and name does not start with python- | ||
| """ | ||
| if isinstance(name, basestring): | ||
|
|
||
| if isinstance(name, (list, tuple)): | ||
| klass = _fvs('sanitize') | ||
| return ",".join([klass.sanitize(r) for r in name]) | ||
|
|
||
| else: | ||
| if os.environ.get('VSC_RPM_PYTHON', 'NOT_ONE') == '1': | ||
| # hardcoded prefix map | ||
| for pydep, rpmname in PYTHON_BDIST_RPM_PREFIX_MAP.items(): | ||
|
|
@@ -1197,14 +1210,19 @@ def sanitize(name): | |
| if p_p: | ||
| name = 'python-%s' % name | ||
| return name | ||
| else: | ||
| klass = _fvs('sanitize') | ||
| return ",".join([klass.sanitize(r) for r in name]) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| @staticmethod | ||
| def get_md5sum(filename): | ||
| """Use this function to compute the md5sum in the KNOWN_LICENSES hash""" | ||
| return hashlib.md5(open(filename).read()).hexdigest() | ||
| hasher = hashlib.md5() | ||
| with open(filename, "rb") as fh: | ||
| for chunk in iter(lambda: fh.read(4096), b""): | ||
| hasher.update(chunk) | ||
| return hasher.hexdigest() | ||
|
|
||
|
|
||
| def get_license(self, license_name=None): | ||
| """ | ||
|
|
@@ -1254,11 +1272,15 @@ def parse_target(self, target, urltemplate=None): | |
|
|
||
| # update the cmdclass with ones from vsc_setup_klass | ||
| # cannot do this in one go, when SHARED_TARGET is defined, vsc_setup doesn't exist yet | ||
| for name, klass in new_target['cmdclass'].items(): | ||
| keepers = new_target['cmdclass'].copy() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of curiosity, why is this modified
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same issue is here as for the previous keepers - you can't iterate through a dictionary and change it at the same time.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The copy() creates a new copy in memory. If we didn't do that, we would just be pointing to the same dictionary.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: |
||
| for name in new_target['cmdclass']: | ||
| klass = new_target['cmdclass'][name] | ||
| try: | ||
| new_target['cmdclass'][name] = getattr(vsc_setup_klass, klass.__name__) | ||
| keepers[name] = getattr(vsc_setup_klass, klass.__name__) | ||
| except AttributeError: | ||
| del new_target['cmdclass'][name] | ||
| del keepers[name] | ||
| log.info("Not including new_target['cmdclass']['%s']" % name) | ||
| new_target['cmdclass'] = keepers | ||
|
|
||
| # prepare classifiers | ||
| classifiers = new_target.setdefault('classifiers', []) | ||
|
|
@@ -1385,7 +1407,7 @@ def parse_target(self, target, urltemplate=None): | |
| dep, depversion])] | ||
|
|
||
| log.debug("New target = %s" % (new_target)) | ||
| print new_target | ||
| print(new_target) | ||
| return new_target | ||
|
|
||
| @staticmethod | ||
|
|
@@ -1410,8 +1432,8 @@ def build_setup_cfg_for_bdist_rpm(target): | |
|
|
||
| try: | ||
| setup_cfg = open('setup.cfg', 'w') # and truncate | ||
| except (IOError, OSError), err: | ||
| print "Cannot create setup.cfg for target %s: %s" % (target['name'], err) | ||
| except (IOError, OSError) as err: | ||
| print("Cannot create setup.cfg for target %s: %s" % (target['name'], err)) | ||
| sys.exit(1) | ||
|
|
||
| klass = _fvs('build_setup_cfg_for_bdist_rpm') | ||
|
|
@@ -1481,7 +1503,6 @@ def action_target(self, target, setupfn=None, extra_sdist=None, urltemplate=None | |
|
|
||
| self.prepare_rpm(target) | ||
| x = self.parse_target(target, urltemplate) | ||
|
|
||
| setupfn(**x) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this removed? isn't adding the blacklist entry sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is being removed in favor of the blacklist entry, which is more specific for the intended bullitin:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this disables all redefined builtin errors. you should keep this one