Skip to content

Commit

Permalink
Bundle win32 binaries with distributed package
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Jan 5, 2015
1 parent b41cfed commit 060062b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ __pycache__
lib/pyfrc.egg-info
lib/pyfrc/version.py

lib/pyfrc/robotpy/win32/plink.exe
lib/pyfrc/robotpy/win32/psftp.exe

.settings
docs/_build

Expand Down
Empty file.
25 changes: 24 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@
from os.path import dirname, exists, join
import sys, subprocess
from setuptools import find_packages, setup
from urllib.request import urlretrieve

setup_dir = dirname(__file__)
base_package = 'pyfrc'
version_file = join(setup_dir, 'lib', base_package, 'version.py')

# Download plink/psftp
ext_dir = join(setup_dir, 'lib', base_package, 'robotpy', 'win32')
ext_files = {
'plink.exe': 'http://the.earth.li/~sgtatham/putty/latest/x86/plink.exe',
'psftp.exe': 'http://the.earth.li/~sgtatham/putty/latest/x86/psftp.exe'
}

for file, uri in ext_files.items():
if exists(join(ext_dir, file)):
continue

print("Downloading %s" % file)
def _reporthook(count, blocksize, totalsize):
percent = int(count*blocksize*100/totalsize)
sys.stdout.write("\r%02d%%" % percent)
sys.stdout.flush()

urlretrieve(uri, join(ext_dir, file), _reporthook)
print()

# Automatically generate a version.py based on the git version
if exists(join(setup_dir, '.git')):
p = subprocess.Popen(["git", "describe", "--tags", "--dirty=-dirty"],
Expand Down Expand Up @@ -43,8 +64,10 @@
author_email='robotpy@googlegroups.com',
url='https://github.com/robotpy/pyfrc',
license='BSD',
packages=find_packages(),
packages=find_packages(where='lib'),
package_dir={'': 'lib'},
package_data={'pyfrc': ['robotpy/win32/plink.exe',
'robotpy/win32/psftp.exe']},
install_requires=install_requires,
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 060062b

Please sign in to comment.