Skip to content

Commit

Permalink
Merge pull request #53 from andrew-hossack/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
andrew-hossack authored Aug 12, 2022
2 parents 5dff88c + d2469fc commit 1c97de0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
20 changes: 11 additions & 9 deletions dashtools/deploy/fileUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import subprocess
from typing import Union
from pipreqs import pipreqs


def check_file_exists(root_path: os.PathLike, file_name: str) -> bool:
Expand Down Expand Up @@ -39,18 +40,19 @@ def create_requirements_txt(root_path: os.PathLike, destination: os.PathLike = N
update: Optional boolean to update existing requirements.txt
"""
print(
f'dashtools: {"Updating" if update else "Creating"} requirements.txt')
f'dashtools: {"Found requirements.txt. Updating" if update else "Creating requirements.txt"} to {root_path}...')
try:
optional_path = f" --savepath {os.path.join(destination, 'requirements.txt')}" if destination else ""
args = {'<path>': root_path, '--encoding': 'utf8', '--pypi-server': None, '--proxy': None, '--proxy-auth': None,
'--proxy-type': None, '--requirement': None, '--requirements': None, '--version': None, '--use-local': None, '--savepath': None, '--diff': None, '--clean': None, '--print': None, '--force': None, '--mode': None}
args['--savepath'] = os.path.join(destination,
'requirements.txt') if destination else None
if update:
subprocess.check_output(
f'pipreqs --encoding=utf8 --force {root_path}{optional_path}', shell=True)
args['--force'] = True
pipreqs.init(args)
else:
subprocess.check_output(
f'pipreqs --encoding=utf8 {root_path}{optional_path}', shell=True)
except subprocess.CalledProcessError as e:
# pipreqs throws a SyntaxError if it encounters a non-ASCII character
# One reason may be that the user is not in a valid dash app directory
pipreqs.init(args)
except Exception as e:
# Catch any pipreqs exceiptions
print(e)
print('dashtools: Error creating requirements.txt')
print('dashtools: Are you in a valid dash app directory?')
Expand Down
2 changes: 1 addition & 1 deletion dashtools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.8.1'
__version__ = '1.8.2'
12 changes: 12 additions & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file.

## [1.8.2] - 2022-08-12

### Fixed

- Pipreqs generating requirements.txt does not work on some systems. Fixed with calling pipreqs.init(args) directly.

## [1.8.1] - 2022-08-12

### Changed

- Print out error message for pipreqs errors

## [1.8.0] - 2022-08-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/source/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Version in this file must match version for dashtools/version.py!

__version__ = '1.8.1'
__version__ = '1.8.2'

0 comments on commit 1c97de0

Please sign in to comment.