-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e609ede
commit fa3737e
Showing
4 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ dist/ | |
*.pyc | ||
.idea/ | ||
*.egg-info | ||
venv/ | ||
venv/ | ||
attachment_downloader/version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
|
||
VERSION_FILENAME = os.path.abspath(os.path.join(os.path.dirname(__file__), 'version.py')) | ||
import subprocess | ||
|
||
|
||
class Version: | ||
@staticmethod | ||
def generate(): | ||
process = subprocess.Popen(["git", "describe", "--always", "--tags"], stdout=subprocess.PIPE, stderr=None) | ||
last_tag = process.communicate()[0].decode('ascii').strip() | ||
version = last_tag.split('-g')[0].replace('-', '.') if '-g' in last_tag else last_tag | ||
with open(VERSION_FILENAME, 'w') as f: | ||
f.write(f'ATTACHMENT_DOWNLOADER_VERSION = "{version}"\n') | ||
return version | ||
|
||
@staticmethod | ||
def get(retry=True): | ||
try: | ||
from attachment_downloader.version import ATTACHMENT_DOWNLOADER_VERSION | ||
return ATTACHMENT_DOWNLOADER_VERSION | ||
except ModuleNotFoundError as e: | ||
if retry: | ||
Version.generate() | ||
return Version.get(False) | ||
return 'unknown' | ||
except ImportError as e: | ||
if retry: | ||
Version.generate() | ||
return Version.get(False) | ||
return 'unknown' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
from setuptools import setup | ||
import os | ||
|
||
from setuptools import setup, find_packages | ||
|
||
from attachment_downloader.version_info import Version | ||
|
||
Version.generate() | ||
|
||
with open(os.path.abspath(os.path.join(os.path.dirname(__file__), 'requirements.txt'))) as f: | ||
install_reqs = f.read().splitlines() | ||
|
||
setup( | ||
name='attachment-downloader', | ||
version='1.1.7', | ||
version=Version.get(), | ||
description='Simple tool for downloading email attachments for all emails in a given folder using an IMAP client.', | ||
long_description=open('README.rst').read(), | ||
author='James Ridgway', | ||
url='https://github.com/jamesridgway/attachment-downloader', | ||
license='MIT', | ||
packages=['attachment_downloader'], | ||
packages=find_packages(), | ||
scripts=['bin/attachment-downloader'], | ||
install_requires=["jinja2", "imbox", "python-dateutil"] | ||
install_requires=install_reqs | ||
) |