GithubHelp home page GithubHelp logo

Comments (5)

prahladyeri avatar prahladyeri commented on June 14, 2024

Hey cemeyer,

Thanks for such objective review and helping me improve this software. The reason for this whole mess started when I decided to provide a symlink to hotspotd post the installation:

distutils.file_util.copy_file(loc + '/hotspotd/hotspotd.py','/usr/bin/hotspotd',link='sym',preserve_mode=1)
os.chmod(loc + '/hotspotd/hotspotd.py',0755)

You see, this is very much required otherwise, how can the user run sudo hotspotd without typing the path to entire python library?
Now how do I find the install location (loc variable)? distutils doesn't provide any easy way to do that. Googling led me to these links and I came up with the implemented solution:

http://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory

http://stackoverflow.com/questions/6362466/install-python-extension-to-specific-location

http://stackoverflow.com/questions/7354096/override-default-installation-directory-for-python-bdist-windows-installer

If you do know abt any way of detecting the install path, please let me know.

The replacement of sys.prefix with /usr/local was done in haste to fix bug#1. I guess that can be undone now.

from hotspotd.

prahladyeri avatar prahladyeri commented on June 14, 2024

I was also prodded along by this python doc page that says on all pure unix systems, the install path is gonna be:

/usr/local/lib/pythonX.Y/site-packages

But apparently it doesn't. Bug #1 arose as the files were installed in dist-packages instead of site-packages

from hotspotd.

cemeyer avatar cemeyer commented on June 14, 2024

Hi Prahlad,

Generally Python binaries whose code lives in site-packages use one of a couple patterns:

  • Don't install hotspotd.py in site-packages, instead install it directly in /usr/bin

Or

  • Don't symlink hotspotd from /usr/bin but instead create a dummy script that just includes hotspotd and executes hotspotd.main() or similar.

Re: Python doc site-packages link, see the immediately following comment:

Most Linux distributions include Python as a standard part of the system, so prefix and exec-prefix
are usually both /usr on Linux. If you build Python yourself on Linux (or any Unix-like system), the
default prefix and exec-prefix are /usr/local.

I'm not super familiar with Python packaging so I can't help out much more. But this is definitely wrong :-).

from hotspotd.

prahladyeri avatar prahladyeri commented on June 14, 2024

Hey Conrad,

Many thanks for the useful suggestion about creating a dummy script that just starts the hotspotd. I came to know that files specified as scripts directly go to the /usr/local/bin folder. Now the setup code has been reduced to just:

#INSTALL IT
from distutils.core import setup
s = setup(name='hotspotd',
    version='0.1',
    description='Small daemon to create a wifi hotspot on linux',
    license='MIT',
    author='Prahlad Yeri',
    author_email='[email protected]',
    url='https://github.com/prahladyeri/hotspotd',
    #py_modules=['hotspotd','cli'],
    packages=['hotspotd'],
    package_dir={'hotspotd': ''},
    package_data={'hotspotd': ['run.dat']},
    scripts=['hotspotd']
    #data_files=[('config',['run.dat'])],
    )

Also, I had considered developing this in C language myself, but went with python for two reasons:

  • python code can easily run on multi-architectures without tweaks.
  • C seems an overkill (at least for now)
  • If at all any need arises for performance, etc. we can always create a C extension or use ctypes in python to call the C library.

Thanks again for your support!

Cheers,
Prahlad

from hotspotd.

cemeyer avatar cemeyer commented on June 14, 2024

Now the setup code has been reduced to just

Great! That looks pretty reasonable.

from hotspotd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.