Pages - Menu

標籤

AWS (1) bash (1) Boost (2) C (2) CMake (2) Concurrency_Programming (3) CPP (37) Database (2) DNS (1) Docker (4) Docker-Compose (1) ELK (1) emacs (4) gcp (1) gdrive (1) git (1) gitbash (2) gitlab (1) kvm (4) Linux (5) MT4 (4) MT5 (4) Multicast (2) MySQL (2) Nijatrader8 (1) OpenCV (1) Python (4) QT5 (1) R (1) rdp (3) screenshot (1) ssh (3) Tabnine (1) TCP (1) TensorFlow (1) Tools (12) Ubuntu_1904 (11) Ubuntu_20_04 (5) UDP (1) VS2010 (1) VS2015 (1) VS2019 (1) WebServer (1) Win10 (1) winmerge (1) WSL (1) xrdp (1)

搜尋此網誌

2021年11月26日星期五

Packaging Python Project

Reference

https://packaging.python.org/tutorials/packaging-projects/

https://dzone.com/articles/executable-package-pip-install 

https://setuptools.pypa.io/en/latest/userguide/declarative_config.html

Cheat sheet



# Install all needed packages
python -m pip install --upgrade pip setuptools wheel
python -m pip install tqdm
python -m pip install --upgrade twine
python -m pip install --upgrade build

# Prepare the package structure and all needed files

# Build the package
python -m build

# Upload to test
python -m twine upload --repository testpypi dist/*
# Upload to prod
python -m twine upload --repository pypi dist/*

# Install the package by specific the repo
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-pkg-YOUR-USERNAME-HERE

2021年9月5日星期日

2021年3月27日星期六

C++ package manager CMake vcpkg

 How to use vcpkg with CMake

Steps

  • Create C++ project by CCreate
    • CCreate -p TradingPlatform
    • cd TradingPlatform/Projects/TradingPlatform/app
    • CCreate -a ThePlatform
  • Install vcpkg
    • https://docs.microsoft.com/en-us/cpp/build/install-vcpkg?view=msvc-160&tabs=linux
    • git clone https://github.com/microsoft/vcpkg
    • cd ./vcpkg
    • ./bootstrap-vcpkg.sh
  • Install package
    • cd ./vcpkg
    • ./vcpkg search | grep json
    • ./vcpkg install rapidjson
Computing installation plan...
The following packages will be built and installed:
    rapidjson[core]:x64-linux -> 2020-09-14
Detecting compiler hash for triplet x64-linux...
Could not locate cached archive: /home/sulfred/.cache/vcpkg/archives/16/16e324f00567b9fbcd2f106e12e631094b31b5de.zip
Starting package 1/1: rapidjson:x64-linux
Building package rapidjson[core]:x64-linux...
-- Downloading https://github.com/Tencent/rapidjson/archive/ce81bc9edfe773667a7a4454ba81dac72ed4364c.tar.gz -> Tencent-rapidjson-ce81bc9edfe773667a7a4454ba81dac72ed4364c.tar.gz...
-- Extracting source /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/downloads/Tencent-rapidjson-ce81bc9edfe773667a7a4454ba81dac72ed4364c.tar.gz
-- Using source at /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/buildtrees/rapidjson/src/c72ed4364c-35829b36f2.clean
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Installing: /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/packages/rapidjson_x64-linux/share/rapidjson/copyright
-- Installing: /home/sulfred/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Projects/vcpkg/packages/rapidjson_x64-linux/share/rapidjson/usage
-- Performing post-build validation
-- Performing post-build validation done
Stored binary cache: /home/sulfred/.cache/vcpkg/archives/16/16e324f00567b9fbcd2f106e12e631094b31b5de.zip
Building package rapidjson[core]:x64-linux... done
Installing package rapidjson[core]:x64-linux...
Installing package rapidjson[core]:x64-linux... done
Elapsed time for package rapidjson:x64-linux: 1.485 s

Total elapsed time: 1.76 s

The package rapidjson provides CMake integration:

    find_package(RapidJSON CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAPIDJSON_INCLUDE_DIRS})
  • Cmake setting
    • -DCMAKE_TOOLCHAIN_FILE=../Projects/vcpkg/scripts/buildsystems/vcpkg.cmake
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Debug$ cat readme.txt | grep cmake
cmake -G Ninja ../Projects -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../Install -DCMAKE_TOOLCHAIN_FILE=../Projects/vcpkg/scripts/buildsystems/vcpkg.cmake
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform/Debug$ cd ..
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform$ ll
total 24
drwxrwxr-x 6 sulfred sulfred 4096 Mar 27 20:05 ./
drwxrwxr-x 3 sulfred sulfred 4096 Mar 27 20:10 ../
drwxrwxr-x 4 sulfred sulfred 4096 Mar 27 20:29 Debug/
drwxrwxr-x 3 sulfred sulfred 4096 Mar 27 20:30 Install/
drwxrwxr-x 4 sulfred sulfred 4096 Mar 27 20:30 Projects/
drwxrwxr-x 2 sulfred sulfred 4096 Mar 27 20:05 Release/
sulfred@sulfred-PC:~/Documents/SoftwareDev/github/SulfredLee/DailyProblem/cpp/app/ProjectCreater/bin/TradingPlatform$ ll Projects/
total 24
drwxrwxr-x  4 sulfred sulfred 4096 Mar 27 20:30 ./
drwxrwxr-x  6 sulfred sulfred 4096 Mar 27 20:05 ../
-rw-rw-r--  1 sulfred sulfred 1025 Mar 27 20:28 CMakeLists.txt
drwxrwxr-x  5 sulfred sulfred 4096 Mar 27 20:30 TradingPlatform/
-rw-rw-r--  1 sulfred sulfred  560 Mar 27 20:05 TradingPlatform.cmake
drwxrwxr-x 14 sulfred sulfred 4096 Mar 27 20:12 vcpkg/
k
    • cat ../Projects/CMakeLists.txt
      • find_package(RapidJSON CONFIG REQUIRED)
      • message(STATUS "Rapid include PATH: " ${RAPIDJSON_INCLUDE_DIRS})

2020年11月15日星期日

Use winmerge in git bash

 .gitconfig

location

  •  C:\Users\<name>\.gitconfig

.gitconfig

[diff]
       tool = winmerge
       prompt = false
[difftool "winmerge"]
       path = C:/Program Files/WinMerge/winmergeu.exe
	   cmd = \"C:/Program Files/WinMerge/winmergeu.exe\" /e /u /wl /dl "$LOCAL" /dr "$REMOTE" "$LOCAL" "$REMOTE"
[merge]
       tool = winmerge
       prompt = false
[mergetool "winmerge"]
       path = C:/Program Files/WinMerge/winmergeu.exe
       cmd = \"C:/Program Files/WinMerge/winmergeu.exe\" /e /u /wl /dl "$LOCAL" /dr "$REMOTE" "$LOCAL" "$REMOTE" -o "$MERGED"
       trustExitCode = true
       keepBackup = false
[diff]
       tool = meld
       prompt = false
[difftool "meld"]
       path = C:/Program Files (x86)/Meld/Meld.exe
	   cmd = \"C:/Program Files (x86)/Meld/Meld.exe\" "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
[merge]
       tool = meld
       prompt = false
[mergetool "meld"]
       path = C:/Program Files (x86)/Meld/Meld.exe
       cmd = \"C:/Program Files (x86)/Meld/Meld.exe\" "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
       trustExitCode = true
       keepBackup = false
[user]
	email = sflee1112@gmail.com
	name = SulfredLee

2020年11月6日星期五

How cmake find package works

 Aim

Here are some examples showing how to use cmake find packet.

 Learn from

Here

Examples - use default modules

ALSA library

You can install the library first.

$ sudo apt-get install libasound2

You can put the following code into CMakeLists.txt.

# Handle ALSA / ASound libraries
find_package(ALSA)
if (ALSA_FOUND)
  message (STATUS "Info - Found ALSA library: ${ALSA_LIBRARY}")
  message (STATUS "Info - Found ALSA include: ${ALSA_INCLUDE_DIR}")
else (ALSA_FOUND)
  message (FATAL_ERROR "Info - ALSA is not found")
endif (ALSA_FOUND)

How can I know which variables I can use?

 

2020年10月23日星期五

Install xrdp on ubuntu

 Ubuntu 20.04

Install and use (Basic)

  • Install xrdp by

$ sudo apt-get install xrdp

  • Logout, since you cannot remote login while the session is begin used.
  • Connect from other PC, for example:

 

  • DONE

If not working

  • By default Xrdp uses the /etc/ssl/private/ssl-cert-snakeoil.key file which is readable only by users that are members of the “ssl-cert” group. Learn From
  • Add to group ssl-start.
$ sudo adduser xrdp ssl-start

Change close lip behavior



  • Restart service to activate your change
 $ sudo systemctl systemd-logind.service

2020年10月3日星期六

Core dump file in ubuntu

 Aim

When running c++ application, we would like to get the core dump when the application is crashed. How to get those files under linux?

Learn from

Link

Steps

Add to ~/.bashrc 

ulimit -c unlimited

Add to /etc/sysctl.conf

kernel.core_pattern = core.%e.%p.%t

Run command:

$ sudo sysctl --system

Ubuntu KVM guest os network

 On Ubuntu 20.04

You can use the default setting first:


If the guest OS cannot connect to internet, you may try the host nic and bridge it:


If that is not okay, you may need to create a new network source. The easiest way is to install VMWare workstation or Virtual box. They will create the needed network configuration for their VMs. Now you can use the network source created by them. Here is an example:




Ubuntu KVM OpenGL

 On Ubuntu 20.04

Setup

This acceleration can be use only locally. You have to disable the spice server first.


Then you can start your VM through graphical console

Ubuntu KVM multiple monitors

 On Ubuntu 20.04

Learn From

 Steps

Add one more Video QXL 


Set Display Spice and open port for example 5907


 Start VM without using virt-manager graphical console

Finally, you need to use remote-viewer and open up the guest firewall:

You may try directly remote-view the instance first, if not work, you may add the firewall steps

$ sudo apt-get install firewalld
$ sudo firewall-cmd --permanent --add-service=vdsm
$ sudo firewall-cmd --reload
$ remote-viewer spice://localhost:5907