diff --git a/HISTORY.rst b/HISTORY.rst index bcd6d31..e37d306 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ------- +1.1.1 (unreleased) +++++++++++++++++++ + +* Added support for pipenv + 1.1.0 (2019-03-05) ++++++++++++++++++ diff --git a/README.rst b/README.rst index 74590c9..4f24f53 100644 --- a/README.rst +++ b/README.rst @@ -99,6 +99,13 @@ as python executable, which is the standard virtualenv layout. Other installatio might work, but are not officially supported. +pipenv support +-------------- + +A limited / experimental support to ``pipenv`` is provided. + +Check documentation https://djangocms-installer.readthedocs.io/en/latest/usage.html#pipenv-support + Windows support --------------- diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 4b3d4c4..cf9dbe8 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -150,6 +150,12 @@ def parse(args): parser.add_argument('--utc', dest='utc', action='store_true', default=False, help='Use UTC timezone.') + parser.add_argument('--pipenv', dest='pipenv', + action='store', + default='', help='Use pipenv at given path to install dependencies.') + parser.add_argument('--pipenv-options', dest='pipenv_options', + action='store', + default='', help='Options passed to pipenv as is.') if '--utc' in args: for action in parser._positionals._actions: diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index 92088c1..f581f19 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -79,17 +79,24 @@ def check_install(config_data): raise EnvironmentError('\n'.join(errors)) -def requirements(req_file, pip_options='', is_file=False, verbose=False): +def requirements( + req_file, options='', is_file=False, verbose=False, pip_replacement=None +): args = ['install'] - if not verbose: + if not verbose and not pip_replacement: args.append('-q') - if pip_options: - args.extend([opt for opt in pip_options.split(' ') if opt]) + elif verbose and pip_replacement: + args.append('-v') + if options: + args.extend([opt for opt in options.split(' ') if opt]) if is_file: # pragma: no cover args += ['-r', req_file] else: args.extend(['{0}'.format(package) for package in req_file.split()]) - cmd = [sys.executable, '-mpip'] + args + if pip_replacement: + cmd = [pip_replacement] + args + else: + cmd = [sys.executable, '-mpip'] + args if verbose: sys.stdout.write('python path: {0}\n'.format(sys.executable)) sys.stdout.write('packages install command: {0}\n'.format(' '.join(cmd))) diff --git a/djangocms_installer/main.py b/djangocms_installer/main.py index d0dfdb8..38e549a 100644 --- a/djangocms_installer/main.py +++ b/djangocms_installer/main.py @@ -25,15 +25,21 @@ def execute(): 'If I am stuck for a long time, please check for connectivity / PyPi issues\n' ) if not config_data.no_deps: + if config_data.pipenv: + pip_replacement = config_data.pipenv + options = '--dev %s' % config_data.pipenv_options + else: + pip_replacement = None + options = config_data.pip_options if config_data.requirements_file: install.requirements( - config_data.requirements_file, config_data.pip_options, True, - verbose=config_data.verbose + config_data.requirements_file, options, True, + verbose=config_data.verbose, pip_replacement=pip_replacement ) else: install.requirements( - config_data.requirements, config_data.pip_options, - verbose=config_data.verbose + config_data.requirements, options, + verbose=config_data.verbose, pip_replacement=pip_replacement ) sys.stdout.write('Dependencies installed\nCreating the project\n') install.check_install(config_data) @@ -44,7 +50,10 @@ def execute(): django.setup_database(config_data) if config_data.starting_page: django.load_starting_page(config_data) - if not config_data.requirements_file: + if ( + not config_data.requirements_file and + not config_data.pipenv + ): install.write_requirements(config_data) if config_data.aldryn: # pragma: no cover sys.stdout.write('Project created!\n') diff --git a/docs/reference.rst b/docs/reference.rst index 8bbf9d6..7695391 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -88,6 +88,8 @@ advanced usage: * ``--skip-empty-check``, ``-s``: Skip the check if the project dir contains files or directory; in case of error when setting up the project the existing directory will be preserved. * ``--delete-project-dir``', ``-c``: Delete project directory on creation failure in :ref:`batch_mode`. +* ``--pipenv``': Full path to pipenv executable to use ``pipenv`` instead of pip for requirements installation, see :ref:`pipenv_support`. +* ``--pipenv-opts``': additional options (as a single string passed as is) passed to ``pipenv`` executable in the command line, see :ref:`pipenv_support`. diff --git a/docs/usage.rst b/docs/usage.rst index 02e0e8a..699522f 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -165,11 +165,35 @@ You can create the base project with a custom templateset by using the ``--templ Be aware that while **djangocms installer** will copy the files for you, it won't update the ``CMS_TEMPLATES`` settings parameter, so you'll need to modify that after installation. -.. _complete example: https://github.com/nephila/djangocms-installer/blob/develop/config.ini.sample - - Bare install ------------ -You can optionally install just Django and django CMS without any additiona plugin by using the +You can optionally install just Django and django CMS without any additional plugin by using the ``--no-plugins`` option; this will allow you to further customise your installation. + +.. _pipenv_support: + +pipenv support +-------------- + +Provided that you already have `pipenv`_ installed, you can use it to install the dependencies instead of plain pip +and generate a ``Pipfile`` and ``Pipfile.lock``. + +To run provide full path to ``pipenv`` executable via ``--pipenv`` argument. + +You can provide additional options via ``--pipenv-opts`` argument. + +You **must** create the pipenv virtualenv *before* running ``djangocms-installer`` and ``djangocms-installer`` must be installed within the ``pipenv`` virtualenv. + +The currently supported workflow is: + +.. code-block:: bash + + $ pipenv --three + $ pipenv install djangocms-installer + $ pipenv run djangocms mysite + +.. warning:: pipenv support is still experimental and **may** not work for all workflows + +.. _complete example: https://github.com/nephila/djangocms-installer/blob/develop/config.ini.sample +.. _pipenv: https://pipenv.readthedocs.io/en/latest/ diff --git a/tests/config.py b/tests/config.py index 0e1d3e1..9b6e0f0 100644 --- a/tests/config.py +++ b/tests/config.py @@ -874,6 +874,8 @@ class TestBaseConfig(unittest.TestCase): 'no_plugins': False, 'verbose': False, 'wizard': False, + 'pipenv': '', + 'pipenv_options': '', 'delete_project_dir': False, }) diff --git a/tests/django.py b/tests/django.py index c68a646..3da295a 100644 --- a/tests/django.py +++ b/tests/django.py @@ -339,7 +339,7 @@ def test_patch_django_20_develop(self): params = [ '--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, '--django-version=2.0', '-f', '--cms-version=develop', '--timezone=Europe/Moscow', - '-q', '-u', '-zno', '--i18n=no', '-p' + self.project_dir, + '--verbose', '-u', '-zno', '--i18n=no', '-p' + self.project_dir, 'example_path_20_develop_settings' ] config_data = config.parse(params) diff --git a/tests/fixtures/configs/config-01.ini b/tests/fixtures/configs/config-01.ini index 2b9b031..5043aa0 100644 --- a/tests/fixtures/configs/config-01.ini +++ b/tests/fixtures/configs/config-01.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-02.ini b/tests/fixtures/configs/config-02.ini index 50c2f2d..be7b67a 100644 --- a/tests/fixtures/configs/config-02.ini +++ b/tests/fixtures/configs/config-02.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-03.ini b/tests/fixtures/configs/config-03.ini index 7a9f836..c2b91ed 100644 --- a/tests/fixtures/configs/config-03.ini +++ b/tests/fixtures/configs/config-03.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-04.ini b/tests/fixtures/configs/config-04.ini index f200859..602e641 100644 --- a/tests/fixtures/configs/config-04.ini +++ b/tests/fixtures/configs/config-04.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-05.ini b/tests/fixtures/configs/config-05.ini index 643cc8b..7c59e45 100644 --- a/tests/fixtures/configs/config-05.ini +++ b/tests/fixtures/configs/config-05.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-06.ini b/tests/fixtures/configs/config-06.ini index 8817831..635585d 100644 --- a/tests/fixtures/configs/config-06.ini +++ b/tests/fixtures/configs/config-06.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-07.ini b/tests/fixtures/configs/config-07.ini index 9794f1e..aad333d 100644 --- a/tests/fixtures/configs/config-07.ini +++ b/tests/fixtures/configs/config-07.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-08.ini b/tests/fixtures/configs/config-08.ini index 2baa391..f8c3a07 100644 --- a/tests/fixtures/configs/config-08.ini +++ b/tests/fixtures/configs/config-08.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-09.ini b/tests/fixtures/configs/config-09.ini index 7f74462..c727cca 100644 --- a/tests/fixtures/configs/config-09.ini +++ b/tests/fixtures/configs/config-09.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-10.ini b/tests/fixtures/configs/config-10.ini index 1d50043..df89210 100644 --- a/tests/fixtures/configs/config-10.ini +++ b/tests/fixtures/configs/config-10.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-11.ini b/tests/fixtures/configs/config-11.ini index 1a829d7..217e466 100644 --- a/tests/fixtures/configs/config-11.ini +++ b/tests/fixtures/configs/config-11.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-12.ini b/tests/fixtures/configs/config-12.ini index 5db47f7..b7b9399 100644 --- a/tests/fixtures/configs/config-12.ini +++ b/tests/fixtures/configs/config-12.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-13.ini b/tests/fixtures/configs/config-13.ini index 830a926..f9df2a5 100644 --- a/tests/fixtures/configs/config-13.ini +++ b/tests/fixtures/configs/config-13.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-14.ini b/tests/fixtures/configs/config-14.ini index 68e29d5..f547a56 100644 --- a/tests/fixtures/configs/config-14.ini +++ b/tests/fixtures/configs/config-14.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-15.ini b/tests/fixtures/configs/config-15.ini index 29aa80c..e473e0c 100644 --- a/tests/fixtures/configs/config-15.ini +++ b/tests/fixtures/configs/config-15.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-16.ini b/tests/fixtures/configs/config-16.ini index d489d61..1656aca 100644 --- a/tests/fixtures/configs/config-16.ini +++ b/tests/fixtures/configs/config-16.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-17.ini b/tests/fixtures/configs/config-17.ini index 84dea64..4dfbaf4 100644 --- a/tests/fixtures/configs/config-17.ini +++ b/tests/fixtures/configs/config-17.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-18.ini b/tests/fixtures/configs/config-18.ini index 84dea64..4dfbaf4 100644 --- a/tests/fixtures/configs/config-18.ini +++ b/tests/fixtures/configs/config-18.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-19.ini b/tests/fixtures/configs/config-19.ini index 5dc7758..f71b341 100644 --- a/tests/fixtures/configs/config-19.ini +++ b/tests/fixtures/configs/config-19.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-20.ini b/tests/fixtures/configs/config-20.ini index f87bde3..f408179 100644 --- a/tests/fixtures/configs/config-20.ini +++ b/tests/fixtures/configs/config-20.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-21.ini b/tests/fixtures/configs/config-21.ini index a0cd16b..f2c5576 100644 --- a/tests/fixtures/configs/config-21.ini +++ b/tests/fixtures/configs/config-21.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-22.ini b/tests/fixtures/configs/config-22.ini index 55a2aa7..8b6216a 100644 --- a/tests/fixtures/configs/config-22.ini +++ b/tests/fixtures/configs/config-22.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-23.ini b/tests/fixtures/configs/config-23.ini index 15bb3d6..7002a86 100644 --- a/tests/fixtures/configs/config-23.ini +++ b/tests/fixtures/configs/config-23.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-24.ini b/tests/fixtures/configs/config-24.ini index 6946506..8a9cb20 100644 --- a/tests/fixtures/configs/config-24.ini +++ b/tests/fixtures/configs/config-24.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-25.ini b/tests/fixtures/configs/config-25.ini index a7cebd2..0943dc8 100644 --- a/tests/fixtures/configs/config-25.ini +++ b/tests/fixtures/configs/config-25.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-26.ini b/tests/fixtures/configs/config-26.ini index 1a87a91..65a2a0e 100644 --- a/tests/fixtures/configs/config-26.ini +++ b/tests/fixtures/configs/config-26.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-27.ini b/tests/fixtures/configs/config-27.ini index 079579f..9256859 100644 --- a/tests/fixtures/configs/config-27.ini +++ b/tests/fixtures/configs/config-27.ini @@ -29,3 +29,5 @@ no-plugins = false verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-28.ini b/tests/fixtures/configs/config-28.ini index 7d74058..a874ae2 100644 --- a/tests/fixtures/configs/config-28.ini +++ b/tests/fixtures/configs/config-28.ini @@ -29,3 +29,5 @@ no-plugins = true verbose = false wizard = false delete-project-dir = false +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-30.ini b/tests/fixtures/configs/config-30.ini index ea496a8..845eaac 100644 --- a/tests/fixtures/configs/config-30.ini +++ b/tests/fixtures/configs/config-30.ini @@ -29,4 +29,5 @@ no-plugins = true verbose = true wizard = false delete-project-dir = false - +pipenv = +pipenv-options = diff --git a/tests/fixtures/configs/config-32.ini b/tests/fixtures/configs/config-32.ini index 2a587d6..46b2edd 100644 --- a/tests/fixtures/configs/config-32.ini +++ b/tests/fixtures/configs/config-32.ini @@ -29,3 +29,5 @@ no-plugins = true verbose = true wizard = false delete-project-dir = true +pipenv = +pipenv-options =