python-flask-dev 0.0.8__tar.gz → 0.0.9__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 (20) hide show
  1. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/PKG-INFO +6 -5
  2. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/pyproject.toml +6 -5
  3. python_flask_dev-0.0.9/src/python_flask_dev/importing_modules.py +64 -0
  4. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev.egg-info/PKG-INFO +6 -5
  5. python_flask_dev-0.0.8/src/python_flask_dev/importing_modules.py +0 -44
  6. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/README.md +0 -0
  7. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/setup.cfg +0 -0
  8. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/__init__.py +0 -0
  9. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/app.py +0 -0
  10. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/data/__init__.py +0 -0
  11. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev/__init__.py +0 -0
  12. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev/custom_exceptions.py +0 -0
  13. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev/data_source.py +0 -0
  14. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev/filtering_data.py +0 -0
  15. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev/formatting_data.py +0 -0
  16. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev/path_retrieval.py +0 -0
  17. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev.egg-info/SOURCES.txt +0 -0
  18. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev.egg-info/dependency_links.txt +0 -0
  19. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev.egg-info/requires.txt +0 -0
  20. {python_flask_dev-0.0.8 → python_flask_dev-0.0.9}/src/python_flask_dev.egg-info/top_level.txt +0 -0
@@ -1,14 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-flask-dev
3
- Version: 0.0.8
4
- Summary: A small example package
5
- Author-email: Example Author <author@example.com>
3
+ Version: 0.0.9
4
+ Summary: Package containing modules with 'helper' functions to support the development of Python Flask applications.
5
+ Author-email: Dani <daniasestan@gmail.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/pypa/sampleproject
8
8
  Project-URL: Issues, https://github.com/pypa/sampleproject/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Framework :: Flask
12
+ Requires-Python: >=3.12.3
12
13
  Description-Content-Type: text/markdown
13
14
  Requires-Dist: Flask==3.1.2
14
15
  Requires-Dist: numpy==2.4.2
@@ -1,15 +1,16 @@
1
1
  [project]
2
2
  name = "python-flask-dev"
3
- version = "0.0.8"
3
+ version = "0.0.9"
4
4
  authors = [
5
- { name="Example Author", email="author@example.com" },
5
+ { name="Dani", email="daniasestan@gmail.com" },
6
6
  ]
7
- description = "A small example package"
7
+ description = "Package containing modules with 'helper' functions to support the development of Python Flask applications."
8
8
  readme = "README.md"
9
- requires-python = ">=3.9"
9
+ requires-python = ">=3.12.3"
10
10
  classifiers = [
11
11
  "Programming Language :: Python :: 3",
12
- "Operating System :: OS Independent",
12
+ "Operating System :: POSIX :: Linux",
13
+ "Framework :: Flask"
13
14
  ]
14
15
  license = "MIT"
15
16
  license-files = ["LICEN[CS]E*"]
@@ -0,0 +1,64 @@
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,14 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-flask-dev
3
- Version: 0.0.8
4
- Summary: A small example package
5
- Author-email: Example Author <author@example.com>
3
+ Version: 0.0.9
4
+ Summary: Package containing modules with 'helper' functions to support the development of Python Flask applications.
5
+ Author-email: Dani <daniasestan@gmail.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/pypa/sampleproject
8
8
  Project-URL: Issues, https://github.com/pypa/sampleproject/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Framework :: Flask
12
+ Requires-Python: >=3.12.3
12
13
  Description-Content-Type: text/markdown
13
14
  Requires-Dist: Flask==3.1.2
14
15
  Requires-Dist: numpy==2.4.2
@@ -1,44 +0,0 @@
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)