Skip to content

Commit dfdf10d

Browse files
authored
Merge pull request #313 from BCG-Gamma/dev/1.2.5
BUILD: release pytools 1.2.5
2 parents c3da618 + 4089c21 commit dfdf10d

File tree

7 files changed

+148
-114
lines changed

7 files changed

+148
-114
lines changed

RELEASE_NOTES.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Release Notes
44
*pytools* 1.2
55
-------------
66

7+
1.2.5
8+
~~~~~
9+
10+
This is a maintenance release to catch up with *pytools* 1.1.10.
11+
12+
713
1.2.4
814
~~~~~
915

@@ -53,6 +59,20 @@ This is a maintenance release to catch up with *pytools* 1.1.4.
5359
*pytools* 1.1
5460
-------------
5561

62+
1.1.10
63+
~~~~~~
64+
65+
This release addresses additional issues in the release process, focusing on the
66+
`make_base.py` script for Sphinx builds used across *gamma-pytools*, *sklearndf*, and
67+
*gamma-facet*.
68+
69+
70+
1.1.9
71+
~~~~~
72+
73+
This is a bugfix release to restore the GitHub release process.
74+
75+
5676
1.1.8
5777
~~~~~
5878

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,9 @@ stages:
465465
set -eux
466466
echo "Getting version"
467467
pip install packaging~=20.9
468-
cd $(System.DefaultWorkingDirectory)/$(project_root)/src
468+
package_path=$(System.DefaultWorkingDirectory)/$(project_root)/src/$(project_name)
469469
export PYTHONPATH=$(System.DefaultWorkingDirectory)/pytools/sphinx/base
470-
version=$(python -c "import make_base; print(make_base.get_package_version())")
470+
version=$(python -c "import make_util; print(make_util.get_package_version(package_path='$package_path'))")
471471
echo "Current version: $version"
472472
echo "Detecting pre-release ('dev' or 'rc' in version)"
473473
prerelease=False
@@ -525,7 +525,7 @@ stages:
525525
)
526526
)
527527
inputs:
528-
gitHubConnection: github_release
528+
gitHubConnection: github-release
529529
repositoryName: $(Build.Repository.Name)
530530
action: create
531531
target: $(Build.SourceVersion)

make.py

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717

1818
import toml
1919

20-
CWD = os.getcwd()
2120
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
2221

22+
sys.path.insert(
23+
0,
24+
os.path.normpath(os.path.join(SCRIPT_DIR, "sphinx", "base")),
25+
)
26+
# noinspection PyUnresolvedReferences
27+
from make_util import get_package_version
28+
2329
FACET_PATH_ENV = "FACET_PATH"
2430
FACET_PATH_URI_ENV = "FACET_PATH_URI"
2531
FACET_BUILD_PKG_VERSION_ENV = "FACET_BUILD_{project}_VERSION"
@@ -77,30 +83,8 @@ def __init__(self, project: str, dependency_type: str) -> None:
7783

7884
project_root_path = os.path.abspath(os.path.join(projects_root_path, project))
7985
src_root_path = os.path.join(project_root_path, "src", project)
80-
init_path = os.path.join(src_root_path, "__init__.py")
81-
82-
print(f"Retrieving package version from {init_path}")
83-
84-
with open(init_path, "rt") as init_file:
85-
init_lines = init_file.readlines()
8686

87-
matches = {
88-
match[1] or match[2]
89-
for match in (RE_VERSION_DECLARATION.match(line) for line in init_lines)
90-
if match
91-
}
92-
93-
if len(matches) == 0:
94-
raise RuntimeError(f"No valid __version__ declaration found in {init_path}")
95-
96-
elif len(matches) > 1:
97-
raise RuntimeError(
98-
f"Multiple conflicting __version__ declarations found in {init_path}: "
99-
f"{matches}"
100-
)
101-
102-
else:
103-
package_version = next(iter(matches))
87+
package_version = str(get_package_version(package_path=src_root_path))
10488

10589
os.environ[
10690
FACET_BUILD_PKG_VERSION_ENV.format(project=project.upper())
@@ -154,7 +138,7 @@ def get_pyproject_toml(self) -> Dict[str, Any]:
154138
pyproject_toml_path = os.path.join(
155139
os.environ[FACET_PATH_ENV], self.project, "pyproject.toml"
156140
)
157-
print(f"Reading build configuration from {pyproject_toml_path}")
141+
log(f"Reading build configuration from {pyproject_toml_path}")
158142
with open(pyproject_toml_path, "rt") as f:
159143
return toml.load(f)
160144

@@ -251,7 +235,7 @@ def get_matrix_dependencies(matrix_type: str) -> Dict[str, str]:
251235
for package, version in requirements_to_expose.items():
252236
# bash ENV variables can not use dash, replace it to _
253237
env_var_name = "FACET_V_" + re.sub(r"[^\w]", "_", package.upper())
254-
print(f"Exporting {env_var_name}={version !r}")
238+
log(f"Exporting {env_var_name}={version !r}")
255239
os.environ[env_var_name] = version
256240

257241
@abstractmethod
@@ -266,7 +250,7 @@ def print_build_info(self, stage: str) -> None:
266250
f"VERSION {self.package_version}"
267251
)
268252
separator = "=" * len(message)
269-
print(f"{separator}\n{message}\n{separator}")
253+
log(f"{separator}\n{message}\n{separator}")
270254

271255
@abstractmethod
272256
def build(self) -> None:
@@ -321,7 +305,7 @@ def clean(self) -> None:
321305
# purge pre-existing build directories
322306
package_dist_name = self.get_package_dist_name()
323307
for obsolete_folder in glob(os.path.join(build_path, f"{package_dist_name}_*")):
324-
print(f"Clean: Removing obsolete conda-build folder at: {obsolete_folder}")
308+
log(f"Clean: Removing obsolete conda-build folder at: {obsolete_folder}")
325309
shutil.rmtree(obsolete_folder, ignore_errors=True)
326310

327311
# remove broken packages
@@ -341,7 +325,7 @@ def build(self) -> None:
341325

342326
os.makedirs(build_path, exist_ok=True)
343327
build_cmd = f"conda-build -c conda-forge -c bcg_gamma {recipe_path}"
344-
print(
328+
log(
345329
f"Building: {self.project}\n"
346330
f"Build path: {build_path}\n"
347331
f"Build Command: {build_cmd}"
@@ -384,9 +368,9 @@ def build(self) -> None:
384368
os.chdir(build_path)
385369

386370
build_cmd = f"tox -e {tox_env} -v"
387-
print(f"Build Command: {build_cmd}")
371+
log(f"Build Command: {build_cmd}")
388372
subprocess.run(args=build_cmd, shell=True, check=True)
389-
print("Tox build completed – creating local PyPi index")
373+
log("Tox build completed – creating local PyPi index")
390374

391375
# Create/update a local PyPI PEP 503 (the simple repository API) compliant
392376
# folder structure, so that it can be used with PIP's --extra-index-url
@@ -418,7 +402,7 @@ def build(self) -> None:
418402
with open(project_index_html_path, "wt") as f:
419403
f.writelines(package_file_links)
420404

421-
print(f"Local PyPi Index created at: {pypi_index_path}")
405+
log(f"Local PyPi Index created at: {pypi_index_path}")
422406

423407
finally:
424408
os.chdir(original_dir)
@@ -471,6 +455,15 @@ def print_usage() -> None:
471455
print(usage)
472456

473457

458+
def log(message: str) -> None:
459+
"""
460+
Write a message to `stderr`.
461+
462+
:param message: the message to write
463+
"""
464+
print(message, file=sys.stderr)
465+
466+
474467
def run_make() -> None:
475468
"""
476469
Run this build script with the given arguments.
@@ -495,7 +488,7 @@ def run_make() -> None:
495488
):
496489

497490
if arg_value not in valid_values:
498-
print(
491+
log(
499492
f"Wrong value for {arg_name} argument: "
500493
f"got {arg_value} but expected one of {', '.join(valid_values)}"
501494
)

sphinx/base/conf_base.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,22 @@ def set_config(
4545
Add required modules to the python path, and set custom configuration options
4646
"""
4747

48+
from make_util import get_package_version
49+
4850
globals_["project"] = project
51+
globals_["version"] = str(
52+
get_package_version(
53+
package_path=(
54+
os.path.join(os.getcwd(), os.pardir, os.pardir, "src", project)
55+
)
56+
)
57+
)
4958

5059
if html_logo:
5160
globals_["html_logo"] = html_logo
5261
globals_["latex_logo"] = html_logo
5362

54-
modules = set(modules) | {"pytools"}
63+
modules = {"pytools", *modules}
5564
for module in modules:
5665
module_path = os.path.normpath(os.path.join(_dir_repo_root, module, "src"))
5766
if module_path not in sys.path:
@@ -73,8 +82,8 @@ def set_config(
7382

7483
# -- Project information -----------------------------------------------------
7584

76-
project = "pytools"
77-
copyright = "2021, Boston Consulting Group (BCG)"
85+
# noinspection PyShadowingBuiltins
86+
copyright = "2022, Boston Consulting Group (BCG)"
7887
author = "FACET Team"
7988

8089
# -- General configuration ---------------------------------------------------
@@ -177,31 +186,13 @@ def set_config(
177186
# Class documentation to include docstrings both global to the class, and from __init__
178187
autoclass_content = "both"
179188

180-
181-
def _get_package_version() -> str:
182-
"""
183-
Get the package version for the project being built.
184-
:return: string with Python package version
185-
"""
186-
# NOTE: sphinx-make changes the CWD into sphinx/source
187-
# while FACET's make_base expects a CWD <project>/src
188-
# hence: save current CWD, navigate to <project>/src, then go back
189-
cwd = os.getcwd()
190-
os.chdir(os.path.join(cwd, os.pardir, os.pardir, "src"))
191-
import make_base
192-
193-
version_ = str(make_base.get_package_version())
194-
os.chdir(cwd)
195-
return version_
196-
197-
198-
version = _get_package_version()
199189
# -- End of options section ------------------------------------------------------------
200190

201191

202192
def setup(app: Sphinx) -> None:
203193
"""
204-
Add event handlers to the Sphinx application object
194+
Add event handlers to the Sphinx application object.
195+
205196
:param app: the Sphinx application object
206197
"""
207198

0 commit comments

Comments
 (0)