Skip to content

Py3 compat - #5

Closed
danielballan wants to merge 3 commits into
diffpy:mainfrom
danielballan:py3-compat
Closed

danielballan wants to merge 3 commits into
diffpy:mainfrom
danielballan:py3-compat

Conversation

@danielballan

Copy link
Copy Markdown
  • Use six. (For the uninitiated, it's a package commonly used to simplify py2/3 compatibility.)
  • Remove py2-isms (print statements, has_key, etc.)
  • Remove homebrewed versioning code in favor of versioneer.
  • Remove a couple unused imports.

The important module is importable in Python 3:

In [1]: import diffpy.srxplanar
Only tiff or .npy mask is support since fabio is not available

and versioneer is doing its job.

In [2]: import diffpy

In [3]: diffpy.__version__
Out[3]: '1.1+39.g3a19323.dirty'

The +39 means 39 commits past version 1.1, and the .dirty means there was uncommitted code when I ran this. The last commit was hash g3a19323....

I followed the existing convention of exposing __version__ in the subpackages, although this is a little unusual. You can see that they all still work.

In [4]: diffpy.srxplanar.__version__
Out[4]: '1.1+39.g3a19323.dirty'

In [5]: diffpy.confutils.__version__
Out[5]: '1.1+39.g3a19323.dirty'

attn @pavoljuhas

- Use six.
- Fix simple stuff (print statements, has_key, etc.)
- Remove versioning code in favor of versioneer.
- Remove a couple unused imports.
@zthatch

zthatch commented Jun 15, 2021

Copy link
Copy Markdown

@danielballan thank you for already having done what I was recently assigned. Looks like I will just add test code to prove that this works on python 2 and 3 (specifically testing how it interfaces with srxplanargui and pdfgetxgui).

It also looks like there is now a conflict, so I will see if I can pull your PR and rebase.

I still have to have a conversation with @pavoljuhas about versioning and will likely switch from versioneer to Rever.

@pavoljuhas

Copy link
Copy Markdown
Member

diffpy is a namespace-only (for Python-import) package to mark up software packages / products belonging to the DiffPy suite. There are diffpy.structure, diffpy.pdfgui, diffpy.srreal, etc., on PyPI and Conda repositories; each of them installs a diffpy namespace in a way that other diffpy.SOMETHING subpackages are visible and importable even if they reside in a different PYTHONPATH directory.

I'd advice against putting version value or any other content (except of namespacing support) to diffpy/__init__.py, because it would cause conflicts and unpredictable results when several diffpy.SOMETHING packages were installed.

@sbillinge

Copy link
Copy Markdown
Contributor

closing, replaced by #29

@sbillinge sbillinge closed this Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants