Skip to content

Commit

Permalink
Fix bad support of extras
Browse files Browse the repository at this point in the history
Fix #15
  • Loading branch information
Gaetan Semet committed Aug 1, 2019
1 parent 5fc1e82 commit 1148187
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 51 deletions.
6 changes: 0 additions & 6 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[isort]
line_length = 100
known_future_library = future
known_standard_library = pathlib2,glob2
known_twisted =
twisted,
klein
Expand All @@ -22,11 +21,6 @@ sections =
TWISTED,
FIRSTPARTY,
LOCALFOLDER
add_imports =
from __future__ import absolute_import,
from __future__ import division,
from __future__ import print_function,
from __future__ import unicode_literals,
min-similarity-lines=5
ignore-comments=yes
ignore-docstrings=yes
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python:
- 3.6

install:
- rm -f .python-version
- make ensure-pip-ci
- make dev-ci

Expand Down
43 changes: 20 additions & 23 deletions pipenv_to_requirements/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import argparse
import sys
Expand Down Expand Up @@ -41,19 +37,23 @@ def clean_version(pkg_name, pkg_info):
git = pkg_info.get("git", "").strip()
path = pkg_info.get("path", "").strip()
ref = pkg_info.get("ref", "").strip()
rstr = ""
if not editable:
rstr += pkg_name

if extras:
rstr += "[{}]".format(', '.join([s.strip() for s in extras]))

if not editable:
rstr = pkg_name
if version and version != "*":
rstr += version
rstr += version.strip()
elif git:
ref = "@" + ref if ref else ref
rstr = "-e git+" + git + ref + "#egg=" + pkg_name
if subdir:
rstr += '&subdirectory=' + subdir
else:
rstr = "-e " + path
if extras:
rstr += "[{}]".format(', '.join([s.strip() for s in extras]))
if markers:
rstr += " ; " + markers
return rstr
Expand All @@ -65,21 +65,18 @@ def parse_pip_file(pipfile, section):

def parse_args():
parser = argparse.ArgumentParser(description='Generate requirements*.txt matching Pipfile*')
parser.add_argument(
'-o',
'--output',
help=('Generate only the main packages to a different file, '
'instead of requirements.txt'))
parser.add_argument(
'-d',
'--dev-output',
help=('Generate only dev packages to a different file, '
'instead of requirements-dev.txt'))
parser.add_argument(
'-f',
'--freeze',
action="store_true",
help='Generate requirements*.txt with frozen versions')
parser.add_argument('-o',
'--output',
help=('Generate only the main packages to a different file, '
'instead of requirements.txt'))
parser.add_argument('-d',
'--dev-output',
help=('Generate only dev packages to a different file, '
'instead of requirements-dev.txt'))
parser.add_argument('-f',
'--freeze',
action="store_true",
help='Generate requirements*.txt with frozen versions')

args = parser.parse_args()
return args
Expand Down
5 changes: 1 addition & 4 deletions pipenv_to_requirements/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# -*- coding: utf-8 -*-

import os

Expand Down
16 changes: 12 additions & 4 deletions pipenv_to_requirements/test_parsing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import json
import os
Expand Down Expand Up @@ -64,3 +60,15 @@ def test_markers(self):

expected_requirements_dev = self.load_requirements("Pipfile.markers.requirements-dev.txt")
assert sorted(requirements_dev) == sorted(expected_requirements_dev)

def test_extras(self):
pipfile_json = self.load_vector_pipfile("Pipfile.extras")

requirements = pipenv_to_requirements.parse_pip_file(pipfile_json, "default")
requirements_dev = pipenv_to_requirements.parse_pip_file(pipfile_json, "develop")

expected_requirements = self.load_requirements("Pipfile.extras.requirements.txt")
assert sorted(requirements) == sorted(expected_requirements)

expected_requirements_dev = self.load_requirements("Pipfile.extras.requirements-dev.txt")
assert sorted(requirements_dev) == sorted(expected_requirements_dev)
22 changes: 22 additions & 0 deletions pipenv_to_requirements/vectors/Pipfile.extras
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true


[dev-packages]

"flake8" = ">=3.4"
pycodestyle = ">=2.0"
pyflakes = "<1.6.0,>=1.5.0"
pylint = ">=1.7"
yapf = ">=0.18"
cryptography = ">=1.4"
pyyaml = ">=3.11"
tox = "*"


[packages]
pbr = ">=3.0"
pipenv = "*"
requests = {version = "==2.9.1", extras = ["security"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cryptography>=1.4
flake8>=3.4
pycodestyle>=2.0
pyflakes<1.6.0,>=1.5.0
pylint>=1.7
pyyaml>=3.11
tox
yapf>=0.18
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pbr>=3.0
pipenv
requests[security]==2.9.1
16 changes: 2 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# -*- coding: utf-8 -*-

import setuptools

# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass

setuptools.setup(setup_requires=['pbr'],
pbr=True)
setuptools.setup(setup_requires=['pbr'], pbr=True)

0 comments on commit 1148187

Please sign in to comment.