Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
in generated files display which pypi2nix and exact command ...
Browse files Browse the repository at this point in the history
... was used to generate nix expressions

also all TODOs were moved into github issue tracker
  • Loading branch information
garbas committed Jun 28, 2016
1 parent 367bdb6 commit 339aee3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion default.nix
Expand Up @@ -4,7 +4,7 @@

let
deps = import ./src/pypi2nix/deps.nix { inherit fetchurl; };
version = builtins.readFile ./VERSION;
version = builtins.readFile ./src/pypi2nix/VERSION;
in stdenv.mkDerivation rec {
name = "pypi2nix-${version}";
srcs = with deps; [ src pip click setuptools zcbuildout zcrecipeegg ]; # six attrs effect ];
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions src/pypi2nix/cli.py
Expand Up @@ -99,12 +99,10 @@ def main(nix_path,
if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir)

# TODO: create requirements.txt from buildout.cfg
if buildout:
raise click.exceptions.ClickException(
u'Not yet implemented!')

# TODO: create requirements.txt from SPECIFICATION
elif specification:
raise click.exceptions.ClickException(
u'Not yet implemented!')
Expand Down
1 change: 0 additions & 1 deletion src/pypi2nix/stage1.py
Expand Up @@ -48,7 +48,6 @@ def main(requirements_file,
returncode = pypi2nix.utils.cmd(command)
if returncode != 0:
raise click.ClickException(
# TODO: better error
u'While trying to run the command something went wrong.')

return glob.glob(os.path.join(wheelhouse_dir, '*.dist-info'))
29 changes: 22 additions & 7 deletions src/pypi2nix/stage3.py
@@ -1,7 +1,13 @@
import sys
import os
import click

DEFAULT_NIX = '''

DEFAULT_NIX = '''# generated using pypi2nix tool (version: %(version)s)
#
# COMMAND:
# pypi2nix %(command_arguments)s
#
{ pkgs ? import <nixpkgs> {}
}:
Expand Down Expand Up @@ -36,7 +42,12 @@
in python
'''

GENERATED_NIX = '''
GENERATED_NIX = '''# generated using pypi2nix tool (version: %s)
#
# COMMAND:
# pypi2nix %s
#
{ pkgs, python, commonBuildInputs ? [], commonDoCheck ? false }:
self: {
Expand Down Expand Up @@ -72,7 +83,6 @@


def find_license(item):
# TODO: get license also from classifiers
license = item.get('license')
if license == 'ZPL 2.1':
license = "lib.zpt21"
Expand Down Expand Up @@ -104,6 +114,10 @@ def main(packages_metadata,
generated_file = os.path.join(project_folder, '{}_generated.nix'.format(requirements_name))
overrides_file = os.path.join(project_folder, '{}_override.nix'.format(requirements_name))

version_file = os.path.join(os.path.dirname(__file__), 'VERSION')
with open(version_file) as f:
version = f.read()

metadata_by_name = {x['name'].lower(): x for x in packages_metadata}

generated_packages_metadata = []
Expand All @@ -118,7 +132,6 @@ def main(packages_metadata,
generated_packages_metadata.append(dict(
name=item.get("name", ""),
version=item.get("version", ""),
# TODO: handle other formats (eg. wheel/egg)
url=item.get("url", ""),
hash_type="md5",
hash_value=item.get("md5", ""),
Expand All @@ -128,13 +141,15 @@ def main(packages_metadata,
description=item.get("description", ""),
))

generated = GENERATED_NIX % '\n\n'.join(
GENERATED_PACKAGE_NIX % x for x in generated_packages_metadata)
generated = GENERATED_NIX % (
version, ' '.join(sys.argv[1:]), '\n\n'.join(
GENERATED_PACKAGE_NIX % x for x in generated_packages_metadata))

# TODO: include known overrides
overrides = OVERRIDES_NIX % ""

default = DEFAULT_NIX % dict(
version=version,
command_arguments=' '.join(sys.argv[1:]),
python_version=python_version,
extra_build_inputs=extra_build_inputs
and "with pkgs; [ %s ]" % (' '.join(extra_build_inputs))
Expand Down

0 comments on commit 339aee3

Please sign in to comment.