Browse Source

deploy-ng: Support generating a requirements.txt file via pipenv

Mitchell Stokes 7 years ago
parent
commit
2486b12a14
1 changed files with 10 additions and 0 deletions
  1. 10 0
      direct/src/showutil/dist.py

+ 10 - 0
direct/src/showutil/dist.py

@@ -264,6 +264,16 @@ class build_apps(setuptools.Command):
             elif num_gui_apps == 1:
             elif num_gui_apps == 1:
                 self.macos_main_app = list(self.gui_apps.keys())[0]
                 self.macos_main_app = list(self.gui_apps.keys())[0]
 
 
+        use_pipenv = (
+            'Pipfile' in os.path.basename(self.requirements_path) or
+            not os.path.exists(self.requirements_path) and os.path.exists('Pipfile')
+        )
+        if use_pipenv:
+            reqspath = os.path.join(self.build_base, 'requirements.txt')
+            with open(reqspath, 'w') as reqsfile:
+                subprocess.check_call(['pipenv', 'lock', '--requirements'], stdout=reqsfile)
+            self.requirements_path = reqspath
+
         assert os.path.exists(self.requirements_path), 'Requirements.txt path does not exist: {}'.format(self.requirements_path)
         assert os.path.exists(self.requirements_path), 'Requirements.txt path does not exist: {}'.format(self.requirements_path)
         assert num_gui_apps + num_console_apps != 0, 'Must specify at least one app in either gui_apps or console_apps'
         assert num_gui_apps + num_console_apps != 0, 'Must specify at least one app in either gui_apps or console_apps'