iker-python-setup 1.0.4__tar.gz → 1.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/.github/workflows/pr.yml +18 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/.github/workflows/push.yml +1 -1
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/PKG-INFO +3 -2
- iker_python_setup-1.0.6/README.md +93 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/pyproject.toml +2 -1
- iker_python_setup-1.0.6/src/iker/setup/__init__.py +110 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/PKG-INFO +3 -2
- iker_python_setup-1.0.4/README.md +0 -25
- iker_python_setup-1.0.4/src/iker/setup/__init__.py +0 -91
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/.editorconfig +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/.gitignore +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/MANIFEST.in +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/VERSION +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/setup.cfg +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/setup.py +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/SOURCES.txt +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/dependency_links.txt +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/not-zip-safe +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/requires.txt +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/top_level.txt +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/test/iker_tests/__init__.py +0 -0
- {iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/test/iker_tests/iker_test.py +0 -0
|
@@ -43,3 +43,21 @@ jobs:
|
|
|
43
43
|
python -m pip install --upgrade pip
|
|
44
44
|
python -m pip install .[test]
|
|
45
45
|
python -m pytest . --cov --cov-config pyproject.toml
|
|
46
|
+
|
|
47
|
+
build-python313:
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
steps:
|
|
50
|
+
- name: Setup Python
|
|
51
|
+
uses: actions/setup-python@v5
|
|
52
|
+
with:
|
|
53
|
+
python-version: "3.13"
|
|
54
|
+
|
|
55
|
+
- name: Checkout
|
|
56
|
+
uses: actions/checkout@v4
|
|
57
|
+
|
|
58
|
+
- name: Build and Test
|
|
59
|
+
run: |
|
|
60
|
+
sudo apt-get install libxml2-dev libxslt1-dev llvm-14-dev
|
|
61
|
+
python -m pip install --upgrade pip
|
|
62
|
+
python -m pip install .[test]
|
|
63
|
+
python -m pytest . --cov --cov-config pyproject.toml
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: iker-python-setup
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Classifier: Programming Language :: Python :: 3
|
|
5
5
|
Classifier: Programming Language :: Python :: 3.11
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.12
|
|
7
|
-
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
8
|
+
Requires-Python: <3.14,>=3.11
|
|
8
9
|
Requires-Dist: setuptools>=75.0
|
|
9
10
|
Requires-Dist: setuptools-scm>=8.0
|
|
10
11
|
Provides-Extra: test
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Iker's Python Setup Module
|
|
2
|
+
|
|
3
|
+
SCM/CI environment settings aware setup tool for Iker's Python projects
|
|
4
|
+
|
|
5
|
+
The Python package naming and versioning should comply with the [PEP 440](https://peps.python.org/pep-0440) and
|
|
6
|
+
[PEP 517](https://peps.python.org/pep-0517/) standards to ensure compatibility with the Python Package Index, as well as
|
|
7
|
+
various build front-ends and back-ends. Additionally, we aim to manage version updates using both the SCM and CI
|
|
8
|
+
systems, enabling for example automatic patch increments based on SCM branch information, CI build numbers, or release
|
|
9
|
+
tags.
|
|
10
|
+
|
|
11
|
+
To achieve this, we can utilize SCM branch information alongside CI-generated data injected into the build environment.
|
|
12
|
+
This approach requires the build process to dynamically determine the version string, taking into account both the local
|
|
13
|
+
version configuration (e.g., major and minor version numbers) and the CI runtime environment.
|
|
14
|
+
|
|
15
|
+
This package offers the necessary build tools to fulfill these requirements.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
To use this tool for managing the versioning of your Python package, follow these steps:
|
|
20
|
+
|
|
21
|
+
1. **Create a `VERSION` file** that maintains the major and minor version numbers. For example:
|
|
22
|
+
```
|
|
23
|
+
1.0
|
|
24
|
+
```
|
|
25
|
+
2. **Modify the `pyproject.toml` file** as follows:
|
|
26
|
+
```toml
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = [
|
|
29
|
+
"setuptools>=68.0",
|
|
30
|
+
"setuptools-scm>=8.0",
|
|
31
|
+
"iker-python-setup>=1.0" # This is required
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project]
|
|
35
|
+
dynamic = ["version"] # This is required
|
|
36
|
+
```
|
|
37
|
+
3. **Use this tool in your `setup.py` script**:
|
|
38
|
+
```python
|
|
39
|
+
from iker.setup import setup
|
|
40
|
+
|
|
41
|
+
setup()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Behaviors
|
|
45
|
+
|
|
46
|
+
The major and minor version numbers are read from the `VERSION` file located in the project’s root directory, while the
|
|
47
|
+
patch version number is sourced from the `BUILD_NUMBER` environment variable. These can be configured via the
|
|
48
|
+
`version_file` and `patch_env_var` parameters of the `setup` function. In a CI environment, the `patch_env_var` can be
|
|
49
|
+
set by the CI system.
|
|
50
|
+
|
|
51
|
+
For SCM settings, if the code is on the specified "base" branch, no additional segments will be appended to the version
|
|
52
|
+
string. Otherwise, a 12-character digest of the current commit will be appended to the version string. Additionally, if
|
|
53
|
+
there are uncommitted changes in the workspace, a `dirty` label will also be added, resulting in a final version string
|
|
54
|
+
format like `{major}.{minor}.{patch}+{digest}.dirty`.
|
|
55
|
+
|
|
56
|
+
An alternative approach for detecting the "base" branch is to use an environment variable specified by
|
|
57
|
+
`scm_branch_env_var`, which defaults to `GIT_BRANCH`. The "base" branch name, defaulting to `master`, is also
|
|
58
|
+
configurable.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from iker.setup import setup
|
|
62
|
+
|
|
63
|
+
setup(
|
|
64
|
+
version_file="MY_VERSION",
|
|
65
|
+
patch_env_var="MY_ENV_VAR",
|
|
66
|
+
scm_branch_name="main",
|
|
67
|
+
scm_branch_env_var="MY_SCM_BRANCH"
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Build and Deploy
|
|
72
|
+
|
|
73
|
+
### Using Conda
|
|
74
|
+
|
|
75
|
+
We recommend using Conda. You need to install Anaconda packages from
|
|
76
|
+
the [official site](https://www.anaconda.com/products/distribution)
|
|
77
|
+
|
|
78
|
+
Create a Conda environment and install the modules and their dependencies in it
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
conda create -n iker python=3.12
|
|
82
|
+
conda activate iker
|
|
83
|
+
|
|
84
|
+
pip install .
|
|
85
|
+
|
|
86
|
+
conda deactivate
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
To remove the existing Conda environment (and create a brand new one)
|
|
90
|
+
|
|
91
|
+
```shell
|
|
92
|
+
conda env remove -n iker
|
|
93
|
+
```
|
|
@@ -8,11 +8,12 @@ build-backend = "setuptools.build_meta"
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "iker-python-setup"
|
|
10
10
|
dynamic = ["version"]
|
|
11
|
-
requires-python = ">=3.11,<3.
|
|
11
|
+
requires-python = ">=3.11,<3.14"
|
|
12
12
|
classifiers = [
|
|
13
13
|
"Programming Language :: Python :: 3",
|
|
14
14
|
"Programming Language :: Python :: 3.11",
|
|
15
15
|
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Programming Language :: Python :: 3.13",
|
|
16
17
|
]
|
|
17
18
|
dependencies = [
|
|
18
19
|
"setuptools>=75.0",
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import importlib.metadata
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
__version__ = importlib.metadata.version("iker-python-setup")
|
|
6
|
+
except importlib.metadata.PackageNotFoundError:
|
|
7
|
+
__version__ = "unknown"
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"version_string_local",
|
|
11
|
+
"version_string_scm",
|
|
12
|
+
"version_string",
|
|
13
|
+
"setup",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def read_version_tuple(cwd: str | None, *, version_file: str, patch_env_var: str) -> tuple[int, int, int]:
|
|
18
|
+
if cwd is None:
|
|
19
|
+
cwd = os.getcwd()
|
|
20
|
+
|
|
21
|
+
with open(os.path.join(cwd, version_file)) as fh:
|
|
22
|
+
major_str, minor_str, *patch_strs = fh.read().strip().split(".")
|
|
23
|
+
|
|
24
|
+
major = max(0, int(major_str))
|
|
25
|
+
minor = max(0, int(minor_str))
|
|
26
|
+
|
|
27
|
+
patch_str = patch_strs[0] if len(patch_strs) > 0 else os.getenv(patch_env_var)
|
|
28
|
+
patch = 0 if patch_str is None else min(999999, max(0, int(patch_str)))
|
|
29
|
+
|
|
30
|
+
return major, minor, patch
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def version_string_local(cwd: str | None,
|
|
34
|
+
*,
|
|
35
|
+
version_file: str,
|
|
36
|
+
patch_env_var: str) -> str:
|
|
37
|
+
major, minor, patch = read_version_tuple(cwd, version_file=version_file, patch_env_var=patch_env_var)
|
|
38
|
+
return f"{major}.{minor}.{patch}"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def version_string_scm(cwd: str | None,
|
|
42
|
+
*,
|
|
43
|
+
version_file: str,
|
|
44
|
+
patch_env_var: str,
|
|
45
|
+
scm_branch_name: str,
|
|
46
|
+
scm_branch_env_var: str) -> str:
|
|
47
|
+
from setuptools_scm import ScmVersion
|
|
48
|
+
from setuptools_scm import get_version
|
|
49
|
+
if cwd is None:
|
|
50
|
+
cwd = os.getcwd()
|
|
51
|
+
|
|
52
|
+
def find_scm_root(cd: str) -> str:
|
|
53
|
+
cd = os.path.abspath(cd)
|
|
54
|
+
for item in os.listdir(cd):
|
|
55
|
+
if os.path.isdir(os.path.join(cd, item)) and item == ".git":
|
|
56
|
+
return cd
|
|
57
|
+
pd = os.path.dirname(cd)
|
|
58
|
+
if pd == cd:
|
|
59
|
+
raise ValueError("Cannot find SCM root properly")
|
|
60
|
+
return find_scm_root(pd)
|
|
61
|
+
|
|
62
|
+
def version_scheme_callback(scm_version: ScmVersion) -> str:
|
|
63
|
+
major, minor, patch = read_version_tuple(cwd, version_file=version_file, patch_env_var=patch_env_var)
|
|
64
|
+
if scm_version.branch == scm_branch_name or os.getenv(scm_branch_env_var) == scm_branch_name:
|
|
65
|
+
return f"{major}.{minor}.{patch}"
|
|
66
|
+
return f"{major}.{minor}.{0}"
|
|
67
|
+
|
|
68
|
+
def local_scheme_callback(scm_version: ScmVersion) -> str:
|
|
69
|
+
if scm_version.branch == scm_branch_name or os.getenv(scm_branch_env_var) == scm_branch_name:
|
|
70
|
+
return ""
|
|
71
|
+
if scm_version.dirty:
|
|
72
|
+
return scm_version.format_with("+{node}.dirty")
|
|
73
|
+
return scm_version.format_with("+{node}")
|
|
74
|
+
|
|
75
|
+
return get_version(root=find_scm_root(cwd),
|
|
76
|
+
version_scheme=version_scheme_callback,
|
|
77
|
+
local_scheme=local_scheme_callback,
|
|
78
|
+
normalize=True)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def version_string(cwd: str | None = None,
|
|
82
|
+
default: str = "0.0.0",
|
|
83
|
+
*,
|
|
84
|
+
version_file: str = "VERSION",
|
|
85
|
+
patch_env_var: str = "BUILD_NUMBER",
|
|
86
|
+
scm_branch_name: str = "master",
|
|
87
|
+
scm_branch_env_var: str = "GIT_BRANCH",
|
|
88
|
+
strict: bool = False) -> str:
|
|
89
|
+
try:
|
|
90
|
+
return version_string_scm(cwd,
|
|
91
|
+
version_file=version_file,
|
|
92
|
+
patch_env_var=patch_env_var,
|
|
93
|
+
scm_branch_name=scm_branch_name,
|
|
94
|
+
scm_branch_env_var=scm_branch_env_var)
|
|
95
|
+
except Exception as e:
|
|
96
|
+
if strict:
|
|
97
|
+
raise e
|
|
98
|
+
try:
|
|
99
|
+
return version_string_local(cwd,
|
|
100
|
+
version_file=version_file,
|
|
101
|
+
patch_env_var=patch_env_var)
|
|
102
|
+
except Exception as e:
|
|
103
|
+
if strict:
|
|
104
|
+
raise e
|
|
105
|
+
return default
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def setup(cwd: str | None = None, **kwargs):
|
|
109
|
+
from setuptools import setup
|
|
110
|
+
setup(version=version_string(cwd, **kwargs), **kwargs)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: iker-python-setup
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Classifier: Programming Language :: Python :: 3
|
|
5
5
|
Classifier: Programming Language :: Python :: 3.11
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.12
|
|
7
|
-
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
8
|
+
Requires-Python: <3.14,>=3.11
|
|
8
9
|
Requires-Dist: setuptools>=75.0
|
|
9
10
|
Requires-Dist: setuptools-scm>=8.0
|
|
10
11
|
Provides-Extra: test
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Iker's Python Setup Module
|
|
2
|
-
|
|
3
|
-
## Build and Deploy
|
|
4
|
-
|
|
5
|
-
### Using Conda
|
|
6
|
-
|
|
7
|
-
We recommend using Conda. You need to install Anaconda packages from
|
|
8
|
-
the [official site](https://www.anaconda.com/products/distribution)
|
|
9
|
-
|
|
10
|
-
Create a Conda environment and install the modules and their dependencies in it
|
|
11
|
-
|
|
12
|
-
```shell
|
|
13
|
-
conda create -n iker python=3.12
|
|
14
|
-
conda activate iker
|
|
15
|
-
|
|
16
|
-
pip install .
|
|
17
|
-
|
|
18
|
-
conda deactivate
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
To remove the existing Conda environment (and create a brand new one)
|
|
22
|
-
|
|
23
|
-
```shell
|
|
24
|
-
conda env remove -n iker
|
|
25
|
-
```
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import importlib.metadata
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
__version__ = importlib.metadata.version("iker-python-setup")
|
|
6
|
-
except importlib.metadata.PackageNotFoundError:
|
|
7
|
-
__version__ = "unknown"
|
|
8
|
-
|
|
9
|
-
__all__ = [
|
|
10
|
-
"version_string_local",
|
|
11
|
-
"version_string_scm",
|
|
12
|
-
"version_string",
|
|
13
|
-
"setup",
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def read_version_tuple(cwd: str | None = None,
|
|
18
|
-
*,
|
|
19
|
-
default: (int, int, int) = (0, 0, 0),
|
|
20
|
-
version_file: str = "VERSION",
|
|
21
|
-
patch_env_var: str = "BUILD_NUMBER",
|
|
22
|
-
strict: bool = False) -> (int, int, int):
|
|
23
|
-
if cwd is None:
|
|
24
|
-
cwd = os.getcwd()
|
|
25
|
-
try:
|
|
26
|
-
with open(os.path.join(cwd, version_file)) as fh:
|
|
27
|
-
major_str, minor_str, *patch_strs = fh.read().strip().split(".")
|
|
28
|
-
|
|
29
|
-
major = max(0, int(major_str))
|
|
30
|
-
minor = max(0, int(minor_str))
|
|
31
|
-
|
|
32
|
-
patch_str = patch_strs[0] if len(patch_strs) > 0 else os.getenv(patch_env_var)
|
|
33
|
-
patch = 0 if patch_str is None else min(999999, max(0, int(patch_str)))
|
|
34
|
-
|
|
35
|
-
return major, minor, patch
|
|
36
|
-
except Exception as e:
|
|
37
|
-
if strict:
|
|
38
|
-
raise e
|
|
39
|
-
return default
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def version_string_local(cwd: str | None = None) -> str:
|
|
43
|
-
major, minor, patch = read_version_tuple(cwd, strict=True)
|
|
44
|
-
return f"{major}.{minor}.{patch}"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def version_string_scm(cwd: str | None = None) -> str:
|
|
48
|
-
from setuptools_scm import ScmVersion
|
|
49
|
-
from setuptools_scm import get_version
|
|
50
|
-
if cwd is None:
|
|
51
|
-
cwd = os.getcwd()
|
|
52
|
-
|
|
53
|
-
def find_scm_root(cd: str) -> str:
|
|
54
|
-
cd = os.path.abspath(cd)
|
|
55
|
-
for item in os.listdir(cd):
|
|
56
|
-
if os.path.isdir(os.path.join(cd, item)) and item == ".git":
|
|
57
|
-
return cd
|
|
58
|
-
pd = os.path.dirname(cd)
|
|
59
|
-
if pd == cd:
|
|
60
|
-
raise ValueError("Cannot find SCM root properly")
|
|
61
|
-
return find_scm_root(pd)
|
|
62
|
-
|
|
63
|
-
def version_scheme_callback(scm_version: ScmVersion) -> str:
|
|
64
|
-
major, minor, patch = read_version_tuple(cwd, strict=True)
|
|
65
|
-
if scm_version.branch == "master" or os.getenv("GIT_BRANCH", "") == "master":
|
|
66
|
-
return f"{major}.{minor}.{patch}"
|
|
67
|
-
return f"{major}.{minor}.{0}"
|
|
68
|
-
|
|
69
|
-
def local_scheme_callback(scm_version: ScmVersion) -> str:
|
|
70
|
-
if scm_version.branch == "master" or os.getenv("GIT_BRANCH", "") == "master":
|
|
71
|
-
return ""
|
|
72
|
-
if scm_version.dirty:
|
|
73
|
-
return scm_version.format_with("+{node}.dirty")
|
|
74
|
-
return scm_version.format_with("+{node}")
|
|
75
|
-
|
|
76
|
-
return get_version(root=find_scm_root(cwd),
|
|
77
|
-
version_scheme=version_scheme_callback,
|
|
78
|
-
local_scheme=local_scheme_callback,
|
|
79
|
-
normalize=True)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def version_string(cwd: str | None = None):
|
|
83
|
-
try:
|
|
84
|
-
return version_string_scm(cwd)
|
|
85
|
-
except Exception:
|
|
86
|
-
return version_string_local(cwd)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def setup():
|
|
90
|
-
from setuptools import setup
|
|
91
|
-
setup(version=version_string())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/requires.txt
RENAMED
|
File without changes
|
{iker_python_setup-1.0.4 → iker_python_setup-1.0.6}/src/iker_python_setup.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|