Skip to content

Add setuptools_scm build arguments to pyproject.toml #110

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 7 commits into from
Jul 12, 2024

Conversation

dihm
Copy link
Contributor

@dihm dihm commented Feb 23, 2024

This provides further fixes to how we use setuptools_scm as noted in comments on #106.

This should fix the random build issues (of which I still cannot replicate the successful build from two weeks ago). Basic premise is that setuptools_scm will use whatever is in the pyproject.toml to determine the version scheme if it is getting version by inspecting files (ie not installing). It will use setup.py to override the pyproject.toml settings when installing, and it will use __version__.py to override everything when importing the package.

There are a few minor choices we could make here beyond what is currently in the PR:

  1. The os.getenv calls in setup.py and __version__.py are no longer required. I'm not sure they are even needed with this change. Should we just remove them?
  2. setuptools_scm is a sort of runtime dependency of all the packages right now. If you have a .git folder, it will fail if setuptools_scm isn't installed. I'm inclined to wrap that in a try/except so it just falls back to importlib_metadata instead and keep this off the official dependency list. That said, we could also just enforce it as a dependency for everyone, even it they are installing from pip.
  3. We could use this as an opportunity to port over setup.cfg to the pyproject.toml and only have one metadata file.
  4. It may not be a bad idea to drop node-and-date from the local scheme when installing, (particularly for editable mode). Then we wouldn't need the overrides in setup.py which I suspect might be fragile going forward. It also makes the package versions under conda list a bit less noisy (so only have v3.3.0.devN instead of v3.3.0.devN+SHA.date) and doesn't remove much information since the node/date info in an editable install is all but worthless anyway for how quickly it stales. Having that info at import time where it can update automatically is the only place I see it having real value.

These changes, assuming they are sufficient, will need to be ported to all the repos. So @philipstarkey, any thoughts before I get cracking on that?

@dihm dihm added the bug Something isn't working label Feb 23, 2024
@dihm dihm requested a review from philipstarkey February 23, 2024 20:30
@dihm dihm self-assigned this Feb 23, 2024
@dihm
Copy link
Contributor Author

dihm commented Mar 1, 2024

@philipstarkey I've gone ahead and made commits that implement all of the above suggestions. Happy to back out any that are beyond the pail.

@dihm dihm force-pushed the setuptools_scm_fix2 branch from 83b1cfa to 0f80202 Compare April 4, 2024 17:56
@dihm dihm force-pushed the setuptools_scm_fix2 branch from 0f80202 to b3358c9 Compare April 4, 2024 17:58
@dihm
Copy link
Contributor Author

dihm commented Jul 12, 2024

Going to go ahead with these changes since nothing heard. Will start working through the other projects to update to this standard.

@dihm dihm merged commit 346ee1d into labscript-suite:master Jul 12, 2024
dihm added a commit that referenced this pull request Apr 29, 2025
commit 6c5181f2fa45b572c0366285bd9a09f5b363efc2
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Apr 11 13:59:24 2025 -0400

    Merge pull request #113 from dihm/workflow_refresh

    Workflow refresh

commit 58c124a622e5db65d4bff3c2e03f83365e9bbef2
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Jul 12 17:15:52 2024 -0400

    Fix typo in metadata

commit 24c5b7a6af994e4ddd494fc2a6802fcb6ce1b0da
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Jul 12 17:11:01 2024 -0400

    Merge pull request #110 from dihm/setuptools_scm_fix2

    Add setuptools_scm build arguments to pyproject.toml

commit 58505653fcdb1da50c1fb0dc3f6c7bd60029068e
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Tue Mar 19 10:27:24 2024 -0400

    Merge pull request #111 from dihm/runmanager_dep_break

    Remove latent dependency on runmanager due to `get_shot_globals`.

commit 4cd0cf319ec1a3a1ba7a8f4b53f0cd48c1030b92
Author: Phil Starkey <philipstarkey@users.noreply.github.com>
Date:   Sat Feb 17 15:13:13 2024 +1100

    Merge pull request #102 from philipstarkey/philipstarkey/v3-refactor

    This is a first pass attempt at breaking up `labscript.py` into separate files. The idea here is that, while this might not be how we ultimately want things to be split up, at this point something is better than nothing. This should provide enough of a base that other people begin to feel comfortable moving things around and/or breaking things up logically. It also introduces some conceptual boundaries between output classes and the base device classes that handle timing/clock generation. My hope is that this split will open up the possibility of actually writing tests for some of this stuff. That's probably still a long way off (with several more refactors in between) but it's a step towards that goal!

    Other changes:
    * More modern context managers for warning suppression that can actually be used to enable/disable warnings, not just disable.
    * `config` is moved into `compiler` which means it should get reset between labscript shots and not just globally changed until you reload the compiler subprocess in runmanager.
    * Some better/more consistent formatting. I didn't run `black`/`ruff` but I think we should think about it soon.
    * Updated error message string formatting to use `f` strings for increased code readability
    * Fixed a mistake with trigger error detection that was never raised (and also the `if` condition around the unraised error was wrong anyway)
    * Fixed a minor bug in an error message for shutters (had open/close the wrong way around)
    * Probably some other small changes.

commit 87cab030f05562171984f3ad1470678a8ac90698
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Feb 9 13:24:34 2024 -0500

    Merge pull request #107 from dihm/update_workflow

    Update workflow pins to use node.js=20

commit 719460ec1936dc62942c4d85551c528941f7b789
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Feb 9 13:24:20 2024 -0500

    Merge pull request #106 from dihm/setuptools_scm_fix

    Ensure setuptools_scm uses `release-branch-semver`

commit 3981efc6ce62a1678a9a853073b59d702e931ff1
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Thu Jan 18 20:55:11 2024 -0500

    Merge pull request #103 from dihm/rtd_build

    Modernize RTD build
dihm added a commit that referenced this pull request Apr 29, 2025
commit 41d6e1c
Merge: bfc65fe b3869b7
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Apr 11 13:59:24 2025 -0400

    Merge pull request #113 from dihm/workflow_refresh

    Workflow refresh

commit b3869b7
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Apr 11 13:54:15 2025 -0400

    Update project metadata and remove old dependencies

commit 98be5f3
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Apr 11 13:54:02 2025 -0400

    Update workflow to latest and greatest

commit bfc65fe
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Jul 12 17:15:52 2024 -0400

    Fix typo in metadata

commit 346ee1d
Merge: 24f2d6a b3358c9
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Jul 12 17:11:01 2024 -0400

    Merge pull request #110 from dihm/setuptools_scm_fix2

    Add setuptools_scm build arguments to pyproject.toml

commit b3358c9
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Thu Feb 29 16:24:39 2024 -0500

    Make editable installs use `pyproject.toml` setuptools_scm config.

    Removes no longer necessary `setup.py`.

commit 225bbee
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Thu Apr 4 13:57:59 2024 -0400

    Move all project metadata to `pyproject.toml`

commit f41d956
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Thu Feb 29 20:30:15 2024 -0500

    Make `setuptools_scm` optional, even if installed in editable mode.

commit 67a5a89
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Thu Feb 29 16:19:46 2024 -0500

    Remove environment checks in `setup.py` for setuptools_scm

commit 003ce6c
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Thu Feb 29 16:19:14 2024 -0500

    Remove environment checks on `__version__.py` setuptools_scm

commit dfb3b00
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Feb 23 15:16:30 2024 -0500

    Remove `SCM_LOCAL_SCHEME` environment variable in release workflow as it is no longer used.

commit 06b0b44
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Feb 23 13:47:37 2024 -0500

    Add setuptools_scm build arguments to pyproject.toml

commit 24f2d6a
Merge: 37be1bf 554968f
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Tue Mar 19 10:27:24 2024 -0400

    Merge pull request #111 from dihm/runmanager_dep_break

    Remove latent dependency on runmanager due to `get_shot_globals`.

commit 554968f
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Tue Mar 19 10:22:34 2024 -0400

    Remove latent dependency on runmanager due to `get_shot_globals`.

    Bumps required version of `labscript_utils` to match.

commit 37be1bf
Merge: 332c180 714d982
Author: Phil Starkey <philipstarkey@users.noreply.github.com>
Date:   Sat Feb 17 15:13:13 2024 +1100

    Merge pull request #102 from philipstarkey/philipstarkey/v3-refactor

    This is a first pass attempt at breaking up `labscript.py` into separate files. The idea here is that, while this might not be how we ultimately want things to be split up, at this point something is better than nothing. This should provide enough of a base that other people begin to feel comfortable moving things around and/or breaking things up logically. It also introduces some conceptual boundaries between output classes and the base device classes that handle timing/clock generation. My hope is that this split will open up the possibility of actually writing tests for some of this stuff. That's probably still a long way off (with several more refactors in between) but it's a step towards that goal!

    Other changes:
    * More modern context managers for warning suppression that can actually be used to enable/disable warnings, not just disable.
    * `config` is moved into `compiler` which means it should get reset between labscript shots and not just globally changed until you reload the compiler subprocess in runmanager.
    * Some better/more consistent formatting. I didn't run `black`/`ruff` but I think we should think about it soon.
    * Updated error message string formatting to use `f` strings for increased code readability
    * Fixed a mistake with trigger error detection that was never raised (and also the `if` condition around the unraised error was wrong anyway)
    * Fixed a minor bug in an error message for shutters (had open/close the wrong way around)
    * Probably some other small changes.

commit 332c180
Merge: a99573e 1071fee
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Feb 9 13:24:34 2024 -0500

    Merge pull request #107 from dihm/update_workflow

    Update workflow pins to use node.js=20

commit a99573e
Merge: 6f38c9a bf0d2b7
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Feb 9 13:24:20 2024 -0500

    Merge pull request #106 from dihm/setuptools_scm_fix

    Ensure setuptools_scm uses `release-branch-semver`

commit bf0d2b7
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Feb 9 13:21:32 2024 -0500

    Ensure setuptools_scm uses `release-branch-semver`

    Updates setuptools and setuptools_scm pin in the build.

commit 1071fee
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Feb 9 13:19:20 2024 -0500

    Update workflow pins to use node.js=20

commit 714d982
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 16:24:56 2024 +1100

    Remove `compiler` module from autosummary documentation due to a bug that breaks documentation.

commit 7e0ab10
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 16:20:40 2024 +1100

    Reamed `Compiler` class to work around an autosummary bug

commit 32b3d6e
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 16:15:18 2024 +1100

    Updated module doc strings so they are only a single sentence and relocated `print_time()` function to utils.

commit 5ea15e8
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 16:05:28 2024 +1100

    Added copyright notices and docstrings to new files

commit 5c04f42
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 15:49:00 2024 +1100

    Split `AnalogIn` into it's own module so that documentation makes a little more sese

commit 59757a4
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 13:08:04 2024 +1100

    Added note about not using generic classes directly

commit 9a9e205
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 13:00:34 2024 +1100

    Attempt to fix module cross reference

commit 8775e24
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 12:55:17 2024 +1100

    Updated connection table documentation with links to class documentation.

commit 36dad35
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 12:37:53 2024 +1100

    First pass at getting new files included in the docs

commit ba082c1
Merge: 91025be 6f38c9a
Author: Phil Starkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 12:24:42 2024 +1100

    Merge branch 'labscript-suite:master' into philipstarkey/v3-refactor

commit 91025be
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Jan 27 12:16:47 2024 +1100

    Revert change to use public property in `ClockLine.add_device` internals

commit 6f38c9a
Merge: 01cc205 dd410e4
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Thu Jan 18 20:55:11 2024 -0500

    Merge pull request #103 from dihm/rtd_build

    Modernize RTD build

commit dd410e4
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Thu Jan 18 20:51:16 2024 -0500

    Modernize RTD build

commit 5b580ad
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Thu Jan 4 17:30:11 2024 +1100

    Fix bug with cached imports in utils

commit 4d0089b
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Thu Jan 4 17:29:52 2024 +1100

    Fix bug in error condition. This was an error that perviously wasn't raised (message was formed, but not raised), hence why the incorrect condition was never noticed.

commit 96b3dd3
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Thu Jan 4 17:28:26 2024 +1100

    Revert change made that tried to write to a property

commit 6d4535b
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Wed Jan 3 20:40:40 2024 +1100

    * Move `Output` classes to a separate file.
    * `config` also refactored to be inside `compiler`.
    * constants moved into their own file.
    * warnings context managers moved into the `utils` file

commit 63ce813
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Wed Jan 3 19:59:13 2024 +1100

    Updated output classes to more modern Python and improved some formatting.

    Also fixed a couple of bugs with error messages (not being raised, having incorrect text, etc.)

commit 6e43872
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Wed Jan 3 16:31:23 2024 +1100

    Moved core classes into their own files. Also moved some utils functions out of labscript.py.

commit 994ccc6
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Wed Jan 3 16:14:57 2024 +1100

    Updated core device subclasses (`Pseudoclock`, `ClockLine`, `TriggerableDevice`, `IntermediateDevice`, etc.) to more modern Python and improved some formatting.

    Also fixed a bug in an error message.

commit 461344e
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Dec 30 21:14:30 2023 +1100

    Break out `Device` class into it's own file

commit 5345e6d
Author: philipstarkey <philipstarkey@users.noreply.github.com>
Date:   Sat Dec 30 21:11:48 2023 +1100

    Initial work centered around refactoring the `Device` and `compiler` classes, and updating code to take advantage of more modern Python (3.6+) features.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant