Skip to content

Commit c15c275

Browse files
committed
New distribution [0.5.3]
* bugfix in Python <3.6 * revised 3rdparty dependencies
1 parent c30e1c6 commit c15c275

11 files changed

Lines changed: 35 additions & 57 deletions

File tree

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# basic info
22
FROM library/ubuntu
3-
LABEL version 0.5.2
4-
LABEL description "Ubuntu Environment"
3+
LABEL version 0.5.3
4+
LABEL description "Ubuntu Environment for F2FORMAT"
55

66
# prepare environment
77
ENV LANG "C.UTF-8"
@@ -10,13 +10,16 @@ ENV PYTHONIOENCODING "UTF-8"
1010

1111
# install packages
1212
RUN apt-get update \
13-
&& apt-get install --yes python3 python3-distutils \
13+
&& apt-get install --yes --no-install-recommends \
14+
python3 \
15+
python3-distutils \
1416
&& rm -rf /var/lib/apt/lists/*
1517

1618
# copy source
17-
COPY . /f2format
18-
RUN cd /f2format \
19-
&& python3 /f2format/setup.py install
19+
COPY . /tmp/f2format
20+
RUN cd /tmp/f2format \
21+
&& python3 /f2format/setup.py install \
22+
&& rm -rf /tmp/f2fomat
2023

2124
# cleanup
2225
RUN apt-get remove python3-distutils --yes \

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ setup-formula: pipenv
3636

3737
# update Python stdlib files
3838
setup-stdlib:
39-
rm -f src/lib/token.py src/lib/tokenize.py
40-
mkdir -p src/lib
41-
cp -f $(token) $(tokenize) src/lib/
39+
rm -f src/token.py src/tokenize.py
40+
cp -f $(token) $(tokenize) src
4241

4342
# update manpages
4443
setup-manpages:
@@ -97,7 +96,14 @@ docker-build: docker-prep
9796
docker build --tag f2format:$(version) --tag f2format:latest release
9897

9998
# make PyPI distribution
100-
dist-pypi: clean-pypi dist-macos dist-linux
99+
#dist-pypi: clean-pypi dist-macos dist-linux
100+
dist-pypi: clean-pypi dist-pypi-setup
101+
102+
.ONESHELL:
103+
dist-pypi-setup:
104+
set -ex
105+
cd $(DIR)
106+
python3 setup.py sdist bdist_wheel
101107

102108
.ONESHELL:
103109
dist-macos:
@@ -113,8 +119,7 @@ dist-macos:
113119
dist-linux:
114120
set -ex
115121
cd $(DIR)/docker
116-
sed "s/LABEL version.*/LABEL version $(shell date +%Y.%m.%d)/" Dockerfile > Dockerfile.tmp
117-
mv Dockerfile.tmp Dockerfile
122+
sed -i "s/LABEL version.*/LABEL version $(shell date +%Y.%m.%d)/" Dockerfile
118123
docker-compose up --build
119124

120125
# upload PyPI distribution
@@ -166,7 +171,7 @@ release:
166171
# run distribution process
167172
dist:
168173
$(MAKE) message="$(message)" \
169-
setup clean pypi git-tag \
174+
setup clean pypi \
170175
git-upload release setup-formula
171176
$(MAKE) message="f2format: $(version)" DIR=Tap \
172177
git-upload

Pipfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
"pathlib2" = ">=2.3.2"
87
parso = "~=0.4.0"
98
tbtrim = ">=0.2.1"
109

1110
[dev-packages]
1211
f2format = {editable = true,path = "."}
13-
"autopep8" = "*"
14-
isort = {extras = ["pipfile", "requirements"],version = "*"}
1512
ipython = "*"
1613
homebrew-pypi-poet = "*"
1714
requests = "*"
18-
docutils = "*"
1915

2016
[requires]
2117
python_version = "3.7"

docs/f2format.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ f2format
66
back-port compiler for Python 3.6 f-string literals
77
---------------------------------------------------
88

9-
:Version: v0.5.2
10-
:Date: April 07, 2019
9+
:Version: v0.5.3
10+
:Date: April 17, 2019
1111
:Manual section: 1
1212
:Author:
1313
Jarry Shaw, a newbie programmer, is the author, owner and maintainer

man/f2format.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH F2FORMAT 1 "April 07, 2019" "v0.5.2" ""
3+
.TH F2FORMAT 1 "April 17, 2019" "v0.5.3" ""
44
.SH NAME
55
f2format \- back-port compiler for Python 3.6 f-string literals
66
.

setup-formula.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
# print(F2FORMAT_URL)
2222
# print(F2FORMAT_SHA)
2323

24-
PATHLIB2 = subprocess.check_output(['poet', 'pathlib2']).decode().strip()
2524
PARSO = subprocess.check_output(['poet', 'parso']).decode().strip()
2625
TBTRIM = subprocess.check_output(['poet', 'tbtrim']).decode().strip()
27-
# print(PATHLIB2)
2826
# print(PARSO)
2927
# print(TBTRIM)
3028

@@ -43,26 +41,10 @@ class F2format < Formula
4341
4442
{PARSO}
4543
46-
{PATHLIB2}
47-
4844
{TBTRIM}
4945
5046
def install
51-
# virtualenv_install_with_resources
52-
venv = virtualenv_create(libexec, "python3")
53-
54-
%w[parso tbtrim].each do |r|
55-
venv.pip_install resource(r)
56-
end
57-
58-
version = Language::Python.major_minor_version "python3"
59-
if version =~ /3.[34]/
60-
%w[pathlib2 six].each do |r|
61-
venv.pip_install resource(r)
62-
end
63-
end
64-
venv.pip_install_and_link buildpath
65-
47+
virtualenv_install_with_resources
6648
man1.install "man/f2format.1"
6749
bash_completion.install "comp/f2format.bash-completion"
6850
end

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
long_desc = file.read()
1414

1515
# version string
16-
__version__ = '0.5.2'
16+
__version__ = '0.5.3'
1717

1818
# set-up script for pip distribution
1919
setup(
@@ -34,9 +34,6 @@
3434
'parso~=0.4.0', # universal AST support
3535
'tbtrim>=0.2.1', # traceback trim support
3636
],
37-
extras_require={
38-
':python_version < "3.5"': ['pathlib2>=2.3.2'],
39-
},
4037
py_modules=['f2format'],
4138
packages=['f2format'],
4239
entry_points={

src/__main__.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@
2424
mp = multiprocessing
2525
del multiprocessing
2626

27-
# backport compatibility
28-
if sys.version_info[:2] < (3, 5):
29-
import pathlib2 as pathlib
30-
else:
31-
import pathlib
32-
3327
# version string
34-
__version__ = '0.5.2'
28+
__version__ = '0.5.3'
3529

3630
# macros
3731
__cwd__ = os.getcwd()
@@ -61,7 +55,7 @@ def get_parser():
6155
default=__f2format_version__, choices=PARSO_VERSION,
6256
help='convert against Python version (%s)' % __f2format_version__)
6357

64-
parser.add_argument('file', nargs='*', metavar='SOURCE', default=__cwd__,
58+
parser.add_argument('file', nargs='+', metavar='SOURCE', default=__cwd__,
6559
help='python source files and folders to be converted (%s)' % __cwd__)
6660

6761
return parser
@@ -99,15 +93,15 @@ def rename(path):
9993

10094
# make archive directory
10195
if archive:
102-
pathlib.Path(ARCHIVE).mkdir(parents=True, exist_ok=True)
96+
os.makedirs(ARCHIVE, exist_ok=True)
10397

10498
# fetch file list
10599
filelist = list()
106100
for path in sys.argv[1:]:
107101
if os.path.isfile(path):
108102
if archive:
109103
dest = rename(path)
110-
pathlib.Path(dest).parent.mkdir(parents=True, exist_ok=True)
104+
os.makedirs(os.path.dirname(dest), exist_ok=True)
111105
shutil.copy(path, dest)
112106
filelist.append(path)
113107
if os.path.isdir(path):
@@ -117,14 +111,14 @@ def rename(path):
117111

118112
# check if file is Python source code
119113
def ispy(file): return (os.path.isfile(file) and (os.path.splitext(file)[1] in ('.py', '.pyw')))
120-
filelist = set(filter(ispy, filelist))
114+
filelist = sorted(filter(ispy, filelist))
121115

122116
# if no file supplied
123117
if len(filelist) == 0:
124118
parser.error('argument PATH: no valid source file found')
125119

126120
# process files
127-
if mp is None:
121+
if mp is None or CPU_CNT <= 1:
128122
[f2format(filename) for filename in filelist]
129123
else:
130124
mp.Pool(processes=CPU_CNT).map(f2format, filelist)

src/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
###############################################################################
44
import os # noqa
55
import sys # noqa
6-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib')) # noqa
6+
sys.path.insert(0, os.path.dirname(__file__)) # noqa
77
###############################################################################
88

99
import collections.abc
@@ -16,6 +16,7 @@
1616

1717
###############################################################################
1818
sys.path.pop(0)
19+
del sys
1920
###############################################################################
2021

2122
__all__ = ['f2format', 'convert', 'ConvertError']
@@ -197,7 +198,7 @@ def f2format(filename):
197198
print('Now converting %r...' % filename)
198199

199200
# fetch encoding
200-
encoding = os.getenv('F2FORMAT_ENCODING', locale.getpreferredencoding())
201+
encoding = os.getenv('F2FORMAT_ENCODING', LOCALE_ENCODING)
201202

202203
lineno = dict() # line number -> file offset
203204
content = list() # file content
File renamed without changes.

0 commit comments

Comments
 (0)