Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
FRidh committed Dec 30, 2017
2 parents d2b02d6 + 9d4de1e commit 2d0bead
Show file tree
Hide file tree
Showing 73 changed files with 1,946 additions and 570 deletions.
2 changes: 2 additions & 0 deletions lib/maintainers.nix
Expand Up @@ -361,6 +361,7 @@
ldesgoui = "Lucas Desgouilles <ldesgoui@gmail.com>";
league = "Christopher League <league@contrapunctus.net>";
lebastr = "Alexander Lebedev <lebastr@gmail.com>";
ledif = "Adam Fidel <refuse@gmail.com>";
leemachin = "Lee Machin <me@mrl.ee>";
leenaars = "Michiel Leenaars <ml.software@leenaa.rs>";
leonardoce = "Leonardo Cecchi <leonardo.cecchi@gmail.com>";
Expand Down Expand Up @@ -451,6 +452,7 @@
mrVanDalo = "Ingolf Wanger <contact@ingolf-wagner.de>";
msackman = "Matthew Sackman <matthew@wellquite.org>";
mschristiansen = "Mikkel Christiansen <mikkel@rheosystems.com>";
mstarzyk = "Maciek Starzyk <mstarzyk@gmail.com>";
msteen = "Matthijs Steen <emailmatthijs@gmail.com>";
mt-caret = "Masayuki Takeda <mtakeda.enigsol@gmail.com>";
mtreskin = "Max Treskin <zerthurd@gmail.com>";
Expand Down
160 changes: 138 additions & 22 deletions maintainers/scripts/update-python-libraries
@@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p 'python3.withPackages(ps: with ps; [ requests toolz ])'
#! nix-shell -i python3 -p 'python3.withPackages(ps: with ps; [ packaging requests toolz ])' -p git

"""
Update a Python package expression by passing in the `.nix` file, or the directory containing it.
Expand All @@ -18,18 +18,43 @@ import os
import re
import requests
import toolz
from concurrent.futures import ThreadPoolExecutor as pool
from concurrent.futures import ThreadPoolExecutor as Pool
from packaging.version import Version as _Version
from packaging.version import InvalidVersion
from packaging.specifiers import SpecifierSet
import collections
import subprocess

INDEX = "https://pypi.io/pypi"
"""url of PyPI"""

EXTENSIONS = ['tar.gz', 'tar.bz2', 'tar', 'zip', '.whl']
"""Permitted file extensions. These are evaluated from left to right and the first occurance is returned."""

PRERELEASES = False

import logging
logging.basicConfig(level=logging.INFO)


class Version(_Version, collections.abc.Sequence):

def __init__(self, version):
super().__init__(version)
# We cannot use `str(Version(0.04.21))` because that becomes `0.4.21`
# https://github.com/avian2/unidecode/issues/13#issuecomment-354538882
self.raw_version = version

def __getitem__(self, i):
return self._version.release[i]

def __len__(self):
return len(self._version.release)

def __iter__(self):
yield from self._version.release


def _get_values(attribute, text):
"""Match attribute in text and return all matches.

Expand Down Expand Up @@ -82,13 +107,59 @@ def _fetch_page(url):
else:
raise ValueError("request for {} failed".format(url))

def _get_latest_version_pypi(package, extension):

SEMVER = {
'major' : 0,
'minor' : 1,
'patch' : 2,
}


def _determine_latest_version(current_version, target, versions):
"""Determine latest version, given `target`.
"""
current_version = Version(current_version)

def _parse_versions(versions):
for v in versions:
try:
yield Version(v)
except InvalidVersion:
pass

versions = _parse_versions(versions)

index = SEMVER[target]

ceiling = list(current_version[0:index])
if len(ceiling) == 0:
ceiling = None
else:
ceiling[-1]+=1
ceiling = Version(".".join(map(str, ceiling)))

# We do not want prereleases
versions = SpecifierSet(prereleases=PRERELEASES).filter(versions)

if ceiling is not None:
versions = SpecifierSet(f"<{ceiling}").filter(versions)

return (max(sorted(versions))).raw_version


def _get_latest_version_pypi(package, extension, current_version, target):
"""Get latest version and hash from PyPI."""
url = "{}/{}/json".format(INDEX, package)
json = _fetch_page(url)

version = json['info']['version']
for release in json['releases'][version]:
versions = json['releases'].keys()
version = _determine_latest_version(current_version, target, versions)

try:
releases = json['releases'][version]
except KeyError as e:
raise KeyError('Could not find version {} for {}'.format(version, package)) from e
for release in releases:
if release['filename'].endswith(extension):
# TODO: In case of wheel we need to do further checks!
sha256 = release['digests']['sha256']
Expand All @@ -98,7 +169,7 @@ def _get_latest_version_pypi(package, extension):
return version, sha256


def _get_latest_version_github(package, extension):
def _get_latest_version_github(package, extension, current_version, target):
raise ValueError("updating from GitHub is not yet supported.")


Expand Down Expand Up @@ -141,19 +212,21 @@ def _determine_extension(text, fetcher):
"""
if fetcher == 'fetchPypi':
try:
format = _get_unique_value('format', text)
src_format = _get_unique_value('format', text)
except ValueError as e:
format = None # format was not given
src_format = None # format was not given

try:
extension = _get_unique_value('extension', text)
except ValueError as e:
extension = None # extension was not given

if extension is None:
if format is None:
format = 'setuptools'
extension = FORMATS[format]
if src_format is None:
src_format = 'setuptools'
elif src_format == 'flit':
raise ValueError("Don't know how to update a Flit package.")
extension = FORMATS[src_format]

elif fetcher == 'fetchurl':
url = _get_unique_value('url', text)
Expand All @@ -167,9 +240,7 @@ def _determine_extension(text, fetcher):
return extension


def _update_package(path):


def _update_package(path, target):

# Read the expression
with open(path, 'r') as f:
Expand All @@ -186,11 +257,13 @@ def _update_package(path):

extension = _determine_extension(text, fetcher)

new_version, new_sha256 = _get_latest_version_pypi(pname, extension)
new_version, new_sha256 = FETCHERS[fetcher](pname, extension, version, target)

if new_version == version:
logging.info("Path {}: no update available for {}.".format(path, pname))
return False
elif new_version <= version:
raise ValueError("downgrade for {}.".format(pname))
if not new_sha256:
raise ValueError("no file available for {}.".format(pname))

Expand All @@ -202,10 +275,19 @@ def _update_package(path):

logging.info("Path {}: updated {} from {} to {}".format(path, pname, version, new_version))

return True
result = {
'path' : path,
'target': target,
'pname': pname,
'old_version' : version,
'new_version' : new_version,
#'fetcher' : fetcher,
}

return result

def _update(path):

def _update(path, target):

# We need to read and modify a Nix expression.
if os.path.isdir(path):
Expand All @@ -222,24 +304,58 @@ def _update(path):
return False

try:
return _update_package(path)
return _update_package(path, target)
except ValueError as e:
logging.warning("Path {}: {}".format(path, e))
return False


def _commit(path, pname, old_version, new_version, **kwargs):
"""Commit result.
"""

msg = f'python: {pname}: {old_version} -> {new_version}'

try:
subprocess.check_call(['git', 'add', path])
subprocess.check_call(['git', 'commit', '-m', msg])
except subprocess.CalledProcessError as e:
subprocess.check_call(['git', 'checkout', path])
raise subprocess.CalledProcessError(f'Could not commit {path}') from e

return True


def main():

parser = argparse.ArgumentParser()
parser.add_argument('package', type=str, nargs='+')
parser.add_argument('--target', type=str, choices=SEMVER.keys(), default='major')
parser.add_argument('--commit', action='store_true', help='Create a commit for each package update')

args = parser.parse_args()
target = args.target

packages = list(map(os.path.abspath, args.package))

logging.info("Updating packages...")

# Use threads to update packages concurrently
with Pool() as p:
results = list(p.map(lambda pkg: _update(pkg, target), packages))

logging.info("Finished updating packages.")

# Commits are created sequentially.
if args.commit:
logging.info("Committing updates...")
list(map(lambda x: _commit(**x), filter(bool, results)))
logging.info("Finished committing updates")

packages = map(os.path.abspath, args.package)
count = sum(map(bool, results))
logging.info("{} package(s) updated".format(count))

with pool() as p:
count = list(p.map(_update, packages))

logging.info("{} package(s) updated".format(sum(count)))

if __name__ == '__main__':
main()
11 changes: 10 additions & 1 deletion nixos/modules/programs/tmux.nix
Expand Up @@ -151,6 +151,15 @@ in {
type = types.str;
description = "Set the $TERM variable.";
};

secureSocket = mkOption {
default = true;
type = types.bool;
description = ''
Store tmux socket under /run, which is more secure than /tmp, but as a
downside it doesn't survive user logout.
'';
};
};
};

Expand All @@ -163,7 +172,7 @@ in {
systemPackages = [ pkgs.tmux ];

variables = {
TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}'';
TMUX_TMPDIR = lib.optional cfg.secureSocket ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}'';
};
};
};
Expand Down
6 changes: 6 additions & 0 deletions pkgs/applications/editors/emacs-modes/melpa-packages.nix
Expand Up @@ -137,6 +137,12 @@ self:
# upstream issue: missing file header
maxframe = markBroken super.maxframe;

# version of magit-popup needs to match magit
# https://github.com/magit/magit/issues/3286
magit = super.magit.override {
inherit (self.melpaPackages) magit-popup;
};

# missing OCaml
merlin = markBroken super.merlin;

Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/graphics/feh/default.nix
Expand Up @@ -6,11 +6,11 @@ with stdenv.lib;

stdenv.mkDerivation rec {
name = "feh-${version}";
version = "2.22.2";
version = "2.23";

src = fetchurl {
url = "https://feh.finalrewind.org/${name}.tar.bz2";
sha256 = "1kcflv4jb4250g94nqn28i98xqvvci8w7vqpfr62gxlp16z1za05";
sha256 = "18922zv8ckm82r1ap1yn7plbk6djpj02za2ahng58sjj2fw3rpqn";
};

outputs = [ "out" "man" "doc" ];
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/graphics/leocad/default.nix
Expand Up @@ -7,13 +7,13 @@ set the variable LEOCAD_LIB=/path/to/libs/ or use option -l /path/to/libs/

stdenv.mkDerivation rec {
name = "leocad-${version}";
version = "17.02";
version = "17.07";

src = fetchFromGitHub {
owner = "leozide";
repo = "leocad";
rev = "v${version}";
sha256 = "0d7l2il6r4swnmrmaf1bsrgpjgai5xwhwk2mkpcsddnk59790mmc";
sha256 = "1j361pvxywi4nb2alhnnd4qpqrpg6503gbi17cadcdi434gbqbsd";
};

nativeBuildInputs = [ qmake4Hook ];
Expand All @@ -26,6 +26,6 @@ stdenv.mkDerivation rec {
description = "CAD program for creating virtual LEGO models";
homepage = http://www.leocad.org/;
license = licenses.gpl2;
inherit (qt4.meta) platforms;
platforms = platforms.linux;
};
}
32 changes: 32 additions & 0 deletions pkgs/applications/graphics/renderdoc/custom_swig.patch
@@ -0,0 +1,32 @@
diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt
index 2df9ffa5..66bafaba 100644
--- a/qrenderdoc/CMakeLists.txt
+++ b/qrenderdoc/CMakeLists.txt
@@ -65,16 +65,6 @@ include(ExternalProject)
# Need bison for swig
find_package(BISON)

-# Compile our custom SWIG that will do scoped/strong enum classes
-ExternalProject_Add(custom_swig
- # using an URL to a zip directly so we don't clone the history etc
- URL ${RENDERDOC_SWIG_PACKAGE}
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND ./autogen.sh > /dev/null 2>&1
- COMMAND CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ./configure --with-pcre=yes --prefix=${CMAKE_BINARY_DIR} > /dev/null
- BUILD_COMMAND $(MAKE) > /dev/null 2>&1
- INSTALL_COMMAND $(MAKE) install > /dev/null 2>&1)
-
# Lastly find PySide 2, optionally, for Qt5 Python bindings
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

@@ -186,9 +176,8 @@ foreach(in ${swig_interfaces})
get_filename_component(swig_file ${in} NAME_WE)

add_custom_command(OUTPUT ${swig_file}_python.cxx ${swig_file}.py
- COMMAND ${CMAKE_BINARY_DIR}/bin/swig -v -Wextra -Werror -O -c++ -python -modern -modernargs -enumclass -fastunpack -py3 -builtin -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/renderdoc/api/replay -outdir ${CMAKE_CURRENT_BINARY_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/${swig_file}_python.cxx ${CMAKE_CURRENT_SOURCE_DIR}/${in}
+ COMMAND $ENV{NIXOS_CUSTOM_SWIG} -v -Wextra -Werror -O -c++ -python -modern -modernargs -enumclass -fastunpack -py3 -builtin -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/renderdoc/api/replay -outdir ${CMAKE_CURRENT_BINARY_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/${swig_file}_python.cxx ${CMAKE_CURRENT_SOURCE_DIR}/${in}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${in}
- DEPENDS custom_swig
DEPENDS ${RDOC_REPLAY_FILES}
DEPENDS ${QRD_INTERFACE_FILES})

0 comments on commit 2d0bead

Please sign in to comment.