Skip to content

Commit 77b7fca

Browse files
committedMay 27, 2017
Merge remote-tracking branch 'upstream/master' into HEAD
2 parents 76a020e + 6b999f3 commit 77b7fca

File tree

146 files changed

+692
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+692
-556
lines changed
 

‎doc/languages-frameworks/python.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ nix-env -if build.nix
710710
```
711711
Now you can use the Python interpreter, as well as the extra packages that you added to the environment.
712712

713-
#### Environment defined in `~/.nixpkgs/config.nix`
713+
#### Environment defined in `~/.config/nixpkgs/config.nix`
714714

715715
If you prefer to, you could also add the environment as a package override to the Nixpkgs set.
716716
```nix

‎maintainers/scripts/update-python-libraries

+32-27
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ def _fetch_page(url):
6464
if r.status_code == requests.codes.ok:
6565
return r.json()
6666
else:
67-
logging.warning("Request for {} failed".format(url))
67+
raise ValueError("Request for {} failed".format(url))
6868

6969
def _get_latest_version(package, extension):
7070

7171

7272
url = "{}/{}/json".format(INDEX, package)
7373
json = _fetch_page(url)
7474

75-
data = extract_relevant_nix_data(json)[1]
75+
data = extract_relevant_nix_data(json, extension)[1]
7676

7777
version = data['latest_version']
7878
if version in data['versions']:
@@ -83,7 +83,7 @@ def _get_latest_version(package, extension):
8383
return version, sha256
8484

8585

86-
def extract_relevant_nix_data(json):
86+
def extract_relevant_nix_data(json, extension):
8787
"""Extract relevant Nix data from the JSON of a package obtained from PyPI.
8888

8989
:param json: JSON obtained from PyPI
@@ -124,11 +124,11 @@ def extract_relevant_nix_data(json):
124124
releases = toolz.itemfilter(lambda x: x[1] is not None, releases)
125125
return releases
126126

127-
# Collect data
127+
# Collect data)
128128
name = str(json['info']['name'])
129129
latest_version = str(_extract_latest_version(json))
130130
#src = _get_src_and_hash(json, latest_version, EXTENSIONS)
131-
sources = _get_sources(json, EXTENSIONS)
131+
sources = _get_sources(json, [extension])
132132

133133
# Collect meta data
134134
license = str(_extract_license(json))
@@ -188,7 +188,7 @@ def _update_package(path):
188188
except ValueError as e:
189189
# No format mentioned, then we assume we have setuptools
190190
# and use a .tar.gz
191-
logging.warning("Path {}: {}".format(path, str(e)))
191+
logging.info("Path {}: {}".format(path, str(e)))
192192
extension = ".tar.gz"
193193
else:
194194
if format == 'wheel':
@@ -197,33 +197,38 @@ def _update_package(path):
197197
try:
198198
url = _get_value('url', text)
199199
extension = os.path.splitext(url)[1]
200+
if 'pypi' not in url:
201+
logging.warning("Path {}: uses non-PyPI url, not updating.".format(path))
202+
return False
200203
except ValueError as e:
201-
logging.warning("Path {}: {}".format(path, str(e)))
204+
logging.info("Path {}: {}".format(path, str(e)))
202205
extension = ".tar.gz"
203206

204-
new_version, new_sha256 = _get_latest_version(pname, extension)
205-
if not new_sha256:
206-
logging.warning("Path has no valid file available: {}".format(path))
207-
return False
208-
209-
if new_version != version:
210-
211-
try:
212-
text = _replace_value('version', new_version, text)
213-
except ValueError as e:
214-
logging.warning("Path {}: {}".format(path, str(e)))
215-
try:
216-
text = _replace_value('sha256', new_sha256, text)
217-
except ValueError as e:
218-
logging.warning("Path {}: {}".format(path, str(e)))
207+
try:
208+
new_version, new_sha256 = _get_latest_version(pname, extension)
209+
except ValueError as e:
210+
logging.warning("Path {}: {}".format(path, str(e)))
211+
else:
212+
if not new_sha256:
213+
logging.warning("Path has no valid file available: {}".format(path))
214+
return False
215+
if new_version != version:
216+
try:
217+
text = _replace_value('version', new_version, text)
218+
except ValueError as e:
219+
logging.warning("Path {}: {}".format(path, str(e)))
220+
try:
221+
text = _replace_value('sha256', new_sha256, text)
222+
except ValueError as e:
223+
logging.warning("Path {}: {}".format(path, str(e)))
219224

220-
with open(path, 'w') as f:
221-
f.write(text)
225+
with open(path, 'w') as f:
226+
f.write(text)
222227

223-
logging.info("Updated {} from {} to {}".format(pname, version, new_version))
228+
logging.info("Updated {} from {} to {}".format(pname, version, new_version))
224229

225-
else:
226-
logging.info("No update available for {} at {}".format(pname, version))
230+
else:
231+
logging.info("No update available for {} at {}".format(pname, version))
227232

228233
return True
229234

0 commit comments

Comments
 (0)
Please sign in to comment.