Commit 273eaf4682ba11c1c1fcfdcda31d0c95211599a2

Authored by Jay Berkenbilt
1 parent 17c5b950

Remove hard-coded version from manual/conf.py

CMakeLists.txt
@@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.16) @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.16)
3 3
4 # make_dist expects the version line to be on a line by itself after 4 # make_dist expects the version line to be on a line by itself after
5 # the project line. When updating the version, check make_dist for all 5 # the project line. When updating the version, check make_dist for all
6 -# the places it has to be updated. 6 +# the places it has to be updated. The doc configuration and CI build
  7 +# also find the version number here.
7 project(qpdf 8 project(qpdf
8 VERSION 11.7.0 9 VERSION 11.7.0
9 LANGUAGES C CXX) 10 LANGUAGES C CXX)
build-scripts/build-doc
@@ -10,7 +10,7 @@ pip3 install sphinx sphinx_rtd_theme @@ -10,7 +10,7 @@ pip3 install sphinx sphinx_rtd_theme
10 cmake -S . -B build -DBUILD_DOC=1 10 cmake -S . -B build -DBUILD_DOC=1
11 cmake --build build --verbose --target doc_dist 11 cmake --build build --verbose --target doc_dist
12 zip -r doc.zip build/manual/doc-dist 12 zip -r doc.zip build/manual/doc-dist
13 -version=$(grep -E '^release' manual/conf.py | cut -d"'" -f 2) 13 +version=$(grep -E '^ +VERSION [1-9]' CMakeLists.txt | awk '{print $2}')
14 mv build/manual/doc-dist qpdf-${version}-doc 14 mv build/manual/doc-dist qpdf-${version}-doc
15 mkdir distribution 15 mkdir distribution
16 zip -r distribution/qpdf-${version}-doc-ci.zip qpdf-${version}-doc 16 zip -r distribution/qpdf-${version}-doc-ci.zip qpdf-${version}-doc
make_dist
@@ -59,7 +59,6 @@ cd($tmpdir); @@ -59,7 +59,6 @@ cd($tmpdir);
59 # Check versions 59 # Check versions
60 my $cmakeversion = get_version_from_cmake(); 60 my $cmakeversion = get_version_from_cmake();
61 my $code_version = get_version_from_source(); 61 my $code_version = get_version_from_source();
62 -my $doc_version = get_version_from_manual();  
63 62
64 my $version_error = 0; 63 my $version_error = 0;
65 if ($version ne $cmakeversion) 64 if ($version ne $cmakeversion)
@@ -72,11 +71,6 @@ if ($version ne $code_version) @@ -72,11 +71,6 @@ if ($version ne $code_version)
72 print "$whoami: QPDF.cc version = $code_version\n"; 71 print "$whoami: QPDF.cc version = $code_version\n";
73 $version_error = 1; 72 $version_error = 1;
74 } 73 }
75 -if ($version ne $doc_version)  
76 -{  
77 - print "$whoami: doc version = $doc_version\n";  
78 - $version_error = 1;  
79 -}  
80 if ($version_error) 74 if ($version_error)
81 { 75 {
82 die "$whoami: version numbers are not consistent\n"; 76 die "$whoami: version numbers are not consistent\n";
@@ -157,22 +151,6 @@ sub get_version_from_source @@ -157,22 +151,6 @@ sub get_version_from_source
157 $code_version; 151 $code_version;
158 } 152 }
159 153
160 -sub get_version_from_manual  
161 -{  
162 - my $fh = safe_open("manual/conf.py");  
163 - my $doc_version = 'unknown';  
164 - while (<$fh>)  
165 - {  
166 - if (m/release = '([^\']+)\'/)  
167 - {  
168 - $doc_version = $1;  
169 - last;  
170 - }  
171 - }  
172 - $fh->close();  
173 - $doc_version;  
174 -}  
175 -  
176 sub safe_open 154 sub safe_open
177 { 155 {
178 my $file = shift; 156 my $file = shift;
manual/conf.py
@@ -15,8 +15,12 @@ sys.path.append(os.path.abspath(&quot;./_ext&quot;)) @@ -15,8 +15,12 @@ sys.path.append(os.path.abspath(&quot;./_ext&quot;))
15 project = 'QPDF' 15 project = 'QPDF'
16 copyright = '2005-2023, Jay Berkenbilt' 16 copyright = '2005-2023, Jay Berkenbilt'
17 author = 'Jay Berkenbilt' 17 author = 'Jay Berkenbilt'
18 -# make_dist and the CI build lexically find the release version from this file.  
19 -release = '11.7.0' 18 +here = os.path.dirname(os.path.realpath(__file__))
  19 +with open(f'{here}/../CMakeLists.txt') as f:
  20 + for line in f.readlines():
  21 + if line.strip().startswith('VERSION '):
  22 + release = line.replace('VERSION', '').strip()
  23 + break
20 version = release 24 version = release
21 extensions = [ 25 extensions = [
22 'sphinx_rtd_theme', 26 'sphinx_rtd_theme',