Skip to content
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

Reload not working when app package is symlinked from site-packages #60

Closed
merwok opened this issue Nov 7, 2019 · 9 comments · Fixed by #61
Closed

Reload not working when app package is symlinked from site-packages #60

merwok opened this issue Nov 7, 2019 · 9 comments · Fixed by #61

Comments

@merwok
Copy link

merwok commented Nov 7, 2019

flit is a new package build tool that’s I find nicer than distutils/setuptools for simple projects (issues with missing package data are gone!). The develop install equivalent is symlink install that creates and installs dist-info dir + a symlink from site-packages to project dir so that imports work. With that setup, editing a file does not cause hupper (used via pserve) to reload the app.

@merwok merwok changed the title Reload not working when app is symlinked from site-packages Reload not working when app package is symlinked from site-packages Nov 7, 2019
@digitalresistor
Copy link
Member

That's the same method that python setup.py develop or pip -e . uses, so I find it weird that this does not work.

What operating system are you using?

@mmerickel
Copy link
Member

mmerickel commented Nov 9, 2019 via email

@merwok
Copy link
Author

merwok commented Nov 11, 2019

Ha, I was under the impression that hupper was already monitoring site-packages!
(I think I saw a restart after I installed or updated a package, but maybe I read that wrong)

Is there an acceptable workaround, like a setting to specify extra files to monitor, or a trick like touch development.ini to cause a reload?

(the django devserver reloader sometimes misses changes to views, so I’m used to needing touch models.py 🤷‍♂️)

@digitalresistor
Copy link
Member

touch development.ini should work since it's not located in site-packages.

@merwok
Copy link
Author

merwok commented Nov 11, 2019

That will work!

I’m still not sure if this line in the readme is accurate:

hupper is an integrated process monitor that will track changes to any imported Python files in sys.modules

I will test with changes to existing file (already loaded module) vs. adding a new submodule in the symlinked package.

@mmerickel
Copy link
Member

Yeah it was an optimization hupper made in 1.4 https://github.com/Pylons/hupper/blob/master/CHANGES.rst#14-2018-10-26 to skip site-packages. The reason was because it was adding unnecessary overhead for most projects - #34.

It might be possible to just special case symlinked stuff and not count it as a system path. The filtering is happening here:

def in_system_paths(self, path):
for prefix in self.system_paths:
if path.startswith(prefix):
return True
return False
def get_system_paths():
paths = get_site_packages()
for name in {'stdlib', 'platstdlib', 'platlib', 'purelib'}:
path = sysconfig.get_path(name)
if path is not None:
paths.append(path)
return paths

@mmerickel
Copy link
Member

mmerickel commented Nov 12, 2019

As I think about it more, maybe the best option would be to resolve paths to their os.path.realpath. I think right now hupper only forces paths to be absolute but not real. Only then should we test if it's a system path. I suppose this would include some folders that are symlinked because virtualenvs can legitimately symlink a bunch of their assets from the system site packages but it seems probably worth the tradeoff.

@mmerickel
Copy link
Member

@merwok any chance you can easily test whether #61 works for you?

@merwok
Copy link
Author

merwok commented Nov 12, 2019

Easy enough: pip install git+https://github.com/mmerickel/hupper@realpath

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 a pull request may close this issue.

3 participants