-
Notifications
You must be signed in to change notification settings - Fork 29
Update build pipeline and switch to pytest #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| python: | ||
| - 3.9 | ||
| - 3.10 | ||
| - 3.10 | ||
| - 3.12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,4 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
| cd tests | ||
| nosetests | ||
|
|
||
| pytest | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| from .pyxb_compat import (CreateFromDocument, ToXML, ToDOM) | ||
| from .ismrmrdschema import * | ||
| from .pyxb_compat import CreateFromDocument, ToXML, ToDOM | ||
| from .ismrmrdschema import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,29 @@ | ||
| [build-system] | ||
| requires = ["setuptools","wheel","xsdata[cli]","jinja2 >= 2.11.0"] | ||
| build-backend = "setuptools.build_meta" | ||
| requires = ["setuptools", "xsdata[cli]"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "ismrmrd" | ||
| dynamic = ["version"] | ||
| dependencies = ["h5py>=2.3", "numpy>=1.22.0", "xsdata>=22.12"] | ||
| requires-python = ">=3.9" | ||
|
|
||
| authors = [{name = "ISMRMRD Developers"}] | ||
|
|
||
| description = "Python implementation of ISMRMRD" | ||
| readme = "README.md" | ||
| license-files = ["LICENSE"] | ||
| license = "LicenseRef-IsmrmrdSoftwareLicense" | ||
| keywords = ["ismrmrd"] | ||
| classifiers = [ | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Programming Language :: Python :: 3", | ||
| "Operating System :: OS Independent", | ||
| "Intended Audience :: Science/Research", | ||
| "Topic :: Scientific/Engineering :: Medical Science Apps." | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/ismrmrd/ismrmrd-python" | ||
| Documentation = "https://github.com/ismrmrd/ismrmrd-python" | ||
| Repository = "https://github.com/ismrmrd/ismrmrd-python" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| h5py==2.9.0 | ||
| nose==1.3.7 | ||
| numpy==1.22.0 | ||
| PyXB==1.2.6 | ||
| six==1.12.0 | ||
| xsdata==24.4 | ||
| h5py==3.14.0 | ||
| pytest==8.4.1 | ||
| numpy==2.3.2 | ||
| xsdata==25.7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,81 +1,74 @@ | ||
| import os | ||
| from setuptools import setup, find_packages | ||
| from distutils.command.build import build | ||
| from distutils.command.build_py import build_py | ||
| from setuptools import setup, find_packages, Command | ||
|
|
||
| import logging | ||
| import shutil | ||
| from pathlib import Path | ||
| import re | ||
|
|
||
| logging.basicConfig() | ||
| log_ = logging.getLogger(__name__) | ||
| import re | ||
|
|
||
| schema_file = os.path.join('schema','ismrmrd.xsd') | ||
| config_file = os.path.join('schema','.xsdata.xml') | ||
|
|
||
| class my_build_py(build_py): | ||
| def run(self): | ||
| # honor the --dry-run flag | ||
| if not self.dry_run: | ||
| outloc = self.build_lib | ||
| outloc = os.path.join(outloc,'ismrmrd/xsd/ismrmrdschema') | ||
|
|
||
|
|
||
| generate_schema(schema_file, config_file, outloc) | ||
| # distutils uses old-style classes, so no super() | ||
| build_py.run(self) | ||
| import setuptools.command.build | ||
| setuptools.command.build.build.sub_commands.append(("generate_schema", None)) | ||
|
|
||
| class GenerateSchemaCommand(Command): | ||
| description = "Generate Python code from ISMRMRD XML schema using xsdata" | ||
| user_options = [] | ||
|
|
||
| def fix_init_file(package_name,filepath): | ||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self.build_lib = None | ||
| self.editable_mode = False | ||
|
|
||
| with open(filepath,'r+') as f: | ||
| text = f.read() | ||
| text = re.sub(f'from {package_name}.ismrmrd', 'from .ismrmrd',text) | ||
| f.seek(0) | ||
| f.write(text) | ||
| f.truncate() | ||
| def initialize_options(self): | ||
| pass | ||
|
|
||
| def finalize_options(self): | ||
| # Set build_lib for non-editable installs | ||
| self.set_undefined_options("build_py", ("build_lib", "build_lib")) | ||
|
|
||
| def run(self): | ||
| # Use editable_mode if present (PEP 660) | ||
| if self.editable_mode: | ||
| outdir = 'ismrmrd/xsd/' | ||
| else: | ||
| outdir = os.path.join(self.build_lib, 'ismrmrd/xsd/') | ||
| self.announce(f'Generating schema to {outdir} (editable_mode={self.editable_mode})', level=3) | ||
| self.generate_schema(schema_file, config_file, 'ismrmrdschema', outdir) | ||
|
|
||
| def get_source_files(self): | ||
| return [schema_file, config_file] | ||
|
|
||
| def generate_schema(schema_filename, config_filename, outloc ): | ||
| def to_uri(filename): | ||
| return Path(filename).absolute().as_uri() | ||
| def get_outputs(self): | ||
| return [ | ||
| "{build_lib}/ismrmrd/xsd/ismrmrdschema/__init__.py", | ||
| "{build_lib}/ismrmrd/xsd/ismrmrdschema/ismrmrd.py" | ||
| ] | ||
|
|
||
| import sys | ||
| import subprocess | ||
|
|
||
| subpackage_name = 'ismrmrdschema' | ||
| args = [sys.executable,'-m','xsdata', str(schema_filename), '--config',str(config_filename), '--package',subpackage_name] | ||
| subprocess.run(args) | ||
| fix_init_file(subpackage_name,f"{subpackage_name}/__init__.py") | ||
| shutil.rmtree(os.path.join(outloc,subpackage_name),ignore_errors=True) | ||
| shutil.move(subpackage_name,outloc) | ||
| def fix_init_file(self, package_name,filepath): | ||
| with open(filepath,'r+') as f: | ||
| text = f.read() | ||
| text = re.sub(f'from {package_name}.ismrmrd', 'from .ismrmrd',text) | ||
| f.seek(0) | ||
| f.write(text) | ||
| f.truncate() | ||
|
|
||
| this_directory = Path(__file__).parent | ||
| long_description = (this_directory / "README").read_text() | ||
| def generate_schema(self, schema_filename, config_filename, subpackage_name, outdir): | ||
| import sys | ||
| import subprocess | ||
| # subpackage_name = 'ismrmrdschema' | ||
| args = [sys.executable, '-m', 'xsdata', str(schema_filename), '--config', str(config_filename), '--package', subpackage_name] | ||
| subprocess.run(args) | ||
| self.fix_init_file(subpackage_name, f"{subpackage_name}/__init__.py") | ||
| destination = os.path.join(outdir, subpackage_name) | ||
| shutil.rmtree(destination, ignore_errors=True) | ||
| shutil.move(subpackage_name, destination) | ||
|
|
||
| setup( | ||
| name='ismrmrd', | ||
| version='1.14.1', | ||
| author='ISMRMRD Developers', | ||
| description='Python implementation of the ISMRMRD', | ||
| license='Public Domain', | ||
| keywords='ismrmrd', | ||
| url='https://ismrmrd.github.io', | ||
| long_description = long_description, | ||
| long_description_content_type='text/markdown', | ||
| packages=find_packages(), | ||
| classifiers=[ | ||
| 'Development Status :: 5 - Production/Stable', | ||
| 'Intended Audience :: Science/Research', | ||
| 'License :: Public Domain', | ||
| 'Operating System :: OS Independent', | ||
| 'Topic :: Scientific/Engineering :: Medical Science Apps.' | ||
| ], | ||
| install_requires=['xsdata>=22.12', 'numpy>=1.22.0', 'h5py>=2.3'], | ||
| setup_requires=['nose>=1.0', 'xsdata[cli]>=22.12', 'jinja2 >= 2.11'], | ||
| test_suite='nose.collector', | ||
| cmdclass={'build_py':my_build_py} | ||
| cmdclass={ | ||
| 'generate_schema': GenerateSchemaCommand | ||
| } | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the version be bumped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, yes, but this project's version has historically followed the version of the main C++ implementation.
So, the version will bump to 1.14.2 in the next PR when I add the ProtocolSerializer, bringing the API to feature parity with the C++ library.