Skip to content

create zip offline_requirements with proper name #165

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ docs/_build/
# PyBuilder
target/
.idea/

# pydev
.project
.pydevproject
.settings
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ coverage==4.0
Sphinx==1.3.1
cryptography==1.0.1
PyYAML==3.11

httpretty
freezegun
15 changes: 11 additions & 4 deletions shellfoundry/commands/dist_command.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@

import os

from shellfoundry.utilities.archive_creator import ArchiveCreator
from shellfoundry.utilities.python_dependencies_packager import PythonDependenciesPackager
from shellfoundry.utilities.shell_config_reader import ShellConfigReader


class DistCommandExecutor(object):
def __init__(self, dependencies_packager=None):
self.dependencies_packager = dependencies_packager or PythonDependenciesPackager()
self.config_reader = ShellConfigReader()

def dist(self):
current_path = os.getcwd()

requirements_path = os.path.join(current_path, 'src', 'requirements.txt')
dest_path = os.path.join(current_path, 'dist', 'offline_requirements')
current_path = os.getcwd()
dist_path = os.path.join(current_path, 'dist')
offline_requirements_path = os.path.join(dist_path, 'offline_requirements')
requirements_file_path = os.path.join(current_path, 'src', 'requirements.txt')
zip_file_path = os.path.join(dist_path, self.config_reader.read().name + '_offline_requirements.zip')

self.dependencies_packager.save_offline_dependencies(requirements_path, dest_path)
self.dependencies_packager.save_offline_dependencies(requirements_file_path, offline_requirements_path)
ArchiveCreator.make_archive(zip_file_path, 'zip', offline_requirements_path)
2 changes: 1 addition & 1 deletion shellfoundry/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.7'
__version__ = '0.2.8'
6 changes: 5 additions & 1 deletion tests/test_commands/test_dist_command.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

import os
from mock import Mock
from pyfakefs import fake_filesystem_unittest

from shellfoundry.commands.dist_command import DistCommandExecutor
from tests.asserts import *


class TestDistCommandExecutor(fake_filesystem_unittest.TestCase):
Expand Down Expand Up @@ -35,3 +36,6 @@ def test_dependencies_downloaded(self):
self.assertEqual(args[0].split(os.path.sep)[-2], 'src')
self.assertEqual(args[1].split(os.path.sep)[-1], 'offline_requirements')
self.assertEqual(args[1].split(os.path.sep)[-2], 'dist')

ls = os.listdir(os.path.dirname(args[1]))
self.assertEqual(ls[0], 'nut_shell_offline_requirements.zip')
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[tox]
envlist = py26, py27, py33, py34, py35
envlist = py27, py35

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/shellfoundry
commands = python setup.py test
deps = -rrequirements.txt
commands = py.test

; If you want to make tox run the tests with the same versions, create a
; requirements.txt with the pinned versions and uncomment the following lines:
Expand Down