Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixes .pth file has no effect in editable install #58

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

Conversation

philipstarkey
Copy link
Member

Fixes #43

The .pth file is now copied during labscript-profile-create if it does not exist in the site-packages dir (where the .egg-info files exist) and if it the .pth file exists in the package structure (aka labscript-utils it is an editable install)

The labscript-suite.pth file has been updated to not raise an exception if labscript-suite has been uninstalled (so we do not have to worry about cleanup).

Also updated the labscript_profile.add_userlib_and_pythonlib function to use the site library for adding userlib and pythonlib to the system path.

Fixes labscript-suite#43

The .pth file is now copied during `labscript-profile-create` if it does not exist in the site-packages dir (where the .egg-info files exist) and if it the .pth file exists in the package structure (aka labscript-utils it is an editable install)

The labscript-suite.pth file has been updated to not raise an exception if labscript-suite has been uninstalled (so we do not have to worry about cleanup).

Also updated the `labscript_profile.add_userlib_and_pythonlib` function to use the `site` library for adding userlib and pythonlib to the system path.
@philipstarkey
Copy link
Member Author

I have tested this for conda + developer install. I have not tested in the other install procedures (which will require using test PyPI/conda packages). It would be good to at least test with ediatble Windows Store Python (would appreciate someone else testing that as I don't have it installed)

@philipstarkey philipstarkey force-pushed the philipstarkey/issue43 branch from 13d9e59 to 271439e Compare June 24, 2020 03:10
@philipstarkey
Copy link
Member Author

Gah, RTD fails due to a long standing bug using site within virtualenv (which RTD uses over venv for some reason).

This means that any project importing desktop-app will fail to build on RTD.

@chrisjbillington: I know this is ridiculous, but how would you feel about updating desktop-app to not call site.getsitepackages() unless it actually exists in site?

@chrisjbillington
Copy link
Member

Sure, though I think there's a trick I saw somewhere about this problem, I'll see if I can find it otherwise just not call it.

@chrisjbillington
Copy link
Member

Done, desktop-app now doesn't call those functions until they're needed.

Also, I made get_install_directory() public (in the sense of removing the prefixed underscore, anyway).

I'll have a go at adding a commit to your branch to use the new function name and depend on the new desktop-app version

Which renames `_get_install_directory` to not have an underscore,
and which fixes a bug preventing docs from building on RTD.
@rpanderson
Copy link
Member

Relevant:

@chrisjbillington
Copy link
Member

Yes, I've got my eye on that Python issue. If they remove it they'll need to replace it with something else since plenty of projects use it defensible ways. We'll have to adapt to whatever that is when it comes. I've mentioned our use case in that thread, though that was back when we didn't care about the code execution and were just hard-coding paths.

@chrisjbillington
Copy link
Member

One flaw with this approach (which didn't occur to me earlier) is that it only copies the .pth file if a profile is being created (duh).

This is a flaw because installation is not necessarily followed by profile creation - a profile might already exist. Perhaps we should add a custom develop command to our setup.py that runs the usual develop command and then copies the .pth file if so.

Use a custom develop command to copy the .pth file into site-packages
when `python setup.py develop` is run - this is what pip does under the
hood for `pip install -e`.

No longer need desktop-app to locate site-packages, as the setuptools
command class knows it as `self.install_dir`.

The file is not removed by `pip uninstall`, but due to the `try:
except:`s in the `.pth` file, leaving it behind is harmless.

It is removed if the user runs whatever `setup.py` command undoies
@chrisjbillington
Copy link
Member

chrisjbillington commented Jun 24, 2020

I took the liberty of moving the copying of the file into a custom develop command in setup.py (which is what gets run when you do pip install -e. This means the copying really is tied to creation of an editable install instead of profile creation.

Hopefully this is agreeable phil!

No desktop-app dependency is required this way since the setuptools machinery knows which site packages directory it is being installed to already.

The problem of the file being left behind remains, so the try: except:s to make it inert are still necessary.

@philipstarkey
Copy link
Member Author

Sure. Should we be deleting the file as well if we're uninstalling? (I assume that's what self.uninstall` indicates?)

@chrisjbillington
Copy link
Member

I did initially write code for that but pip doesn't actually call setup.py when uninstalling a package installed in editable mode, so the file will still be left behind

The uninstall code will run if a user runs python setup.py develop --uninstall, but they shouldn't really do that since they should stick to using pip.

Do you think I should put it back in? I lean against since it's a bit strange if it only works if the user is using non-recommended methods of managing their packages and we've otherwise accepted we're going to leave the file behind.

@philipstarkey
Copy link
Member Author

Yeah, let's leave as is then. It's a bit dumb that pip doesn't call setup.py on uninstall...but then that seems to describe most aspect of python package management...

@chrisjbillington
Copy link
Member

Lol. At least they acknowledged what a hodge-podge the ecosystem is by making their mascot a platypus

@chrisjbillington chrisjbillington merged commit 5025b1b into labscript-suite:master Jun 24, 2020
@philipstarkey philipstarkey deleted the philipstarkey/issue43 branch June 24, 2020 06:59
philipstarkey added a commit that referenced this pull request Jun 25, 2020
commit d8b8343
Merge: 9bc7a39 bfa6932
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 20:48:39 2020 -0400

    Merge pull request #59 from philipstarkey/fix-h5py-file-mode

    Addresses #47 for this module

commit 9bc7a39
Merge: 1189334 66d0be4
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 20:30:42 2020 -0400

    Merge pull request #55 from rpanderson/example_IMAQdx_remote

    Example labscript and analysis scripts for IMAQdxCamera and RemoteBLACS

commit bfa6932
Author: philipstarkey <[email protected]>
Date:   Thu Jun 25 10:25:49 2020 +1000

    Addresses #47 for this module

commit 1189334
Merge: 5025b1b 0b0d07a
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 19:35:15 2020 -0400

    Merge pull request #54 from rpanderson/example_experiment

    Minimal working connection table and example experiment script

commit 66d0be4
Author: Russell Anderson <[email protected]>
Date:   Mon Jun 15 13:37:23 2020 +1000

    lyse analysis script demonstrating some Run methods for example_IMAQdx_remote

commit a48a9c0
Author: Russell Anderson <[email protected]>
Date:   Mon Jun 15 13:15:48 2020 +1000

    Example connection table and labscript experiment script for RemoteBLACS and IMAQdxCamera

commit 5025b1b
Merge: f77525f ed76901
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 02:16:29 2020 -0400

    Merge pull request #58 from philipstarkey/philipstarkey/issue43

    Fixes .pth file has no effect in editable install

commit ed76901
Author: chrisjbillington <[email protected]>
Date:   Wed Jun 24 01:23:44 2020 -0400

    Move copying of .pth file into setup.py

    Use a custom develop command to copy the .pth file into site-packages
    when `python setup.py develop` is run - this is what pip does under the
    hood for `pip install -e`.

    No longer need desktop-app to locate site-packages, as the setuptools
    command class knows it as `self.install_dir`.

    The file is not removed by `pip uninstall`, but due to the `try:
    except:`s in the `.pth` file, leaving it behind is harmless.

    It is removed if the user runs whatever `setup.py` command undoies

commit 894e245
Author: chrisjbillington <[email protected]>
Date:   Wed Jun 24 00:04:13 2020 -0400

    Require desktop-app 0.2.6

    Which renames `_get_install_directory` to not have an underscore,
    and which fixes a bug preventing docs from building on RTD.

commit 271439e
Author: philipstarkey <[email protected]>
Date:   Wed Jun 24 12:53:49 2020 +1000

    Removed support for custom development directories from path

commit dd098a5
Author: philipstarkey <[email protected]>
Date:   Wed Jun 24 12:38:19 2020 +1000

    Fixes .pth file has no effect in editable install
    Fixes #43

    The .pth file is now copied during `labscript-profile-create` if it does not exist in the site-packages dir (where the .egg-info files exist) and if it the .pth file exists in the package structure (aka labscript-utils it is an editable install)

    The labscript-suite.pth file has been updated to not raise an exception if labscript-suite has been uninstalled (so we do not have to worry about cleanup).

    Also updated the `labscript_profile.add_userlib_and_pythonlib` function to use the `site` library for adding userlib and pythonlib to the system path.

commit 0b0d07a
Author: Russell Anderson <[email protected]>
Date:   Mon Jun 22 17:48:00 2020 +1000

    start()/stop() in __main__ block so connection table can be imported

commit 4c19de9
Author: Russell Anderson <[email protected]>
Date:   Mon Jun 15 13:12:52 2020 +1000

    Add AnalogOut with ramp example, rename DigitalOut connection

commit 9b64a0d
Author: Russell Anderson <[email protected]>
Date:   Wed Jun 10 23:09:03 2020 +1000

    Minimal example connection table and labscript using dummy devices

commit f77525f
Author: Phil Starkey <[email protected]>
Date:   Sat Jun 20 18:09:53 2020 +1000

    Removed unnecessary fixed title from main TOC

    This was erroneously added in #57

commit 5e02b01
Merge: 3f78207 8b19766
Author: Phil Starkey <[email protected]>
Date:   Sat Jun 20 18:07:04 2020 +1000

    Merge pull request #57 from philipstarkey/master

    Changed URL for API reference to be shorter
    Fixed bug with readthedocs auto PR build

commit 8b19766
Author: philipstarkey <[email protected]>
Date:   Sat Jun 20 12:02:51 2020 +1000

    Updated method call for stylesheet to remove deprecated warning in build

commit 56fdd63
Author: philipstarkey <[email protected]>
Date:   Sat Jun 20 11:46:33 2020 +1000

    Fixed sphinx conf to detect PR builds and link to 'latest' instead of stable

commit 9889d19
Author: philipstarkey <[email protected]>
Date:   Sat Jun 20 10:44:04 2020 +1000

    Changed URL for API reference to be shorter

commit 3f78207
Merge: bbd928a bf9d10e
Author: Phil Starkey <[email protected]>
Date:   Fri Jun 19 18:58:37 2020 +1000

    Merge pull request #56 from philipstarkey/master

    Added links to other component docs

commit bf9d10e
Author: philipstarkey <[email protected]>
Date:   Fri Jun 19 16:06:09 2020 +1000

    Addressing latest review comments

commit e75b6bc
Author: philipstarkey <[email protected]>
Date:   Fri Jun 19 11:23:49 2020 +1000

    Updated docs to use jinja template for component doc links

commit 9c61238
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 17:14:57 2020 +1000

    Removed autogenerated rst file from version control

commit 2303185
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:43:29 2020 +1000

    Updated .gitignore with latest GitHub defaults

commit 87b757e
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:39:52 2020 +1000

    Relocated custom sphinx gitignore rules

commit 75813a5
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:31:01 2020 +1000

    Updated PR as per review in labscript-suite/labscript-suite#48

commit bbd928a
Author: Russell Anderson <[email protected]>
Date:   Wed Jun 17 11:39:17 2020 +1000

    Populated README.md with styling, iconogrpahy, prose, and badges

commit 573c521
Author: philipstarkey <[email protected]>
Date:   Tue Jun 16 18:10:25 2020 +1000

    Added links to other component docs
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.

.pth file has no effect in editable install
3 participants