@@ -82,19 +82,6 @@ def get_lib(name):
82
82
if prefix := get_library_prefix (name ):
83
83
return os .path .join (prefix , "lib" )
84
84
85
- def get_version (rel_path ):
86
- """Read version from a file via text parsing, following PyPA guide."""
87
- def read (rel_path ):
88
- here = os .path .abspath (os .path .dirname (__file__ ))
89
- with codecs .open (os .path .join (here , rel_path ), "r" ) as fp :
90
- return fp .read ()
91
- for line in read (rel_path ).splitlines ():
92
- if line .startswith ("__version__" ):
93
- delim = '"' if '"' in line else "'"
94
- return line .split (delim )[1 ]
95
- else :
96
- raise RuntimeError ("Unable to find version string." )
97
-
98
85
# Configuratin
99
86
INCLUDE_MPI = True
100
87
INCLUDE_FFTW = True
@@ -179,26 +166,6 @@ def read(rel_path):
179
166
extra_compile_args = extra_compile_args ,
180
167
extra_link_args = extra_link_args ))
181
168
182
- # Runtime requirements
183
- install_requires = [
184
- "docopt" ,
185
- "h5py >= 3.0.0" ,
186
- "matplotlib" ,
187
- "mpi4py >= 2.0.0" ,
188
- "numexpr" ,
189
- "numpy >= 1.20.0" ,
190
- "py" ,
191
- "pytest" ,
192
- "pytest-benchmark" ,
193
- "pytest-cov" ,
194
- "pytest-parallel" ,
195
- "scipy >= 1.4.0" ,
196
- "xarray" ]
197
-
198
- # Grab long_description from README
199
- with open ("README.md" ) as f :
200
- long_description = f .read ()
201
-
202
169
# Cython directives
203
170
compiler_directives = {}
204
171
compiler_directives ["language_level" ] = 3
@@ -217,24 +184,38 @@ def run(self):
217
184
# Run the original build command
218
185
_build .run (self )
219
186
187
+ # Set version
188
+ if os .path .exists (".git" ):
189
+ # If on a git repository, we can
190
+ # get the version from the commit sha
191
+ kwargs = {
192
+ "use_scm_version" : {
193
+ "write_to" : "pysr/version.py" ,
194
+ },
195
+ "setup_requires" : ["setuptools" , "setuptools_scm" ],
196
+ }
197
+ else :
198
+ # As a backup, we read from the pyproject.toml
199
+ import re
200
+
201
+ with open (os .path .join (os .path .dirname (__file__ ), "pyproject.toml" )) as f :
202
+ data = f .read ()
203
+ version = re .search (r'version = "(.*)"' , data ).group (1 )
204
+ # TODO: When limited to Python 3.11, can use tomllib from the standard library
205
+
206
+ # Write the version to version.py
207
+ with open (os .path .join (os .path .dirname (__file__ ), "dedalus" , "version.py" ), "w" ) as f :
208
+ f .write (f'__version__ = "{ version } "' )
209
+
210
+ kwargs = {
211
+ "use_scm_version" : False ,
212
+ "version" : version ,
213
+ }
214
+
215
+
220
216
# Setup
221
217
print ()
222
218
setup (
223
- name = "dedalus" ,
224
- version = get_version ("dedalus/__init__.py" ),
225
- author = "Keaton J. Burns" ,
226
-
227
- description = "A flexible framework for solving PDEs with modern spectral methods." ,
228
- long_description = long_description ,
229
- long_description_content_type = "text/markdown" ,
230
- url = "http://dedalus-project.org" ,
231
- classifiers = ["Programming Language :: Python :: 3" ],
232
- python_requires = ">=3.9" ,
233
- install_requires = install_requires ,
234
- license = "GPL3" ,
235
- packages = setuptools .find_packages (),
236
- package_data = {"" : ["dedalus.cfg" , "examples.tar.gz" ]},
237
219
ext_modules = cythonize (extensions , compiler_directives = compiler_directives ),
238
- cmdclass = {"build" : build },
239
- entry_points = {"xarray.backends" : ["dedalus=dedalus.tools.post:DedalusXarrayBackend" ]})
220
+ cmdclass = {"build" : build })
240
221
0 commit comments