python-flask-dev 0.0.1__tar.gz → 0.0.7__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.
Files changed (23) hide show
  1. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/PKG-INFO +7 -6
  2. python_flask_dev-0.0.7/pyproject.toml +33 -0
  3. python_flask_dev-0.0.7/src/python_flask_dev/importing_modules.py +44 -0
  4. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev.egg-info/PKG-INFO +7 -6
  5. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev.egg-info/SOURCES.txt +1 -3
  6. python_flask_dev-0.0.1/pyproject.toml +0 -35
  7. python_flask_dev-0.0.1/src/python_flask_dev/importing_modules.py +0 -64
  8. python_flask_dev-0.0.1/src/python_flask_dev/packaging/__init__.py +0 -0
  9. python_flask_dev-0.0.1/src/python_flask_dev/packaging/incremental_versioning.py +0 -107
  10. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/README.md +0 -0
  11. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/setup.cfg +0 -0
  12. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/__init__.py +0 -0
  13. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/app.py +0 -0
  14. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/data/__init__.py +0 -0
  15. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev/__init__.py +0 -0
  16. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev/custom_exceptions.py +0 -0
  17. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev/data_source.py +0 -0
  18. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev/filtering_data.py +0 -0
  19. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev/formatting_data.py +0 -0
  20. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev/path_retrieval.py +0 -0
  21. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev.egg-info/dependency_links.txt +0 -0
  22. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev.egg-info/requires.txt +0 -0
  23. {python_flask_dev-0.0.1 → python_flask_dev-0.0.7}/src/python_flask_dev.egg-info/top_level.txt +0 -0
@@ -1,13 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-flask-dev
3
- Version: 0.0.1
4
- Summary: Package containing modules with 'helper' functions to support the development of Python Flask applications.
5
- Author-email: Dani <daniasestan@gmail.com>
3
+ Version: 0.0.7
4
+ Summary: A small example package
5
+ Author-email: Example Author <author@example.com>
6
6
  License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pypa/sampleproject
8
+ Project-URL: Issues, https://github.com/pypa/sampleproject/issues
7
9
  Classifier: Programming Language :: Python :: 3
8
- Classifier: Operating System :: POSIX :: Linux
9
- Classifier: Framework :: Flask
10
- Requires-Python: >=3.12.3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
11
12
  Description-Content-Type: text/markdown
12
13
  Requires-Dist: Flask==3.1.2
13
14
  Requires-Dist: numpy==2.4.2
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "python-flask-dev"
3
+ version = "0.0.7"
4
+ authors = [
5
+ { name="Example Author", email="author@example.com" },
6
+ ]
7
+ description = "A small example package"
8
+ readme = "README.md"
9
+ requires-python = ">=3.9"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ license = "MIT"
15
+ license-files = ["LICEN[CS]E*"]
16
+ dependencies = [
17
+ 'Flask==3.1.2',
18
+ 'numpy==2.4.2',
19
+ 'pandas==3.0.1',
20
+ "build==1.4.0",
21
+ "twine==6.2.0"
22
+ ]
23
+
24
+ [build-system]
25
+ requires = ["setuptools >= 77.0.3"]
26
+ build-backend = "setuptools.build_meta"
27
+
28
+ [tool.setuptools]
29
+ package-dir = {"" = "src"}
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/pypa/sampleproject"
33
+ Issues = "https://github.com/pypa/sampleproject/issues"
@@ -0,0 +1,44 @@
1
+ import os
2
+ import sys
3
+ import importlib.util
4
+ from pathlib import Path
5
+ import site
6
+
7
+
8
+ PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
9
+ VIRTUAL_ENV = Path(os.getenv('VIRTUAL_ENV'))
10
+
11
+ # opt for module in the local project directory, or module installed in the venv
12
+
13
+ def get_imported_project_module(module_name, module_path = None, is_pkg_installation_required = False, add_to_import_system = False):
14
+
15
+ if is_pkg_installation_required:
16
+ module_path = f"{site.getsitepackages()[0]}/{module_name}"
17
+ else:
18
+ if module_path == None:
19
+ raise Exception("ERROR: Module path is required for an installed package")
20
+
21
+ # Create the module object from the spec
22
+ module_spec = importlib.util.spec_from_file_location(module_name, Path(module_path))
23
+ # Load the module
24
+ custom_module = importlib.util.module_from_spec(module_spec)
25
+
26
+ # Optionally add the module to sys.modules so it's treated as a normal import
27
+ if add_to_import_system:
28
+ sys.modules[module_name] = custom_module
29
+
30
+ module_spec.loader.exec_module(custom_module)
31
+
32
+ # The module is callable: `custom_module.some_function()`
33
+ return custom_module
34
+
35
+ # Note that, typically, this is not recommended for python projects
36
+ def modify_venv_pythonpath(pkg_path, absolute_path=False):
37
+ python_version = f"python{sys.version_info.major}.{sys.version_info.minor}"
38
+
39
+ site_pkgs_pth_file = f"{VIRTUAL_ENV}/lib/{python_version}/site-packages/{Path(PROJECT_ROOT).name}.pth"
40
+
41
+ print("site_pkgs_pth_file: ", site_pkgs_pth_file)
42
+ with open(site_pkgs_pth_file, "w") as f:
43
+ path = pkg_path if absolute_path else f"{PROJECT_ROOT}/{pkg_path}"
44
+ f.write(path)
@@ -1,13 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-flask-dev
3
- Version: 0.0.1
4
- Summary: Package containing modules with 'helper' functions to support the development of Python Flask applications.
5
- Author-email: Dani <daniasestan@gmail.com>
3
+ Version: 0.0.7
4
+ Summary: A small example package
5
+ Author-email: Example Author <author@example.com>
6
6
  License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pypa/sampleproject
8
+ Project-URL: Issues, https://github.com/pypa/sampleproject/issues
7
9
  Classifier: Programming Language :: Python :: 3
8
- Classifier: Operating System :: POSIX :: Linux
9
- Classifier: Framework :: Flask
10
- Requires-Python: >=3.12.3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
11
12
  Description-Content-Type: text/markdown
12
13
  Requires-Dist: Flask==3.1.2
13
14
  Requires-Dist: numpy==2.4.2
@@ -14,6 +14,4 @@ src/python_flask_dev.egg-info/PKG-INFO
14
14
  src/python_flask_dev.egg-info/SOURCES.txt
15
15
  src/python_flask_dev.egg-info/dependency_links.txt
16
16
  src/python_flask_dev.egg-info/requires.txt
17
- src/python_flask_dev.egg-info/top_level.txt
18
- src/python_flask_dev/packaging/__init__.py
19
- src/python_flask_dev/packaging/incremental_versioning.py
17
+ src/python_flask_dev.egg-info/top_level.txt
@@ -1,35 +0,0 @@
1
- [project]
2
- name = "python-flask-dev"
3
- version = "0.0.1"
4
- authors = [
5
- { name = "Dani", email = "daniasestan@gmail.com" },
6
- ]
7
- description = "Package containing modules with 'helper' functions to support the development of Python Flask applications."
8
- readme = "README.md"
9
- requires-python = ">=3.12.3"
10
- classifiers = [
11
- "Programming Language :: Python :: 3",
12
- "Operating System :: POSIX :: Linux",
13
- "Framework :: Flask",
14
- ]
15
- license = "MIT"
16
- license-files = [
17
- "LICEN[CS]E*",
18
- ]
19
- dependencies = [
20
- "Flask==3.1.2",
21
- "numpy==2.4.2",
22
- "pandas==3.0.1",
23
- "build==1.4.0",
24
- "twine==6.2.0",
25
- ]
26
- dynamic = []
27
-
28
- [build-system]
29
- requires = [
30
- "setuptools >= 77.0.3",
31
- ]
32
- build-backend = "setuptools.build_meta"
33
-
34
- [tool.setuptools.package-dir]
35
- "" = "src"
@@ -1,64 +0,0 @@
1
- import os
2
- import sys
3
- import importlib.util
4
- from pathlib import Path
5
- import site
6
- import logging
7
-
8
-
9
- logger = logging.getLogger(__name__)
10
- logging.basicConfig(level=logging.INFO)
11
-
12
- def get_imported_project_module(module_name, module_path = None, add_to_import_system = False):
13
- logger.info(f"##### module_path: {module_path}")
14
- # Create the module object from the spec
15
- module_spec = importlib.util.spec_from_file_location(module_name, Path(module_path))
16
- logger.info(f"##### module_spec: {module_spec}")
17
- # Load the module
18
- custom_module = importlib.util.module_from_spec(module_spec)
19
-
20
- # Optionally add the module to sys.modules so it's treated as a normal import
21
- if add_to_import_system:
22
- sys.modules[module_name] = custom_module
23
-
24
- module_spec.loader.exec_module(custom_module)
25
-
26
- # The module is callable: `custom_module.some_function()`
27
- return custom_module
28
-
29
- # Note that, typically, this is not recommended for python projects; Modules located within the directory that is added to the search path can be imported.
30
- def modify_venv_pythonpath(*, pth_filename = "imported-project-modules.pth", absolute_pkg_path = None, installed_pkg_name = None):
31
- site_dir = site.getsitepackages()[0]
32
- logger.info(f"########## site_dir: {site_dir}")
33
-
34
- if absolute_pkg_path:
35
- pkg_path = absolute_pkg_path
36
- elif installed_pkg_name:
37
- pkg_path = f"{site_dir}/{installed_pkg_name}"
38
- else:
39
- raise Exception("ERROR: absolute_pkg_path or installed_pkg_name is required")
40
-
41
- # Create/write to a .pth file, listing the path of the package to import:
42
- site_pkgs_pth_filepath = f"{site_dir}/{pth_filename}"
43
- try:
44
- with open(site_pkgs_pth_filepath, 'r') as file:
45
- lines = [line.strip() for line in file]
46
- except Exception as e:
47
- logger.error(e)
48
- lines = []
49
-
50
- logger.info(f"########## pkg_path: {pkg_path}")
51
- logger.info(f"########## lines: {lines}")
52
-
53
- if pkg_path not in lines:
54
- with open(site_pkgs_pth_filepath, 'a') as file:
55
- if pkg_path not in lines:
56
- logger.info(f"########## writing to site-pkgs .pth; pkg_path: {pkg_path}")
57
- file.write(pkg_path + '\n')
58
-
59
- # Add the package:
60
- known_paths = set(sys.path)
61
- logger.info(f"########## known_paths: {known_paths}")
62
- site.addpackage(site_dir, site_pkgs_pth_filepath, known_paths)
63
- if pkg_path in os.listdir(site_dir):
64
- logger.info(f"########## `{pkg_path}` package added to the Python packages search system path")
@@ -1,107 +0,0 @@
1
- import logging
2
- import requests
3
- import tomllib
4
- import tomli_w
5
- import argparse
6
-
7
-
8
-
9
- # ENV VARS
10
- PYPI_BASE_URL = "https://pypi.org/simple/"
11
- VERSIONING = "manual"
12
-
13
- # ARGS
14
- parser = argparse.ArgumentParser()
15
- parser.add_argument('-v', '--versioning', default="manual", help='Options: "automatic", "dynamic", "manual"')
16
- args = parser.parse_args()
17
-
18
- # LOGGING
19
- logger = logging.getLogger(__name__)
20
- logging.basicConfig(level=logging.INFO)
21
-
22
- def get_pypi_repository_data(toml_data):
23
- # Retrieve latest version from PyPI API data
24
- # TODO: [START] replace
25
- # project_name = toml_data["project"]["name"]
26
- project_name = "my_simple_test"
27
- # TODO: [END] replace
28
- pypi_project_url = f"{PYPI_BASE_URL}{project_name}"
29
- resp = requests.get(pypi_project_url, headers={"Accept": "application/vnd.pypi.simple.v1+json"}).json()
30
- logging.info(f"########################## pypi_project_url: {pypi_project_url}")
31
-
32
- project_versions = resp["versions"]
33
- project_versions.sort(reverse=True)
34
- project_latest_version = project_versions[0]
35
-
36
- return {"project_name": project_name, "pypi_project_url": pypi_project_url, "project_versions": project_versions, "project_latest_version": project_latest_version}
37
-
38
- def update_pyproject_config(toml_data):
39
- with open("pyproject.toml", "wb") as f:
40
- tomli_w.dump(toml_data, f)
41
-
42
- def set_version_manually(toml_data):
43
- if "version" in toml_data["project"]["dynamic"]:
44
- toml_data["project"]["dynamic"].remove("version")
45
- update_pyproject_config(toml_data)
46
-
47
- logging.info("Manual versioning selected. Please update the version number in pyproject.toml manually.")
48
-
49
- def set_version_dynamically(toml_data):
50
- if "version" in toml_data["project"]:
51
- del toml_data["project"]["version"]
52
- update_pyproject_config(toml_data)
53
-
54
- if "version" not in toml_data["project"]["dynamic"]:
55
- toml_data["project"]["dynamic"].append("version")
56
- update_pyproject_config(toml_data)
57
-
58
- logging.info("Dynamic versioning selected. Please set the version number in the 'version.txt' file.")
59
-
60
- def set_version_automatically(toml_data):
61
- project_name, pypi_project_url, project_versions, project_latest_version = get_pypi_repository_data(toml_data).values()
62
-
63
- # Change the version number
64
- project_versioning_list = project_latest_version.split(".")
65
- project_versioning_list[2] = f"{int(project_versioning_list[2]) + 1}"
66
- logger.info(f"############## project_versioning_list: {project_versioning_list}")
67
- new_project_version = '.'.join(project_versioning_list)
68
- logger.info(f"############## new_project_version: {new_project_version}")
69
-
70
- # Write the new version number
71
- toml_data["project"]["version"] = new_project_version
72
- if "version" in toml_data["project"]["dynamic"]:
73
- toml_data["project"]["dynamic"].remove("version")
74
- update_pyproject_config(toml_data)
75
- logging.info(f"Automatic versioning selected. Version number updated to {new_project_version} in pyproject.toml.")
76
-
77
- def incremental_versioning(versioning):
78
- # Read project data from pyproject.toml
79
- with open("pyproject.toml", "rb") as f:
80
- toml_data = tomllib.load(f)
81
- logger.info(f"############ toml_data: {toml_data}")
82
-
83
- if "version" not in toml_data["project"]:
84
- toml_data["project"]["version"] = []
85
- update_pyproject_config(toml_data)
86
-
87
- if "dynamic" not in toml_data["project"]:
88
- toml_data["project"]["dynamic"] = []
89
- update_pyproject_config(toml_data)
90
-
91
- logging.info(f"######## Project: {get_pypi_repository_data(toml_data)['project_name']}")
92
- logging.info(f"######## Version: {get_pypi_repository_data(toml_data)['project_latest_version']}")
93
-
94
- if versioning == "manual":
95
- set_version_manually(toml_data)
96
- elif versioning == "dynamic":
97
- set_version_dynamically(toml_data)
98
- elif versioning == "automatic":
99
- set_version_automatically(toml_data)
100
- else:
101
- set_version_manually(toml_data)
102
- logging.info("Defaulting to manual versioning. Options: 'automatic', 'dynamic', 'manual'")
103
-
104
- if __name__ == "__main__":
105
- # TODO: replace in python-flask-dev pkg; passed in as var
106
- versioning = args.versioning
107
- incremental_versioning(versioning)