| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The module import happens before setup() is executed, and therefore, none of the modules specified in 'setup_requires' (or 'install_requires', for that matter) are loaded at that moment, causing the import to fail with ModuleNotFoundError. Following the first recommendation from the 'Single-sourcing the package version' section of the Python Package User Guide [1], in this commit we switch to reading the version string from the '__init__.py' file instead of attempting to import the module. [1]: https://packaging.python.org/guides/single-sourcing-package-version/
|
It also might be a good idea to apply the following patch before I’m not sure how realistic the danger of those problems is, but I cannot push more commits to this PR, because I no longer have From 6ee974ec3ab6f0d6dbf7ffd36239d4f3555c0a34 Mon Sep 17 00:00:00 2001
From: Igor Burago <iburago@uci.edu>
Date: Thu, 11 Jun 2020 20:34:10 -0700
Subject: [PATCH] setup.py: Convert relative paths to absolute ones in read_file()
---
setup.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git setup.py setup.py
index f0eabdc..1fe4f0c 100644
--- setup.py
+++ setup.py
@@ -3,12 +3,14 @@ import sys
from setuptools import setup, find_packages
-def read_file(path):
- with open(path) as f:
+def read_file(rel_path):
+ abs_dir_path = os.path.abspath(os.path.dirname(__file__))
+ abs_path = os.path.join(abs_dir_path, rel_path)
+ with open(abs_path) as f:
return f.read()
-def read_version(path):
- for line in read_file(path).splitlines():
+def read_version(rel_path):
+ for line in read_file(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
--
2.27.0
|
Sorry, something went wrong.
The module import happens before setup() is executed, and therefore, none of the modules specified in 'setup_requires' (or 'install_requires', for that matter) are loaded at that moment, causing the import to fail with ModuleNotFoundError. Following the first recommendation from the 'Single-sourcing the package version' section of the Python Package User Guide [1], in this commit we switch to reading the version string from the '__init__.py' file instead of attempting to import the module. [1]: https://packaging.python.org/guides/single-sourcing-package-version/ --- Also includes updates in patch at #54 (comment)
|
Cherry-picked, squashed, and merged in #55. |
Sorry, something went wrong.
Lots of updates, thanks to one and all. This will be the last release with Py2k support and the last release before declaring a v1.0. Updates: - #35: Add fancy double quote to punctuation; Thanks @dwaynebailey! - #45: Fix deprecation warning regarding invalid escape sequences. Thanks @tirkarthi - #46: Add support for titlecasing non-ASCII letters; Thanks @acabal! - #47: Add sphinx documentation to titlecase function; Thanks @1kastner! - #49: Remove closing bracket in parser help text; Thanks @1kastner! - #53: Add table with examples; Thanks @1kastner! - #53: Terms with only consonants should be ALL CAPS; Thanks @Garret-R! - #54: setup.py: Read version from __init__.py to avoid importing the module Major thanks for unblocking this @iburago!!
| Back | FazBrowse Home | New Git URL |
The titlecase import in setup.py happens before the setup() call
is executed, and therefore, none of the modules specified in setup_requires
(or install_requires, for that matter) are loaded at that moment,
causing the import to fail with ModuleNotFoundError for the regex
import in __init__.py.
Following the first recommendation from the ‘Single-sourcing the
package version’ section of the Python Packaging User Guide, in this
commit we switch to reading the version string from the __init__.py
file instead of having to import the module just for the version string.
Fixes #50, #52.