Skip to content

Commit 6059727

Browse files
authored
Support Python 3.7 (#111)
* Support Python 3.7 * fix * skip
1 parent 89314fb commit 6059727

File tree

23 files changed

+82
-41
lines changed

23 files changed

+82
-41
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu-latest, windows-latest, macos-latest]
27-
python-version: ['3.8', '3.9', '3.10']
27+
python-version: ['3.7', '3.8', '3.9', '3.10']
2828

2929
steps:
3030
- uses: actions/checkout@v2
@@ -55,7 +55,7 @@ jobs:
5555
strategy:
5656
fail-fast: false
5757
matrix:
58-
python-version: ['2.7', '3.8']
58+
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10']
5959

6060
steps:
6161
- uses: actions/checkout@v2

docs/meta/history.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
### Unreleased
1212

13+
***Added:***
14+
15+
- Support Python 3.7
16+
1317
### [1.0.0rc7](https://github.com/ofek/hatch/releases/tag/hatch-v1.0.0rc7) - 2022-01-08 ### {: #hatch-v1.0.0rc7 }
1418

1519
***Added:***

hatch.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ full = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=hatch
1313
dev = "pytest --no-cov"
1414

1515
[[envs.test.matrix]]
16-
python = ["38", "39", "310"]
16+
python = ["37", "38", "39", "310"]
1717

1818
[envs.lint]
1919
skip-install = true

hatch/cli/terminal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def initialize_styles(self, styles: dict): # no cov
3636

3737
for option, style in styles.items():
3838
attribute = f'_style_level_{option}'
39-
if default_level := getattr(self, attribute, None):
39+
40+
default_level = getattr(self, attribute, None)
41+
if default_level:
4042
try:
4143
style = Style.parse(style)
4244
except StyleSyntaxError as e: # no cov

hatch/project/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ def from_config(cls, config: RootConfig, project: str) -> Project | None:
6060
return None
6161

6262
if project in config.projects:
63-
if location := config.projects[project].location:
63+
location = config.projects[project].location
64+
if location:
6465
return cls(Path(location).resolve(), name=project)
6566
else:
6667
for project_dir in config.dirs.project:
6768
if not project_dir:
6869
continue
6970

70-
if (location := Path(project_dir, project)).is_dir():
71+
location = Path(project_dir, project)
72+
if location.is_dir():
7173
return cls(Path(location).resolve(), name=project)
7274

7375
def find_project_root(self) -> Path | None:

hatch/publish/pypi.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ def publish(self, artifacts: list, options: dict):
141141
sha256_hash = hashlib.sha256()
142142
blake2_256_hash = hashlib.blake2b(digest_size=32)
143143

144-
while chunk := f.read(io.DEFAULT_BUFFER_SIZE):
144+
while True:
145+
chunk = f.read(io.DEFAULT_BUFFER_SIZE)
146+
if not chunk:
147+
break
148+
145149
md5_hash.update(chunk)
146150
sha256_hash.update(chunk)
147151
blake2_256_hash.update(chunk)
@@ -202,9 +206,10 @@ def get_wheel_form_data(app, artifact):
202206

203207
with zipfile.ZipFile(str(artifact), 'r') as zip_archive:
204208
dist_info_dir = ''
205-
for path in zipfile.Path(zip_archive).iterdir():
206-
if path.name.endswith('.dist-info'):
207-
dist_info_dir = path.name
209+
for path in zip_archive.namelist():
210+
root = path.split('/', 1)[0]
211+
if root.endswith('.dist-info'):
212+
dist_info_dir = root
208213
break
209214
else: # no cov
210215
app.abort(f'Could not find the `.dist-info` directory in wheel: {artifact}')

hatch/template/files_default.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PyProject(File):
7070
name = "{project_name_normalized}"
7171
description = {description!r}
7272
readme = "{readme_file_path}"
73-
requires-python = ">=3.8"
73+
requires-python = ">=3.7"
7474
license = "{license_expression}"{license_files}
7575
keywords = []
7676
authors = [
@@ -79,6 +79,7 @@ class PyProject(File):
7979
classifiers = [
8080
"Development Status :: 4 - Beta",
8181
"Programming Language :: Python",
82+
"Programming Language :: Python :: 3.7",
8283
"Programming Language :: Python :: 3.8",
8384
"Programming Language :: Python :: 3.9",
8485
"Programming Language :: Python :: 3.10",
@@ -142,7 +143,7 @@ def __init__(self, template_config: dict, plugin_config: dict):
142143
no-cov = "cov --no-cov"
143144
144145
[[tool.hatch.envs.test.matrix]]
145-
python = ["38", "39", "310"]
146+
python = ["37", "38", "39", "310"]
146147
147148
[tool.coverage.run]
148149
branch = true

hatch/template/files_feature_ci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CommandLinePackage(File):
2828
fail-fast: false
2929
matrix:
3030
os: [ubuntu-latest, windows-latest, macos-latest]
31-
python-version: ['3.8', '3.9', '3.10']
31+
python-version: ['3.7', '3.8', '3.9', '3.10']
3232
3333
steps:
3434
- uses: actions/checkout@v2

hatch/utils/fs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def as_cwd(self, *args, **kwargs) -> Generator[Path, None, None]:
5252
@contextmanager
5353
def temp_hide(self) -> Generator[Path, None, None]:
5454
with temp_directory() as temp_dir:
55+
temp_path = Path(temp_dir, self.name)
5556
try:
56-
temp_path = self.replace(temp_dir / self.name)
57+
self.replace(temp_dir / self.name)
5758
except FileNotFoundError:
58-
temp_path = Path(temp_dir, self.name)
59+
pass
5960

6061
try:
6162
yield temp_path

hatch/utils/platform.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ def join_command_args(self):
141141
if self.windows:
142142
self.__join_command_args = self._subprocess.list2cmdline
143143
else:
144-
self.__join_command_args = self._shlex.join
144+
try:
145+
self.__join_command_args = self._shlex.join
146+
except AttributeError:
147+
self.__join_command_args = lambda command_args: ' '.join(map(self._shlex.quote, command_args))
145148

146149
return self.__join_command_args
147150

0 commit comments

Comments
 (0)